コード例 #1
0
ファイル: ItemEnderface.java プロジェクト: krisdeds/EnderIO
  @Override
  public ItemStack onItemRightClick(
      ItemStack itemStack, World world, final EntityPlayer entityPlayer) {

    if (!world.isRemote) {
      return itemStack;
    }

    NBTTagCompound tag = itemStack.getTagCompound();
    boolean tagsSet = tag != null && tag.getBoolean(KEY_IO_SET);

    if (tag != null && tag.getBoolean(KEY_IO_SET)) {

      int x = tag.getInteger(KEY_IO_X);
      int y = tag.getInteger(KEY_IO_Y);
      int z = tag.getInteger(KEY_IO_Z);
      int dimension = tag.getInteger(KEY_DIMENSION);

      if (world.provider.dimensionId != dimension) {
        ChatMessageComponent c =
            ChatMessageComponent.func_111066_d("EnderIO block is in a different dimension.");
        entityPlayer.sendChatToPlayer(c);
        return itemStack;
      }

      Chunk c = world.getChunkFromBlockCoords(x, z);
      if (c == null || !c.isChunkLoaded) {
        ChatMessageComponent cm =
            ChatMessageComponent.func_111066_d("EnderIO block's chunk is not loaded.");
        entityPlayer.sendChatToPlayer(cm);
        return itemStack;
      }
      int blockId = world.getBlockId(x, y, z);
      if (blockId != EnderIO.blockEnderIo.blockID) {
        ChatMessageComponent cm =
            ChatMessageComponent.func_111066_d("EnderIO block has been destroyed.");
        entityPlayer.sendChatToPlayer(cm);
        return itemStack;
      }
      entityPlayer.openGui(EnderIO.instance, GuiHandler.GUI_ID_ENDERFACE, world, x, y, z);
      return itemStack;
    }
    ChatMessageComponent cm =
        ChatMessageComponent.func_111066_d(" Enderface not synchronized with EnderIO.");
    entityPlayer.sendChatToPlayer(cm);
    return itemStack;
  }
コード例 #2
0
  @Override
  public void processCommandPlayer(EntityPlayer sender, String[] args) {
    if (args.length >= 1) {
      if (!PermissionsAPI.checkPermAllowed(
          new PermQueryPlayer(sender, getCommandPerm() + ".others"))) {
        OutputHandler.chatError(sender, Localization.get(Localization.ERROR_NOPERMISSION));
        return;
      }
      EntityPlayerMP player = FunctionHelper.getPlayerForName(args[0]);
      if (player != null) {
        PlayerInfo.getPlayerInfo(player.username).back = new WarpPoint(player);

        PropQueryPlayerZone query =
            new PropQueryPlayerZone(
                player, "ForgeEssentials.BasicCommands.spawnPoint", ZoneManager.getGLOBAL(), true);
        PermissionsAPI.getPermissionProp(query);

        String val = query.getStringValue();
        String[] split = val.split("[;_]");

        int dim = Integer.parseInt(split[0]);
        int x = Integer.parseInt(split[1]);
        int y = Integer.parseInt(split[2]);
        int z = Integer.parseInt(split[3]);

        WarpPoint point =
            new WarpPoint(dim, x + .5, y + 1, z + .5, player.cameraYaw, player.cameraPitch);

        // teleport
        FunctionHelper.setPlayer(player, point);
        player.sendChatToPlayer(Localization.get("command.spawn.done"));
        return;
      } else {
        OutputHandler.chatError(sender, Localization.format(Localization.ERROR_NOPLAYER, args[0]));
        return;
      }
    } else if (args.length == 0) {
      PropQueryPlayerZone query =
          new PropQueryPlayerZone(
              sender, "ForgeEssentials.BasicCommands.spawnPoint", ZoneManager.getGLOBAL(), true);
      PermissionsAPI.getPermissionProp(query);

      String val = query.getStringValue();
      String[] split = val.split("[;_]");

      int dim = Integer.parseInt(split[0]);
      int x = Integer.parseInt(split[1]);
      int y = Integer.parseInt(split[2]);
      int z = Integer.parseInt(split[3]);

      WarpPoint spawn =
          new WarpPoint(dim, x + .5, y + 1, z + .5, sender.cameraYaw, sender.cameraPitch);
      PlayerInfo.getPlayerInfo(sender.username).back = new WarpPoint(sender);
      TeleportCenter.addToTpQue(spawn, sender);
      sender.sendChatToPlayer(Localization.get("command.spawn.done"));
    }
  }
コード例 #3
0
  @Override
  public boolean interactFirst(EntityPlayer var1) {
    if (this.worldObj.isRemote) {
      if (this.riddenByEntity == null) {
        var1.sendChatToPlayer(
            ChatMessageComponent.createFromText(
                Keyboard.getKeyName(GCCoreKeyHandlerClient.leftKey.keyCode)
                    + " / "
                    + Keyboard.getKeyName(GCCoreKeyHandlerClient.rightKey.keyCode)
                    + "  - "
                    + StatCollector.translateToLocal("gui.buggy.turn.name")));
        var1.sendChatToPlayer(
            ChatMessageComponent.createFromText(
                Keyboard.getKeyName(GCCoreKeyHandlerClient.accelerateKey.keyCode)
                    + "       - "
                    + StatCollector.translateToLocal("gui.buggy.accel.name")));
        var1.sendChatToPlayer(
            ChatMessageComponent.createFromText(
                Keyboard.getKeyName(GCCoreKeyHandlerClient.decelerateKey.keyCode)
                    + "       - "
                    + StatCollector.translateToLocal("gui.buggy.decel.name")));
        var1.sendChatToPlayer(
            ChatMessageComponent.createFromText(
                Keyboard.getKeyName(GCCoreKeyHandlerClient.openSpaceshipInv.keyCode)
                    + "       - "
                    + StatCollector.translateToLocal("gui.buggy.inv.name")));
      }

      return true;
    } else {
      if (this.riddenByEntity != null) {
        var1.mountEntity(null);
        return true;
      } else {
        var1.mountEntity(this);
        return true;
      }
    }
  }
