@Override public void registerHandlers() { OreDicHandler.registerWildCards(); MaricultureHandlers.biomeType = new BiomeTypeHandler(); MaricultureHandlers.smelter = new LiquifierHandler(); MaricultureHandlers.casting = new IngotCastingHandler(); MaricultureHandlers.vat = new VatHandler(); MaricultureHandlers.anvil = new TileAnvil(); MaricultureHandlers.upgrades = new UpgradeHandler(); MaricultureHandlers.modules = new ModulesHandler(); GameRegistry.registerFuelHandler(new FuelHandler()); GameRegistry.registerWorldGenerator(new WorldGenHandler(), 1); MinecraftForge.EVENT_BUS.register(new GuiItemToolTip()); MinecraftForge.EVENT_BUS.register(new OreDicHandler()); FMLCommonHandler.instance().bus().register(new ServerFMLEvents()); FMLCommonHandler.instance().bus().register(new ClientFMLEvents()); if (RetroGeneration.ENABLED) MinecraftForge.EVENT_BUS.register(new RetroGen()); // Initalise our Side Helper List<Integer> sides = new ArrayList<Integer>(); for (int i = 0; i < 6; i++) { sides.add(i); } BlockTransferHelper.sides = sides; }
public static void create() { boolean register = false; if (FMLCommonHandler.instance().getSide() == Side.CLIENT) { register = hasOptifine = FMLClientHandler.instance().hasOptifine(); } for (ModContainer modContainer : ModAPIManager.INSTANCE.getAPIList()) { if ("appliedenergistics2|API".equals(modContainer.getModId())) { if ("rv1".equals(modContainer.getVersion())) { hasOldAE2 = modContainer.getVersion() + " from " + modContainer.getSource().getName(); register = true; } else if (!"rv2".equals(modContainer.getVersion())) { hasUnknownAE2 = modContainer.getVersion() + " from " + modContainer.getSource().getName(); register = true; } } else if ("CoFHAPI|energy".equals(modContainer.getModId())) { if ("1.7.10R1.0.0".equals(modContainer.getVersion()) || "1.7.10R1.0.1".equals(modContainer.getVersion())) { hasOldRF = modContainer.getVersion() + " from " + modContainer.getSource().getName(); register = true; } } } if (register) { FMLCommonHandler.instance().registerCrashCallable(new EnderIOCrashCallable()); } }
@EventHandler public void preInit(FMLPreInitializationEvent event) { config = new Configuration(event.getSuggestedConfigurationFile()); // gets default config file this.instance = this; FMLCommonHandler.instance().bus().register(worldgen); MinecraftForge.EVENT_BUS.register(worldgen); FMLCommonHandler.instance().bus().register(versionChecker); MinecraftForge.EVENT_BUS.register(versionChecker); FMLCommonHandler.instance().bus().register(this); MinecraftForge.EVENT_BUS.register(this); ClientCommandHandler.instance.registerCommand(new VersionCommand()); fluids.setupFluids(); fluids.setupFluidBlocks(); items.setupItems(); items.registerItems(); items.registerItemsOreDict(); blocks.setupBlocks(); blocks.registerBlocks(); blocks.registerBlocksOreDict(); blocks.setupHarvestLevels(); recipes.setupShapelessCrafting(); recipes.setupShapedCrafting(); recipes.setupSmelting(); worldgen.setupWorldgen(); mobs.setupMobs(); proxy.registerRenderers(); }
/** * Performs the thirst changes for the specified player * * @param username player to handle */ private void handleThirst(String username) { int playerThirst = thirstMap.get(username); EntityPlayer player = mc.thePlayer; if (player == null || player.isDead || player.capabilities.isCreativeMode) { return; } else if (playerThirst == 20000) { if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) { ChatHandler.chatWarning(player, "I should find some water..."); } playerThirst++; } else if (playerThirst == 18000) { if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) { ChatHandler.chatWarning(player, "I feel quite thirsty now..."); } playerThirst++; } else if (playerThirst == 16000) { if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) { ChatHandler.chatWarning(player, "My mouth feels a little dry..."); } playerThirst++; } else if (playerThirst >= 24000 && FMLCommonHandler.instance().getMinecraftServerInstance().getTickCounter() % 40 == 0) { player.attackEntityFrom(DamageType.thirstDeath, 1); } else if (player.isSprinting() || player.isAirBorne) { playerThirst = playerThirst + 2; } else { playerThirst++; } ChatHandler.logDebug(String.valueOf(playerThirst)); thirstMap.put(username, playerThirst); }
@EventHandler public void init(FMLInitializationEvent event) { PacketDispatcher.registerPackets(); proxy.init(event); GameRegistry.addShapelessRecipe(new ItemStack(itemEmptyAtlas), Items.book, Items.compass); RecipeSorter.register( "antiqueatlas:atlascloning", RecipeAtlasCloning.class, SHAPELESS, "after:minecraft:shapeless"); GameRegistry.addRecipe(new RecipeAtlasCloning()); RecipeSorter.register( "antiqueatlas:atlascombining", RecipeAtlasCombining.class, SHAPELESS, "after:minecraft:shapeless"); RecipeAtlasCombining recipeCombining = new RecipeAtlasCombining(); GameRegistry.addRecipe(recipeCombining); FMLCommonHandler.instance().bus().register(recipeCombining); MinecraftForge.EVENT_BUS.register(extBiomeData); FMLCommonHandler.instance().bus().register(extBiomeData); MinecraftForge.EVENT_BUS.register(globalMarkersData); FMLCommonHandler.instance().bus().register(globalMarkersData); MinecraftForge.EVENT_BUS.register(new DeathWatcher()); MinecraftForge.EVENT_BUS.register(new VillageWatcher()); MinecraftForge.EVENT_BUS.register(new NetherFortressWatcher()); MinecraftForge.EVENT_BUS.register(new NetherPortalWatcher()); }
private void sendPacketToClients() { int id = 0; int meta = 0; int enc = 0; if (inv[0] != null) { id = inv[0].itemID; meta = inv[0].getItemDamage(); enc = inv[0].isItemEnchanted() ? 1 : 0; } int id2 = 0; int meta2 = 0; if (inv[1] != null) { id2 = inv[1].itemID; meta2 = inv[1].getItemDamage(); } if (!worldObj.isRemote || FMLCommonHandler.instance().getSide().isServer()) { try { Packet packet = PacketManagerMF.getPacketIntegerArray( this, new int[] {direction, id, meta, id2, meta2, enc, progBar}); FMLCommonHandler.instance() .getMinecraftServerInstance() .getConfigurationManager() .sendPacketToAllPlayers(packet); } catch (NullPointerException e) { System.out.println("MineFantasy: Client connections lost"); } } }
/** Loads and returns the world info */ public WorldInfo loadWorldInfo() { File var1 = new File(this.worldDirectory, "level.dat"); NBTTagCompound var2; NBTTagCompound var3; WorldInfo worldInfo = null; if (var1.exists()) { try { var2 = CompressedStreamTools.readCompressed(new FileInputStream(var1)); var3 = var2.getCompoundTag("Data"); worldInfo = new WorldInfo(var3); FMLCommonHandler.instance().handleWorldDataLoad(this, worldInfo, var2); return worldInfo; } catch (Exception var5) { var5.printStackTrace(); } } var1 = new File(this.worldDirectory, "level.dat_old"); if (var1.exists()) { try { var2 = CompressedStreamTools.readCompressed(new FileInputStream(var1)); var3 = var2.getCompoundTag("Data"); worldInfo = new WorldInfo(var3); FMLCommonHandler.instance().handleWorldDataLoad(this, worldInfo, var2); return worldInfo; } catch (Exception var4) { var4.printStackTrace(); } } return null; }
@ForgeSubscribe public void onSoundLoad(SoundLoadEvent event) { // For each custom sound file we have defined in Sounds for (String soundFile : TFC_Sounds.soundFiles) { // Try to add the custom sound file to the pool of sounds try { URL path = TerraFirmaCraft.instance.getClass().getResource("/" + soundFile); event.manager.soundPoolSounds.addSound(soundFile, path); } // If we cannot add the custom sound file to the pool, log the // exception catch (Exception e) { FMLCommonHandler.instance() .getFMLLogger() .log(Level.WARNING, "TFC Failed loading sound file: " + soundFile); } } // event.manager.soundPoolMusic = new SoundPool(); // For each custom music file we have defined in Sounds for (String soundFile : TFC_Sounds.musicFiles) { // Try to add the custom music file to the pool of sounds try { URL path = TerraFirmaCraft.instance.getClass().getResource("/" + soundFile); event.manager.soundPoolMusic.addSound(soundFile, path); } // If we cannot add the custom music file to the pool, log the // exception catch (Exception e) { FMLCommonHandler.instance() .getFMLLogger() .log(Level.WARNING, "TFC Failed loading music file: " + soundFile); } } }
// An example showing how to get all players currently in game and check what achievements they // have public static void printPlayerAchievements() { if (FMLCommonHandler.instance().getMinecraftServerInstance() == null) return; // Return in the server is not running. Probably not necessary List allPlayers = FMLCommonHandler.instance() .getMinecraftServerInstance() .getConfigurationManager() .playerEntityList; List allAchievements = AchievementList.achievementList; for (Object playerObject : allPlayers) { if (!(playerObject instanceof EntityPlayerMP)) continue; EntityPlayerMP player = (EntityPlayerMP) playerObject; LogHelper.info(player.getCommandSenderName()); // Prints the in game name of the player for (Object achievementObject : allAchievements) { Achievement achievement = (Achievement) achievementObject; LogHelper.info( achievement.statId); // Prints the achievement id e.g. "achievement.ae2.Facade" LogHelper.info( StatCollector.translateToLocal( achievement.statId)); // This will get the localized name of the achievement LogHelper.info( player .func_147099_x() .hasAchievementUnlocked( achievement)); // Prints true or false depending on weather or not the player // has this achievement unlocked } } }
public ForestryModEnvWarningCallable() { this.modIDs = new ArrayList<String>(); if (FMLCommonHandler.instance().getSide() == Side.CLIENT && FMLClientHandler.instance().hasOptifine()) { modIDs.add("Optifine"); } if (Loader.isModLoaded("gregtech_addon")) { modIDs.add("GregTech"); } try { @SuppressWarnings("unused") Class<?> c = Class.forName("org.bukkit.Bukkit"); modIDs.add("Bukkit, MCPC+, or other Bukkit replacement"); } catch (Throwable t) { } // No need to do anything. // Add other bad mods here. if (modIDs.size() > 0) { FMLCommonHandler.instance().registerCrashCallable(this); } }
public static EntityPlayerMP getPlayerForName(String name) { EntityPlayerMP tempPlayer = FMLCommonHandler.instance() .getMinecraftServerInstance() .getConfigurationManager() .func_152612_a(name); if (tempPlayer != null) { return tempPlayer; } List<EntityPlayerMP> possibles = new LinkedList(); ArrayList<EntityPlayerMP> temp = (ArrayList) FMLCommonHandler.instance() .getSidedDelegate() .getServer() .getConfigurationManager() .playerEntityList; for (EntityPlayerMP player : temp) { if (player.getDisplayName().equalsIgnoreCase(name)) { return player; } if (player.getDisplayName().toLowerCase().contains(name.toLowerCase())) { possibles.add(player); } } if (possibles.size() == 1) { return (EntityPlayerMP) possibles.get(0); } return null; }
/** * DO NOT use this for commands * * @param name * @return */ @SuppressWarnings("unchecked") public static EntityPlayerMP getPlayerForName(String name) { // tru exact match first. { EntityPlayerMP tempPlayer = FMLCommonHandler.instance() .getMinecraftServerInstance() .getConfigurationManager() .getPlayerForUsername(name); if (tempPlayer != null) return tempPlayer; } // now try getting others List<EntityPlayerMP> possibles = new LinkedList<EntityPlayerMP>(); ArrayList<EntityPlayerMP> temp = (ArrayList<EntityPlayerMP>) FMLCommonHandler.instance() .getSidedDelegate() .getServer() .getConfigurationManager() .playerEntityList; for (EntityPlayerMP player : temp) { if (player.username.equalsIgnoreCase(name)) return player; if (player.username.toLowerCase().contains(name.toLowerCase())) { possibles.add(player); } } if (possibles.size() == 1) return possibles.get(0); return null; }
public static void registerHandlers() { FMLCommonHandler.instance().bus().register(new TickHandlerClient()); FMLCommonHandler.instance().bus().register(new KeyHandlerClient()); ClientRegistry.registerKeyBinding(KeyHandlerClient.galaxyMap); ClientRegistry.registerKeyBinding(KeyHandlerClient.openFuelGui); ClientRegistry.registerKeyBinding(KeyHandlerClient.toggleAdvGoggles); MinecraftForge.EVENT_BUS.register(new ClientProxyCore()); }
@Override public IMessage onMessage(DigitalMinerGuiMessage message, MessageContext context) { EntityPlayer player = PacketHandler.getPlayer(context); if (!player.worldObj.isRemote) { World worldServer = FMLCommonHandler.instance() .getMinecraftServerInstance() .worldServerForDimension(message.coord4D.dimensionId); if (worldServer != null && message.coord4D.getTileEntity(worldServer) instanceof TileEntityDigitalMiner) { DigitalMinerGuiMessage.openServerGui( message.packetType, message.guiType, worldServer, (EntityPlayerMP) player, message.coord4D, message.index); } } else { if (message.coord4D.getTileEntity(player.worldObj) instanceof TileEntityDigitalMiner) { try { if (message.packetType == MinerGuiPacket.CLIENT) { FMLCommonHandler.instance() .showGuiScreen( DigitalMinerGuiMessage.getGui( message.packetType, message.guiType, player, player.worldObj, message.coord4D.xCoord, message.coord4D.yCoord, message.coord4D.zCoord, -1)); } else if (message.packetType == MinerGuiPacket.CLIENT_INDEX) { FMLCommonHandler.instance() .showGuiScreen( DigitalMinerGuiMessage.getGui( message.packetType, message.guiType, player, player.worldObj, message.coord4D.xCoord, message.coord4D.yCoord, message.coord4D.zCoord, message.index)); } player.openContainer.windowId = message.windowId; } catch (Exception e) { e.printStackTrace(); } } } return null; }
@EventHandler public void preLoad(FMLPreInitializationEvent event) { snw = NetworkRegistry.INSTANCE.newSimpleChannel(modid); snw.registerMessage(TimeTravelerPacketHandler.class, Message.class, 0, Side.CLIENT); FMLCommonHandler.instance().bus().register(new TTEventHandler()); FMLCommonHandler.instance().bus().register(new Ticker()); MinecraftForge.EVENT_BUS.register(new TTEventHandler()); MinecraftForge.EVENT_BUS.register(new Ticker()); }
public void InitFromPlayer(EntityPlayer par7EntityPlayer) { this.setPigZombieName(par7EntityPlayer.getCommandSenderName()); // this.setZombieName("nekosune"); this.inventory.copyInventory(par7EntityPlayer.inventory); findBestEquipment(); Side side1 = FMLCommonHandler.instance().getEffectiveSide(); Side side2 = FMLCommonHandler.instance().getSide(); if (!this.worldObj.isRemote) { setDropItems(); } copyPotionEffects(par7EntityPlayer); // }
private void registerSubscribtions() { FMLCommonHandler.instance().bus().register(keyHandler); FMLCommonHandler.instance().bus().register(mouseHandler); MinecraftForge.EVENT_BUS.register(GalaxyClient.getInstance()); MinecraftForge.EVENT_BUS.register(new MatterOverdriveIcons()); MinecraftForge.EVENT_BUS.register(renderHandler); MinecraftForge.EVENT_BUS.register(new TooltipHandler()); MinecraftForge.EVENT_BUS.register(androidHud); MinecraftForge.EVENT_BUS.register(mouseHandler); MinecraftForge.EVENT_BUS.register(questHud); FMLCommonHandler.instance().bus().register(renderHandler); FMLCommonHandler.instance().bus().register(GalaxyClient.getInstance()); FMLCommonHandler.instance().bus().register(androidHud); }
/** * OP detection * * @param player * @return */ public static boolean isPlayerOp(String player) { if (FMLCommonHandler.instance().getEffectiveSide().isClient()) return true; MinecraftServer server = FMLCommonHandler.instance().getSidedDelegate().getServer(); // SP and LAN if (server.isSinglePlayer()) { if (server instanceof IntegratedServer && server.getServerOwner().equalsIgnoreCase(player)) return true; } // SMP return server.getConfigurationManager().getOps().contains(player); }
/** Main function called by run() every loop. */ public void tick() { FMLCommonHandler.instance().rescheduleTicks(Side.SERVER); long i = System.nanoTime(); AxisAlignedBB.getAABBPool().cleanPool(); FMLCommonHandler.instance().onPreServerTick(); ++this.tickCounter; if (this.startProfiling) { this.startProfiling = false; this.theProfiler.profilingEnabled = true; this.theProfiler.clearProfiling(); } this.theProfiler.startSection("root"); this.updateTimeLightAndEntities(); if (this.tickCounter % 900 == 0) { this.theProfiler.startSection("save"); this.serverConfigManager.saveAllPlayerData(); this.saveAllWorlds(true); this.theProfiler.endSection(); } this.theProfiler.startSection("tallying"); this.tickTimeArray[this.tickCounter % 100] = System.nanoTime() - i; this.sentPacketCountArray[this.tickCounter % 100] = Packet.sentID - this.lastSentPacketID; this.lastSentPacketID = Packet.sentID; this.sentPacketSizeArray[this.tickCounter % 100] = Packet.sentSize - this.lastSentPacketSize; this.lastSentPacketSize = Packet.sentSize; this.receivedPacketCountArray[this.tickCounter % 100] = Packet.receivedID - this.lastReceivedID; this.lastReceivedID = Packet.receivedID; this.receivedPacketSizeArray[this.tickCounter % 100] = Packet.receivedSize - this.lastReceivedSize; this.lastReceivedSize = Packet.receivedSize; this.theProfiler.endSection(); this.theProfiler.startSection("snooper"); if (!this.usageSnooper.isSnooperRunning() && this.tickCounter > 100) { this.usageSnooper.startSnooper(); } if (this.tickCounter % 6000 == 0) { this.usageSnooper.addMemoryStatsToSnooper(); } this.theProfiler.endSection(); this.theProfiler.endSection(); FMLCommonHandler.instance().onPostServerTick(); }
@Subscribe public void preInit(FMLPreInitializationEvent ev) { bukkitLogger = ev.getModLog(); bukkitLogger.setParent(FMLCommonHandler.instance().getFMLLogger()); // ServerGUI.logger = bukkitLogger; if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) { FMLCommonHandler.instance() .getFMLLogger() .warning("Bukkit For Vanilla is currently only a server-side mod."); return; } else if (FMLCommonHandler.instance().getEffectiveSide() == Side.BUKKIT) { FMLCommonHandler.instance() .getFMLLogger() .severe("The bukkit API as a forge mod on bukkit? *mind blown*"); return; } this.bukkitLogger.info("Initializing configuration..."); myConfigurationFile = ev.getSuggestedConfigurationFile(); Configuration config = new Configuration(myConfigurationFile); config.addCustomCategoryComment("consoleConfig", "Configuration for the server console"); config.addCustomCategoryComment("dontTouchThis", "Things which are best left untouched"); Property colour = config.get( "consoleConfig", "enablecolour", DedicatedServer.getServer().getGuiEnabled() ? false : true); colour.comment = "Enable coloured ANSI console output"; this.allowAnsi = colour.getBoolean(false); Property plugins = config.get(Configuration.CATEGORY_GENERAL, "pluginDir", "plugins"); plugins.comment = "The folder to look for plugins in."; this.pluginFolder = plugins.value; Property suuid = config.get("dontTouchThis", "serverUUID", this.genUUID()); bukkitLogger.info("Set UUID to " + suuid.value); suuid.comment = "The UUID of the server. Don't touch this or it might break your plugins."; this.serverUUID = suuid.value; /*Property showAllLogs = config.get(Configuration.CATEGORY_GENERAL, "printForgeLogToGui", false); showAllLogs.comment = "Print stuff that's outputted to the logs to the GUI as it happens."; this.showAllLogs = showAllLogs.getBoolean(false);*/ config.save(); }
@Mod.EventHandler public void postInit(FMLPostInitializationEvent event) { if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { try { Class clz = Class.forName("morph.common.Morph"); hasMorphMod = true; } catch (Exception e) { } } // GSON gen test // Map<String, Map<String, Object>> className = new HashMap<String, Map<String, // Object>>(); // // Map<String, Object> props = new HashMap<String, Object>(); // // props.put("rotatePointVert", 20.2F/16F); // props.put("rotatePointHori", 8F/16F); // props.put("offsetPointVert", 4F/16F); // props.put("offsetPointHori", 2F/16F); // // className.put("net.minecraft.entity.passive.EntityCow", props); // // Gson gson = new GsonBuilder().setPrettyPrinting().create(); // String jsonOutput = gson.toJson(className); // // System.out.println(jsonOutput); }
@Mod.EventHandler public void init(FMLInitializationEvent evt) { // init modintegration PluginManager.init(); // register gui handler NetworkRegistry.INSTANCE.registerGuiHandler(this, new GuiHandler()); // register TileEntities ModBlocks.registerTileEntities(); // init rendering proxy.registerRenderer(); // register EventHandlers proxy.registerEvents(); // Config handler FMLCommonHandler.instance().bus().register(config); // load Entities ModEntities.init(); // load recipes ModRecipes.init(); // init networking }
public void onTickInGame() { world = FMLCommonHandler.instance().getMinecraftServerInstance().worldServerForDimension(0); if (world != null) { if (!dataRead) { WorldSaveToKHandler.readData(); this.dataRead = true; } if (td.tdd == 0 && !ConfigFileToK.GuildSpawning && dataRead) { if (x.xLocation == 0 && x.yLocation == 0 && x.zLocation == 0) { WorldGenGuild wgg = new WorldGenGuild( world, world.getWorldInfo().getSpawnX(), world.getWorldInfo().getSpawnZ(), world.getWorldInfo().getSpawnY()); wgg.CreateGuild(); spawnGuildMembers( world.getWorldInfo().getSpawnX(), world.getWorldInfo().getSpawnY(), world.getWorldInfo().getSpawnZ()); } else { WorldGenGuild wgg = new WorldGenGuild(world, x.xLocation, x.zLocation, x.yLocation); wgg.CreateGuild(); spawnGuildMembers(x.xLocation, x.yLocation, x.zLocation); } td.tdd = 1; WorldSaveToKHandler.writeData(); } } }
public static boolean showExtraInformation() { if ((FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) && (Keyboard.isKeyDown(42))) { return true; } return false; }
@SubscribeEvent public void playerLoggedInEvent(PlayerEvent.PlayerLoggedInEvent event) { Side side = FMLCommonHandler.instance().getEffectiveSide(); if (side == Side.SERVER) { EventHandlerEntity.syncSchedule.add(event.player.getEntityId()); } }
@Override public void onUpdate() { super.onUpdate(); double newSumTemp = 0; double newHeatLost = 0; double newHeatTransferred = 0; if (FMLCommonHandler.instance().getEffectiveSide().isServer()) { for (IGridTransmitter<IHeatTransfer, HeatNetwork> transmitter : transmitters) { if (transmitter instanceof MultipartTransmitter && ((MultipartTransmitter) transmitter).getPart() instanceof IHeatTransfer) { IHeatTransfer heatTransmitter = (IHeatTransfer) ((MultipartTransmitter) transmitter).getPart(); double[] d = heatTransmitter.simulateHeat(); newHeatTransferred += d[0]; newHeatLost += d[1]; } } for (IGridTransmitter<IHeatTransfer, HeatNetwork> transmitter : transmitters) { if (transmitter instanceof MultipartTransmitter && ((MultipartTransmitter) transmitter).getPart() instanceof IHeatTransfer) { IHeatTransfer heatTransmitter = (IHeatTransfer) ((MultipartTransmitter) transmitter).getPart(); newSumTemp += heatTransmitter.applyTemperatureChange(); } } } heatLost = newHeatLost; heatTransferred = newHeatTransferred; meanTemp = newSumTemp / transmitters.size(); }
public void processRecipe() { HandRecipe recipe = getCurrentRecipe(); if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { processClient(); } else { RecipeOverflow overflow = null; for (int i = 0; i < result.overflow.size(); i++) { if (result.overflow.get(i).id == result.recipes.size() - 1) { overflow = result.overflow.get(i); break; } } if (overflow != null) { if (!InventoryUtils.addItemStackToInventory(player.inventory, overflow.stack.copy())) WorldUtils.dropItem(player, overflow.stack.copy()); result.overflow.remove(overflow); } if (isResult(recipe)) if (!InventoryUtils.addItemStackToInventory(player.inventory, recipe.output.copy())) WorldUtils.dropItem(player, recipe.output.copy()); } result.recipes.remove(0); if (size() == 0) removeChain(); }
@EventHandler public void preInit(FMLPreInitializationEvent event) { weaponSpear = new WeaponSpear() .setUnlocalizedName("weaponSpear") .setTextureName(References.MODID + ":weaponSpear") .setCreativeTab(this.tabArkCraft); itemLongneckRifle = new ItemLongneckRifle() .setUnlocalizedName("itemLongneckRifle") .setTextureName(References.MODID + ":itemLongneckRifle") .setCreativeTab(this.tabArkCraft); GameRegistry.registerItem(weaponSpear, "weapon_spear"); GameRegistry.registerItem(itemLongneckRifle, "itemLongneckRifle"); blockWoodenDoor = new BlockWoodenDoor(Material.wood).setBlockName("blockWoodenDoor"); GameRegistry.registerBlock(blockWoodenDoor, "blockWoodenDoor"); if (event.getSide().isClient()) { FMLCommonHandler.instance().bus().register(new TickClientHandlerEvent()); MinecraftForge.EVENT_BUS.register(new TickClientHandlerEvent()); } }
/** * Handles what should be done on right clicking the item. * * @param is The ItemStack which is right clicked. * @param world The world in which the player is. * @param player The player who right clicked the item. * @param Returns the ItemStack after the process. */ @Override public ItemStack onItemRightClick(ItemStack is, World world, EntityPlayer player) { // if world.isRemote than we are on the client side if (world.isRemote) { // display rename GUI if player is sneaking if (player.isSneaking() && is.getItemDamage() != ItemBackpack.ENDERBACKPACK) { FMLCommonHandler.instance().showGuiScreen(new BackpackGui(player)); } return is; } // when the player is not sneaking if (!player.isSneaking()) { // get the inventory IInventory inv; if (is.getItemDamage() == ItemBackpack.ENDERBACKPACK) { inv = player.getInventoryEnderChest(); } else { inv = new BackpackInventory(player, is); } // open the GUI for a chest based on the loaded inventory player.displayGUIChest(inv); } return is; }
public void onServerBlockActivated( World world, EntityPlayer entityplayer, int x, int y, int z, int side, float hitX, float hitY, float hitZ) { if (!entityplayer.canPlayerEdit(x >> 3, y >> 3, z >> 3, side, entityplayer.getHeldItem())) { return; } if (entityplayer.getHeldItem() != null && entityplayer.getHeldItem().getItem() instanceof ItemLittleBlocksWand) { return; } if (this.canPlayerPlaceBlockOrUseItem(world, entityplayer)) { try { BlockUtil.onServerBlockActivated( world, entityplayer, entityplayer.getCurrentEquippedItem(), x, y, z, side, hitX, hitY, hitZ); } catch (ClassCastException e) { FMLCommonHandler.instance().getFMLLogger().warn(e.getLocalizedMessage()); } } }