コード例 #4
0
  @Override
  public boolean interactFirst(EntityPlayer var1) {
    if (this.worldObj.isRemote) {
      if (this.riddenByEntity == null) {
        var1.sendChatToPlayer(
            ChatMessageComponent.createFromText(
                Keyboard.getKeyName(GCKeyHandler.leftKey.keyCode)
                    + " / "
                    + Keyboard.getKeyName(GCKeyHandler.rightKey.keyCode)
                    + "  - "
                    + LanguageRegistry.instance().getStringLocalization("gui.buggy.turn.name")));
        var1.sendChatToPlayer(
            ChatMessageComponent.createFromText(
                Keyboard.getKeyName(GCKeyHandler.accelerateKey.keyCode)
                    + "       - "
                    + LanguageRegistry.instance().getStringLocalization("gui.buggy.accel.name")));
        var1.sendChatToPlayer(
            ChatMessageComponent.createFromText(
                Keyboard.getKeyName(GCKeyHandler.decelerateKey.keyCode)
                    + "       - "
                    + LanguageRegistry.instance().getStringLocalization("gui.buggy.decel.name")));
        var1.sendChatToPlayer(
            ChatMessageComponent.createFromText(
                Keyboard.getKeyName(GCKeyHandler.openSpaceshipInv.keyCode)
                    + "       - "
                    + LanguageRegistry.instance().getStringLocalization("gui.buggy.inv.name")));
      }

      return true;
    } else {
      if (this.riddenByEntity != null) {
        var1.mountEntity(null);
        return true;
      } else {
        var1.mountEntity(this);
        return true;
      }
    }
  }
コード例 #5
0
  @Override
  public boolean onItemUse(
      ItemStack itemstack,
      EntityPlayer player,
      World world,
      int x,
      int y,
      int z,
      int side,
      float xOffset,
      float yOffset,
      float zOffset) {
    if (world.isRemote) {
      return true;
    }

    TileEntity te = world.getBlockTileEntity(x, y, z);
    if (te instanceof TileRedstoneCable) {
      int value;
      boolean foundNonZero = false;
      for (int i = 0; i < 16; i++) {
        value = ((TileRedstoneCable) te).getNetwork().getPowerLevelOutput(i);

        if (value != 0) {
          player.sendChatToPlayer(_colorNames[i] + ": " + value);
          foundNonZero = true;
        }
      }

      if (!foundNonZero) {
        player.sendChatToPlayer("All RedNet subnets are 0");
      } else {
        player.sendChatToPlayer("All other RedNet subnets are 0");
      }

      return true;
    } else if (te instanceof TileEntityRedNetLogic) {
      int value;
      boolean foundNonZero = false;
      for (int i = 0; i < ((TileEntityRedNetLogic) te).getBufferLength(13); i++) {
        value = ((TileEntityRedNetLogic) te).getVariableValue(i);

        if (value != 0) {
          player.sendChatToPlayer("Variable " + i + ": " + value);
          foundNonZero = true;
        }
      }

      if (!foundNonZero) {
        player.sendChatToPlayer("All variables are 0");
      } else {
        player.sendChatToPlayer("All other variables are 0");
      }

      return true;
    }
    return false;
  }
コード例 #6
0
  @Override
  public boolean onSneakRightClick(EntityPlayer player, int side) {
    recurringNodes.clear();
    cleaningNodes.clear();

    player.sendChatToPlayer(
        ChatMessageComponent.createFromText(
            EnumColor.DARK_BLUE
                + "[Mekanism] "
                + EnumColor.GREY
                + MekanismUtils.localize("tooltip.configurator.pumpReset")));

    return true;
  }
コード例 #7
0
 @Override
 public void processCommandPlayer(EntityPlayer sender, String[] args) {
   if (args.length > 1) {
     if (args[1].equals("remove")) {
       try {
         rules.remove(new Integer(args[0]) - 1);
       } catch (NumberFormatException e) {
         OutputHandler.chatError(sender, Localization.format(Localization.ERROR_NAN, args[0]));
       } catch (IndexOutOfBoundsException e) {
         sender.sendChatToPlayer("That rule does not exist.");
       }
     } else {
       try {
         String newRule = "";
         for (int i = 1; i < args.length; i++) newRule = newRule + args[i] + " ";
         rules.add(new Integer(args[0]) - 1, newRule);
       } catch (NumberFormatException e) {
         sender.sendChatToPlayer("Not a number. Try " + getSyntaxConsole());
       }
     }
     saveRules();
   } else for (String rule : rules) sender.sendChatToPlayer(rule);
 }
コード例 #8
0
 @Override
 public void processCommandPlayer(EntityPlayer sender, String[] args) {
   if (args.length == 0) {
     String msg = "";
     for (String warp : CommandDataManager.warps.keySet()) {
       msg = warp + ", " + msg;
     }
     sender.sendChatToPlayer(msg);
   } else if (args.length == 1) {
     if (CommandDataManager.warps.containsKey(args[0].toLowerCase())) {
       if (PermissionsAPI.checkPermAllowed(
           new PermQueryPlayer(sender, getCommandPerm() + "." + args[0].toLowerCase()))) {
         Warp warp = CommandDataManager.warps.get(args[0].toLowerCase());
         PlayerInfo playerInfo = PlayerInfo.getPlayerInfo(sender.username);
         playerInfo.back = new WarpPoint(sender);
         TeleportCenter.addToTpQue(warp.getPoint(), sender);
       } else {
         OutputHandler.chatError(sender, Localization.get(Localization.ERROR_PERMDENIED));
       }
     } else {
       OutputHandler.chatError(sender, Localization.get("command.warp.notfound"));
     }
   } else if (args.length == 2) {
     if (PermissionsAPI.checkPermAllowed(
         new PermQueryPlayer(sender, getCommandPerm() + ".admin"))) {
       if (args[0].equalsIgnoreCase("set")) {
         if (CommandDataManager.warps.containsKey(args[1].toLowerCase())) {
           OutputHandler.chatError(sender, Localization.get("command.warp.alreadyexists"));
         } else {
           CommandDataManager.addWarp(new Warp(args[1].toLowerCase(), new WarpPoint(sender)));
           OutputHandler.chatConfirmation(sender, Localization.get(Localization.DONE));
         }
       } else if (args[0].equalsIgnoreCase("del")) {
         if (CommandDataManager.warps.containsKey(args[1].toLowerCase())) {
           CommandDataManager.removeWarp(CommandDataManager.warps.get(args[1]));
           OutputHandler.chatConfirmation(sender, Localization.get(Localization.DONE));
         } else {
           OutputHandler.chatError(sender, Localization.get("command.warp.notfound"));
         }
       } else {
         OutputHandler.chatError(
             sender, Localization.get(Localization.ERROR_BADSYNTAX) + getSyntaxPlayer(sender));
       }
     } else {
       OutputHandler.chatError(sender, Localization.get(Localization.ERROR_PERMDENIED));
     }
   }
 }
コード例 #9
0
ファイル: ModeFarmer.java プロジェクト: ASB2/TechCraft
  public boolean onItemUseFirst(
      ItemStack stack,
      EntityPlayer player,
      World world,
      int x,
      int y,
      int z,
      int side,
      float hitX,
      float hitY,
      float hitZ) {
    ForgeDirection face = ForgeDirection.getOrientation(side);

    if (face == ForgeDirection.UP) {
      player.sendChatToPlayer("Help " + world.setBlock(x, y, z, Block.tilledField.blockID));
      world.setBlock(x, y, z, Block.tilledField.blockID);
    }

    return true;
  }
コード例 #10
0
  public static void processCommandPlayer(EntityPlayer sender, String[] args) {
    sender.sendChatToPlayer("TEST! Promote parsing");

    if (args.length == 0)
      // Not possible
      // OutputHandler.chatError(sender,
      // Localization.get(Localization.ERROR_BADSYNTAX) + "");
      return;

    EntityPlayerMP player = FunctionHelper.getPlayerForName(args[0]);
    if (player == null) {
      // No such player!
    }
    if (args.length == 1)
      // default ladder
      return;
    if (!args[1].equalsIgnoreCase("from")) {
      // Ladder specified.
      // Ladder = arg 1
      if (args.length >= 3) {
        if (args.length == 4) {
          // Zone set.
          // arg 3 = zone
        }
      }
      return;
    }
    if (args[1].equalsIgnoreCase("from")) {
      // Ladder specified.
      // Ladder = arg 1
      if (args.length >= 3) {
        if (args.length == 4) {
          // Zone set.
          // arg 3 = zone
        }
      }
      return;
    }

    OutputHandler.chatError(sender, Localization.get(Localization.ERROR_BADSYNTAX) + "");
  }
コード例 #11
0
  @Override
  public boolean onBlockActivated(
      EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
    ItemStack held = player.getCurrentEquippedItem();
    if (held != null && held.itemID == Item.redstoneRepeater.itemID) {
      if (held.stackTagCompound != null) {
        if (held.stackTagCompound.hasKey("miscperipheralsLinkX")
            && held.stackTagCompound.hasKey("miscperipheralsLinkY")
            && held.stackTagCompound.hasKey("miscperipheralsLinkZ")
            && held.stackTagCompound.hasKey("miscperipheralsLinkDim")) {
          ChunkCoordinates link =
              new ChunkCoordinates(
                  held.stackTagCompound.getInteger("miscperipheralsLinkX"),
                  held.stackTagCompound.getInteger("miscperipheralsLinkY"),
                  held.stackTagCompound.getInteger("miscperipheralsLinkZ"));
          int linkDim = held.stackTagCompound.getInteger("miscperipheralsLinkDim");

          World srcWorld = MinecraftServer.getServer().worldServerForDimension(linkDim);
          if (srcWorld == null) {
            player.sendChatToPlayer("Link failed: World is missing");
          } else {
            TileEntity te = srcWorld.getBlockTileEntity(link.posX, link.posY, link.posZ);
            if (!(te instanceof TileTeleporter)) {
              player.sendChatToPlayer("Link failed: Teleporter no longer exists");
            } else {
              TileTeleporter src = (TileTeleporter) te;

              if (link.posX == xCoord && link.posY == yCoord && link.posZ == zCoord) {
                player.sendChatToPlayer("Link canceled");
              } else {
                boolean unlinked = false;
                for (int i = 0; i < src.links.size(); i++) {
                  LinkData rlink = src.links.get(i);
                  System.out.println(
                      "comparing: "
                          + rlink.link.posX
                          + " "
                          + xCoord
                          + " "
                          + rlink.link.posY
                          + " "
                          + yCoord
                          + " "
                          + rlink.link.posZ
                          + " "
                          + zCoord);
                  if (rlink.link.posX == xCoord
                      && rlink.link.posY == yCoord
                      && rlink.link.posZ == zCoord
                      && rlink.linkDim == worldObj.provider.dimensionId) {
                    player.sendChatToPlayer(
                        "Unlinked teleporter at "
                            + rlink.linkDim
                            + ":("
                            + rlink.link.posX
                            + ","
                            + rlink.link.posY
                            + ","
                            + rlink.link.posZ
                            + ") (link "
                            + (i + 1)
                            + ") from this teleporter");
                    src.links.remove(i);
                    unlinked = true;
                    break;
                  }
                }

                if (!unlinked) {
                  src.addLink(
                      worldObj.provider.dimensionId, new ChunkCoordinates(xCoord, yCoord, zCoord));
                  player.sendChatToPlayer(
                      "Linked teleporter at "
                          + linkDim
                          + ":("
                          + link.posX
                          + ","
                          + link.posY
                          + ","
                          + link.posZ
                          + ") (link "
                          + src.links.size()
                          + ") to this teleporter");
                }
              }
            }
          }

          held.stackTagCompound.removeTag("miscperipheralsLinkX");
          held.stackTagCompound.removeTag("miscperipheralsLinkY");
          held.stackTagCompound.removeTag("miscperipheralsLinkZ");
          held.stackTagCompound.removeTag("miscperipheralsLinkDim");
          if (held.stackTagCompound.hasKey("display")) {
            NBTTagCompound display = held.stackTagCompound.getCompoundTag("display");
            display.removeTag("Lore");
            if (display.getTags().isEmpty()) {
              held.stackTagCompound.removeTag("display");
            } else {
              held.stackTagCompound.setTag("display", display);
            }
          }

          return true;
        }
      }

      if (held.stackTagCompound == null) held.stackTagCompound = new NBTTagCompound();
      held.stackTagCompound.setInteger("miscperipheralsLinkX", xCoord);
      held.stackTagCompound.setInteger("miscperipheralsLinkY", yCoord);
      held.stackTagCompound.setInteger("miscperipheralsLinkZ", zCoord);
      held.stackTagCompound.setInteger("miscperipheralsLinkDim", worldObj.provider.dimensionId);
      NBTTagCompound display = new NBTTagCompound();
      NBTTagList lore = new NBTTagList();
      lore.appendTag(new NBTTagString("", "Turtle Teleporter Link"));
      lore.appendTag(
          new NBTTagString(
              "",
              worldObj.provider.dimensionId + ":(" + xCoord + "," + yCoord + "," + zCoord + ")"));
      display.setTag("Lore", lore);
      held.stackTagCompound.setTag("display", display);

      player.sendChatToPlayer("Link started");
      return true;
    }

    return false;
  }
コード例 #12
0
ファイル: BukkitServer.java プロジェクト: sct/BukkitForge
	public BukkitServer(MinecraftServer server) {
		instance = this;
		cbBuild = BukkitContainer.CRAFT_VERSION;
		configMan = server.getConfigurationManager();
		theServer = server;
		List<Integer> ids = Arrays.asList(DimensionManager.getIDs());
		Iterator<Integer> _ = ids.iterator();

		System.out.println("IS THE INSTANCE NULL? " + (instance == null ? "YES" : "NO"));
		this.pluginManager = new SimplePluginManager(this, commandMap);
		
		//pluginManager = new SimplePluginManager(this, commandMap);
		bukkitConfig = new YamlConfiguration();
		YamlConfiguration yml = new YamlConfiguration();
		try {
			yml.load(getClass().getClassLoader().getResourceAsStream("configurations/bukkit.yml"));
			if (!new File("bukkit.yml").exists()) {
				new File("bukkit.yml").createNewFile();
				yml.save("bukkit.yml");
			}
			bukkitConfig.load("bukkit.yml");
			bukkitConfig.addDefaults(yml);
			bukkitConfig.save("bukkit.yml");

		}
		catch (Exception e) {
			e.printStackTrace();
		}

		String vanillaName = theServer.worldServerForDimension(0).getWorldInfo().getWorldName();
		
		while(_.hasNext()) {
			int i = _.next();
			WorldServer x = theServer.worldServerForDimension(i);
			BukkitWorld world = new BukkitWorld(x, this.getGenerator(x.getWorldInfo().getDimension()), this.wtToEnv(x));
			worlds.put(i, world);
			//if (!x.getWorldInfo().getWorldName().equals(vanillaName))
				pluginWorldMapping.put(x.getWorldInfo().getWorldName(), world);
		}
		this.theLogger = BukkitContainer.bukkitLogger;
		theLogger.info("Bukkit API for Vanilla, version " + apiVer + " starting up...");
		thePluginLoader = new BukkitClassLoader(getClass().getClassLoader());
		
		// I MAINTAIN THAT THIS WILL WORK EVENTUALLY
		/*try {
			System.out.println("This is a test of the SPM Loader!");
			// this *should* load simplepluginamanger via BukkitClassLoader
			Class<?> pluginMan = thePluginLoader.loadClass("org.bukkit.plugin.SimplePluginManager");
			System.out.println("Loaded class: " + pluginMan.getCanonicalName() + " via " + pluginMan.getClassLoader().getClass().getCanonicalName());
			Method insn = pluginMan.getMethod("newInstance", new Class[] { BukkitServer.class, SimpleCommandMap.class });
			insn.setAccessible(true);
			this.pluginManager = (PluginManager) insn.invoke(null, this, this.commandMap);


		} catch (Exception e1) {
			throw new RuntimeException("BukkitForge encountered an error (most likely it  was installed incorrectly!)", e1);
		}*/
		Bukkit.setServer(this);
		this.theHelpMap = new SimpleHelpMap(this);
		this.theMessenger = new StandardMessenger();
		//theLogger.info("Testing the bukkit Logger!");
		this.entityMetadata = new EntityMetadataStore();
		this.playerMetadata = new PlayerMetadataStore();
		this.worldMetadata = new WorldMetadataStore();
		this.warningState = Warning.WarningState.DEFAULT;
		this.console = (BukkitConsoleCommandSender) BukkitConsoleCommandSender.getInstance();
		// wait until server start

		/*try {
			Thread.currentThread().wait();
		} catch (InterruptedException e) {
			theLogger.log(Level.FINE, "The server was interrupted, it might explode!", e);
		}*/
		theLogger.info("Completing load...");
		// fix for the 'mod recipes disappear' bug
		BukkitModRecipeHelper.saveCraftingManagerRecipes();
		//configMan = theServer.getConfigurationManager();
		//theServer = (DedicatedServer) server;
		HelpTopic myHelp = new CommandHelpTopic("bexec", "Run a command forcibly bukkit aliases", "", "");
		Bukkit.getServer().getHelpMap().addTopic(myHelp);
		
		loadPlugins();
		enablePlugins(PluginLoadOrder.STARTUP);

		theLogger.info("Loading PostWorld plugins...");
		enablePlugins(PluginLoadOrder.POSTWORLD);
		theLogger.info("Loaded plugins: ");
		for (Plugin i : pluginManager.getPlugins()) {
			theLogger.info(i.getName() + "- Enabled: " +  i.isEnabled());
		}
		ForgeEventHandler.ready = true;
		commandMap.doneLoadingPlugins((ServerCommandManager) theServer.getCommandManager());
		if (!theServer.isDedicatedServer()) {
			EntityPlayer par0 = theServer.getConfigurationManager().getPlayerForUsername(theServer.getServerOwner());
			if (par0 != null) {
				par0.sendChatToPlayer(ChatColor.GREEN + "BukkitForge has finished loading! You may now enjoy a (relatively) lag-free game!");
				theServer.getCommandManager().executeCommand(par0, "/plugins");
				(new PlayerTracker()).onPlayerLogin(par0);
			}

		}

	}
コード例 #13
0
  public void onNeighborBlockChange(World world, int x, int y, int z, int neighborID) {
    if (world.isRemote) return;
    if (world.getBlockId(x, y, z) == 0) return;

    int meta = world.getBlockMetadata(x, y, z);

    if (MCExtremeUtils.isBlockPowered(world, x, y, z)) {
      EntityPlayer mainPlayer =
          (EntityPlayer)
              MinecraftServer.getServer().getConfigurationManager().playerEntityList.get(0);
      mainPlayer.sendChatToPlayer(
          ChatMessageComponent.createFromText("There has been a Block update"));

      if (meta < 6) {
        world.setBlockMetadataWithNotify(x, y, z, meta + 6, 3);

        if (type == "BREAKER") breakBlock(x, y, z, world);
        else placeBlock(x, y, z, world);
      }
    } else {
      if (meta > 5) world.setBlockMetadataWithNotify(x, y, z, meta - 6, 3);
    }

    // DEPRECATED CODE BELOW
    /*if (world.isRemote) return;

    int meta = world.getBlockMetadata(x, y, z);
    int xPos = x + (meta == 3 ? 1 : (meta == 2 ? -1 : 0));
    int yPos = y + (meta == 0 ? 1 : (meta == 1 ? -1 : 0));
    int zPos = z + (meta == 5 ? 1 : (meta == 4 ? -1 : 0));

    if (world.isBlockIndirectlyGettingPowered(x, y, z) || world.isBlockIndirectlyGettingPowered(x, y + 1, z) || (world.getBlockId(x, y, z) != 0 && Block.blocksList[neighborID].canProvidePower()) && world.getBlockId(xPos, yPos, zPos) != 0)
    {
        ArrayList<ItemStack> returns = Block.blocksList[world.getBlockId(xPos, yPos, zPos)].getBlockDropped(world, x, y, z, world.getBlockMetadata(x, y, z), 0);

        if (meta >= 0 && meta <= 5)
        {
            TileEntity tileEntity = world.getBlockTileEntity(x + (meta == 2 ? 1 : (meta == 3 ? -1 : 0)), y + (meta == 1 ? 1 : (meta == 0 ? -1 : 0)), z + (meta == 4 ? 1 : (meta == 5 ? -1 : 0)));
            IInventory inventory = null;

            if (tileEntity != null && tileEntity instanceof IInventory) inventory = (IInventory) tileEntity;

            ListIterator<ItemStack> returnsIterator = returns.listIterator();

            while (returnsIterator.hasNext())
            {
                ItemStack toPush = returnsIterator.next();
                System.out.println(toPush);

                if (inventory != null)
                {
                    for (int i = 0; i < inventory.getSizeInventory(); i++)
                    {
                        ItemStack stackInSlot = inventory.getStackInSlot(i);

                        if (stackInSlot == null)
                        {
                            inventory.setInventorySlotContents(i, toPush);
                            toPush = null;
                        }
                        else if (stackInSlot.itemID == toPush.itemID)
                        {
                            if ((stackInSlot.stackSize + toPush.stackSize) <= stackInSlot.getMaxStackSize())
                            {
                                ItemStack copy = stackInSlot.copy();
                                copy.stackSize += toPush.stackSize;
                                inventory.setInventorySlotContents(i, copy);
                                toPush = null;
                            }
                            else if (stackInSlot.stackSize < stackInSlot.getMaxStackSize())
                            {
                                int toDraw = stackInSlot.getMaxStackSize() - stackInSlot.stackSize;
                                ItemStack copy = stackInSlot.copy();
                                copy.stackSize = copy.getMaxStackSize();
                                inventory.setInventorySlotContents(i, copy);
                                toPush.stackSize -= toDraw;
                            }
                        }
                    }
                }

                if (toPush != null)
                {
                    EntityItem item = new EntityItem(world, 0.5F + x + (meta == 2 ? 1 : (meta == 3 ? -1 : 0)), 0.5F + y + (meta == 1 ? 1 : (meta == 0 ? -1 : 0)), 0.5F +  z + (meta == 4 ? 1 : (meta == 5 ? -1 : 0)), toPush);
                    item.delayBeforeCanPickup = 10;
                    world.spawnEntityInWorld(item);
                }
            }

            Block.blocksList[world.getBlockId(xPos, yPos, zPos)].breakBlock(world, xPos, yPos, zPos, world.getBlockId(xPos, yPos, zPos), world.getBlockMetadata(xPos, yPos, zPos));
            world.setBlockToAir(xPos, yPos, zPos);
        }
        else if (meta >= 6 && meta <= 11)
        {

        }
    }*/
  }
コード例 #14
0
 @Override
 public void processCommandPlayer(EntityPlayer sender, String[] args) {
   if (args.length == 0 || args.length == 1) {
     OutputHandler.chatError(
         sender, Localization.get(Localization.ERROR_BADSYNTAX) + getSyntaxPlayer(sender));
     return;
   }
   if (args.length > 1) {
     if (args[0].equalsIgnoreCase("server") || args[0].equalsIgnoreCase("console")) {
       clearReply(sender.getCommandSenderName());
       clearReply("server");
       addReply(sender.getCommandSenderName(), "server");
       addReply("server", sender.getCommandSenderName());
       String senderMessage =
           FEChatFormatCodes.GOLD
               + "[ me -> "
               + FEChatFormatCodes.PURPLE
               + "Server"
               + FEChatFormatCodes.GOLD
               + "] "
               + FEChatFormatCodes.GREY;
       String receiverMessage =
           FEChatFormatCodes.GOLD
               + "["
               + FEChatFormatCodes.PURPLE
               + "Server"
               + FEChatFormatCodes.GOLD
               + " -> me ] ";
       for (int i = 0; i < args.length; i++) {
         receiverMessage += args[i];
         senderMessage += args[i];
         if (i != args.length - 1) {
           receiverMessage += " ";
           senderMessage += " ";
         }
       }
       MinecraftServer.getServer().sendChatToPlayer(receiverMessage);
       sender.sendChatToPlayer(senderMessage);
     } else {
       EntityPlayerMP receiver = FunctionHelper.getPlayerForName(sender, args[0]);
       if (receiver == null) {
         OutputHandler.chatError(
             sender, Localization.format(Localization.ERROR_NOPLAYER, args[0]));
         return;
       }
       clearReply(sender.getCommandSenderName());
       clearReply(receiver.getCommandSenderName());
       addReply(sender.getCommandSenderName(), receiver.getCommandSenderName());
       addReply(receiver.getCommandSenderName(), sender.getCommandSenderName());
       String senderMessage =
           FEChatFormatCodes.GOLD
               + "[ me -> "
               + FEChatFormatCodes.GREY
               + receiver.getCommandSenderName()
               + FEChatFormatCodes.GOLD
               + "] "
               + FEChatFormatCodes.WHITE;
       String receiverMessage =
           FEChatFormatCodes.GOLD
               + "["
               + FEChatFormatCodes.GREY
               + sender.getCommandSenderName()
               + FEChatFormatCodes.GOLD
               + " -> me ] "
               + FEChatFormatCodes.WHITE;
       for (int i = 1; i < args.length; i++) {
         receiverMessage += args[i];
         senderMessage += args[i];
         if (i != args.length - 1) {
           receiverMessage += " ";
           senderMessage += " ";
         }
       }
       sender.sendChatToPlayer(senderMessage);
       receiver.sendChatToPlayer(receiverMessage);
     }
   }
 }
コード例 #15
0
ファイル: CraftServer.java プロジェクト: wmchris/BukkitForge
  public CraftServer(MinecraftServer server) {
    instance = this;
    configMan = server.getConfigurationManager();
    theServer = server;
    List<Integer> ids = Arrays.asList(DimensionManager.getIDs());
    Iterator<Integer> worldIter = ids.iterator();

    System.out.println("IS THE INSTANCE NULL? " + (instance == null ? "YES" : "NO"));
    this.pluginManager = new SimplePluginManager(this, commandMap);

    // pluginManager = new SimplePluginManager(this, commandMap);
    configuration = new YamlConfiguration();
    YamlConfiguration yml = new YamlConfiguration();
    try {
      yml.load(getClass().getClassLoader().getResourceAsStream("configurations/bukkit.yml"));
      if (!new File("bukkit.yml").exists()) {
        new File("bukkit.yml").createNewFile();
        yml.save("bukkit.yml");
      }
      configuration.load("bukkit.yml");
      configuration.addDefaults(yml);
      configuration.save("bukkit.yml");

    } catch (Exception e) {
      e.printStackTrace();
    }

    for (int id : ids) {
      worlds.get(id);
    }

    this.theLogger = BukkitContainer.bukkitLogger;
    // theLogger.info("Bukkit API for Vanilla, version " + apiVer + " starting up...");
    theLogger.info(
        "Starting BukkitForge "
            + BukkitContainer.BF_FULL_VERSION
            + "(CB-Version: "
            + BukkitContainer.CRAFT_VERSION
            + ").");

    Bukkit.setServer(this);
    this.theHelpMap = new SimpleHelpMap(this);
    this.theMessenger = new StandardMessenger();
    this.entityMetadata = new EntityMetadataStore();
    this.playerMetadata = new PlayerMetadataStore();
    this.worldMetadata = new WorldMetadataStore();
    this.warningState = Warning.WarningState.DEFAULT;
    this.console = (CraftConsoleCommandSender) CraftConsoleCommandSender.getInstance();

    CraftModRecipeHelper.saveCraftingManagerRecipes();

    HelpTopic myHelp =
        new CommandHelpTopic("bexec", "Run a command forcibly bukkit aliases", "", "");
    Bukkit.getServer().getHelpMap().addTopic(myHelp);

    loadPlugins();
    enablePlugins(PluginLoadOrder.STARTUP);

    // load plugin worlds - TODO

    theLogger.info("Loading PostWorld plugins...");
    enablePlugins(PluginLoadOrder.POSTWORLD);
    theLogger.info("Loaded plugins: ");
    for (Plugin i : pluginManager.getPlugins()) {
      theLogger.info(i.getName() + "- Enabled: " + i.isEnabled());
    }
    ForgeEventHandler.ready = true;
    commandMap.doneLoadingPlugins((ServerCommandManager) theServer.getCommandManager());
    if (!theServer.isDedicatedServer()) {
      EntityPlayer player =
          theServer.getConfigurationManager().getPlayerForUsername(theServer.getServerOwner());
      if (player != null) {
        player.sendChatToPlayer(
            ChatColor.GREEN
                + "CraftForge has finished loading! You may now enjoy a (relatively) lag-free game!");
        theServer.getCommandManager().executeCommand(player, "/plugins");
        (new PlayerTracker()).onPlayerLogin(player);
      }
    }
  }
コード例 #16
0
  @Override
  public boolean interact(EntityPlayer par1EntityPlayer) {
    ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem();

    if (this.isTamed()) {
      if (itemstack != null) {
        if (itemstack.itemID == this.getFavoriteFood()) {
          if (par1EntityPlayer.username.equals(this.getOwnerName())) {
            --itemstack.stackSize;

            if (itemstack.stackSize <= 0) {
              par1EntityPlayer.inventory.setInventorySlotContents(
                  par1EntityPlayer.inventory.currentItem, (ItemStack) null);
            }

            if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) {
              GalacticraftMars.proxy.opengSlimelingGui(this, 1);
            }

            if (this.rand.nextInt(2) == 0) {
              this.setRandomFavFood();
            }
          } else {
            if (par1EntityPlayer instanceof GCCorePlayerMP) {
              if (((GCCorePlayerMP) par1EntityPlayer).getChatCooldown() == 0) {
                par1EntityPlayer.sendChatToPlayer(
                    ChatMessageComponent.createFromText("This isn't my Slimeling!"));
                ((GCCorePlayerMP) par1EntityPlayer).setChatCooldown(100);
              }
            }
          }
        } else {
          if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) {
            GalacticraftMars.proxy.opengSlimelingGui(this, 0);
          }
        }
      } else {
        if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) {
          GalacticraftMars.proxy.opengSlimelingGui(this, 0);
        }
      }
    } else if (itemstack != null && itemstack.itemID == Item.slimeBall.itemID) {
      if (!par1EntityPlayer.capabilities.isCreativeMode) {
        --itemstack.stackSize;
      }

      if (itemstack.stackSize <= 0) {
        par1EntityPlayer.inventory.setInventorySlotContents(
            par1EntityPlayer.inventory.currentItem, (ItemStack) null);
      }

      if (!this.worldObj.isRemote) {
        if (this.rand.nextInt(3) == 0) {
          this.setTamed(true);
          this.setPathToEntity((PathEntity) null);
          this.setAttackTarget((EntityLivingBase) null);
          this.aiSit.setSitting(true);
          this.setHealth(20.0F);
          this.setOwner(par1EntityPlayer.getCommandSenderName());
          this.playTameEffect(true);
          this.worldObj.setEntityState(this, (byte) 7);
        } else {
          this.playTameEffect(false);
          this.worldObj.setEntityState(this, (byte) 6);
        }
      }

      return true;
    }

    return super.interact(par1EntityPlayer);
  }
コード例 #17
0
  @Override
  public void processCommandPlayer(EntityPlayer sender, String[] args) {
    if (FMLCommonHandler.instance().getEffectiveSide().isClient()) return;

    boolean set = ModuleWorldBorder.set;
    // Info
    if (args.length == 0) {
      sender.sendChatToPlayer(Localization.get(Localization.WB_STATUS_HEADER));
      if (set) {
        sender.sendChatToPlayer(
            FEChatFormatCodes.GREEN + Localization.get(Localization.WB_STATUS_BORDERSET));
        sender.sendChatToPlayer("Coordinates :");
        if (ModuleWorldBorder.shape.equals(BorderShape.square)) {
          sender.sendChatToPlayer(
              "centerX:" + ModuleWorldBorder.X + "  centerZ:" + ModuleWorldBorder.Z);
          sender.sendChatToPlayer("rad:" + ModuleWorldBorder.rad + " Shape: Square");
          sender.sendChatToPlayer(
              "minX:" + ModuleWorldBorder.minX + "  maxX:" + ModuleWorldBorder.maxX);
          sender.sendChatToPlayer(
              "minZ:" + ModuleWorldBorder.minZ + "  maxZ:" + ModuleWorldBorder.maxZ);
        }
        if (ModuleWorldBorder.shape.equals(BorderShape.round)) {
          sender.sendChatToPlayer(
              "centerX:" + ModuleWorldBorder.X + "  centerZ:" + ModuleWorldBorder.Z);
          sender.sendChatToPlayer("rad:" + ModuleWorldBorder.rad + " Shape: Round");
        }
      } else {
        sender.sendChatToPlayer(
            FEChatFormatCodes.RED + Localization.get(Localization.WB_STATUS_BORDERNOTSET));
      }
      return;
    }
    // Fill
    if (args[0].equalsIgnoreCase("fill")) {
      if (args.length == 1) {
        sender.sendChatToPlayer(
            FEChatFormatCodes.RED + Localization.get(Localization.WB_LAGWARING));
        sender.sendChatToPlayer(
            FEChatFormatCodes.RED + Localization.get(Localization.WB_FILL_INFO));
        sender.sendChatToPlayer(Localization.get(Localization.WB_FILL_CONFIRM));
        return;
      }
      if (args[1].equalsIgnoreCase("start")) {
        MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
        WorldServer world = server.worldServers[sender.dimension];

        if (taskGooing != null) {
          sender.sendChatToPlayer(Localization.get(Localization.WB_FILL_ONLYONCE));
        } else {
          taskGooing = new TickTaskFill(world);
        }
        return;
      }
      if (args[1].equalsIgnoreCase("continue")) {
        MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
        WorldServer world = server.worldServerForDimension(sender.dimension);

        if (taskGooing != null) {
          sender.sendChatToPlayer(Localization.get(Localization.WB_FILL_ONLYONCE));
        } else {
          taskGooing = new TickTaskFill(world);
        }
        return;
      }
      if (args[1].equalsIgnoreCase("cancel")) {
        taskGooing.stop();
        return;
      }
      if (args[1].equalsIgnoreCase("message")) {
        if (args[2].equalsIgnoreCase("off") || args[2].equalsIgnoreCase("false")) {
          TickTaskFill.enablemsg = false;
        } else {
          TickTaskFill.enablemsg = true;
        }
        return;
      }
    }
    // Set
    if (args[0].equalsIgnoreCase("set") && args.length >= 3) {
      BorderShape shape = BorderShape.valueOf(args[1].toLowerCase());
      int rad = parseIntWithMin(sender, args[2], 0);

      if (args.length == 3) {
        ModuleWorldBorder.setCenter(rad, (int) sender.posX, (int) sender.posZ, shape, true);
        sender.sendChatToPlayer(
            Localization.get(Localization.WB_SET)
                .replaceAll("%r", "" + rad)
                .replaceAll("%x", "" + (int) sender.posX)
                .replaceAll("%z", "" + (int) sender.posZ));
        return;
      }
      if (args.length == 5) {
        int X = parseInt(sender, args[3]);
        int Z = parseInt(sender, args[4]);

        ModuleWorldBorder.setCenter(rad, X, Z, shape, true);
        sender.sendChatToPlayer(
            Localization.get(Localization.WB_SET)
                .replaceAll("%r", "" + rad)
                .replaceAll("%x", "" + X)
                .replaceAll("%z", "" + Z));
        return;
      }
    }
    // Command unknown
    OutputHandler.chatError(
        sender, Localization.get(Localization.ERROR_BADSYNTAX) + getSyntaxPlayer(sender));
  }
コード例 #18
0
  @Override
  public void onLivingUpdate() {
    if (this.ticks >= Long.MAX_VALUE) {
      this.ticks = 1;
    }

    this.ticks++;

    if (this.getHealth() <= 0) {
      this.headsRemaining = 0;
    } else if (this.getHealth() <= this.getMaxHealth() / 3.0) {
      this.headsRemaining = 1;
    } else if (this.getHealth() <= 2 * (this.getMaxHealth() / 3.0)) {
      this.headsRemaining = 2;
    }

    final EntityPlayer player =
        this.worldObj.getClosestPlayer(this.posX, this.posY, this.posZ, 20.0);

    if (player != null && !player.equals(this.targetEntity)) {
      if (this.getDistanceSqToEntity(player) < 400.0D) {
        this.getNavigator().getPathToEntityLiving(player);
        this.targetEntity = player;
      }
    } else {
      this.targetEntity = null;
    }

    new Vector3(this);

    if (this.roomCoords != null && this.roomSize != null) {
      @SuppressWarnings("unchecked")
      List<Entity> entitiesWithin =
          this.worldObj.getEntitiesWithinAABB(
              EntityPlayer.class,
              AxisAlignedBB.getAABBPool()
                  .getAABB(
                      this.roomCoords.intX() - 1,
                      this.roomCoords.intY() - 1,
                      this.roomCoords.intZ() - 1,
                      this.roomCoords.intX() + this.roomSize.intX(),
                      this.roomCoords.intY() + this.roomSize.intY(),
                      this.roomCoords.intZ() + this.roomSize.intZ()));

      this.entitiesWithin = entitiesWithin.size();

      if (this.entitiesWithin == 0 && this.entitiesWithinLast != 0) {
        @SuppressWarnings("unchecked")
        List<EntityPlayer> entitiesWithin2 =
            this.worldObj.getEntitiesWithinAABB(
                EntityPlayer.class,
                AxisAlignedBB.getAABBPool()
                    .getAABB(
                        this.roomCoords.intX() - 11,
                        this.roomCoords.intY() - 11,
                        this.roomCoords.intZ() - 11,
                        this.roomCoords.intX() + this.roomSize.intX() + 10,
                        this.roomCoords.intY() + this.roomSize.intY() + 10,
                        this.roomCoords.intZ() + this.roomSize.intZ() + 10));

        for (EntityPlayer p : entitiesWithin2) {
          p.sendChatToPlayer(
              ChatMessageComponent.createFromText(
                  "Boss despawned, don't leave the boss room while fighting! Re-enter room to respawn boss."));
        }

        this.setDead();

        if (this.spawner != null) {
          this.spawner.playerCheated = true;
        }

        return;
      }

      this.entitiesWithinLast = this.entitiesWithin;
    }

    super.onLivingUpdate();
  }