diff --git a/build.xml b/build.xml index 39a6a78e..2d9627aa 100644 --- a/build.xml +++ b/build.xml @@ -19,12 +19,13 @@ - + - + + @@ -99,7 +100,7 @@ - + diff --git a/buildcraft_resources/assets/buildcraft/textures/items/triggers/trigger_liquidcontainer_below25.png b/buildcraft_resources/assets/buildcraft/textures/items/triggers/trigger_liquidcontainer_below25.png new file mode 100644 index 00000000..a6ff8872 Binary files /dev/null and b/buildcraft_resources/assets/buildcraft/textures/items/triggers/trigger_liquidcontainer_below25.png differ diff --git a/buildcraft_resources/assets/buildcraft/textures/items/triggers/trigger_liquidcontainer_below50.png b/buildcraft_resources/assets/buildcraft/textures/items/triggers/trigger_liquidcontainer_below50.png new file mode 100644 index 00000000..33f6d298 Binary files /dev/null and b/buildcraft_resources/assets/buildcraft/textures/items/triggers/trigger_liquidcontainer_below50.png differ diff --git a/buildcraft_resources/assets/buildcraft/textures/items/triggers/trigger_liquidcontainer_below75.png b/buildcraft_resources/assets/buildcraft/textures/items/triggers/trigger_liquidcontainer_below75.png new file mode 100644 index 00000000..4ff5dc73 Binary files /dev/null and b/buildcraft_resources/assets/buildcraft/textures/items/triggers/trigger_liquidcontainer_below75.png differ diff --git a/buildcraft_resources/lang/buildcraft/en_US.properties b/buildcraft_resources/lang/buildcraft/en_US.properties index 6b112e2f..2f2cadc9 100644 --- a/buildcraft_resources/lang/buildcraft/en_US.properties +++ b/buildcraft_resources/lang/buildcraft/en_US.properties @@ -57,10 +57,11 @@ gate.trigger.engine.blue=Engine Blue gate.trigger.engine.green=Engine Green gate.trigger.engine.yellow=Engine Yellow gate.trigger.engine.red=Engine Red -gate.trigger.fluid.emtpy=Tank Empty +gate.trigger.fluid.empty=Tank Empty gate.trigger.fluid.contains=Fluid in Tank gate.trigger.fluid.space=Space for Fluid gate.trigger.fluid.full=Tank Full +gate.trigger.fluidlevel.below=Contains < %d%% gate.trigger.inventory.empty=Inventory Empty gate.trigger.inventory.contains=Items in Inventory gate.trigger.inventory.space=Space in Inventory diff --git a/common/buildcraft/BuildCraftBuilders.java b/common/buildcraft/BuildCraftBuilders.java index 5b9e0407..ed129999 100644 --- a/common/buildcraft/BuildCraftBuilders.java +++ b/common/buildcraft/BuildCraftBuilders.java @@ -69,6 +69,7 @@ import buildcraft.core.InterModComms; import buildcraft.core.Version; import buildcraft.core.blueprints.BptPlayerIndex; import buildcraft.core.blueprints.BptRootIndex; +import buildcraft.core.network.PacketHandler; import buildcraft.core.proxy.CoreProxy; import buildcraft.core.utils.BCLog; import cpw.mods.fml.common.Mod; @@ -78,7 +79,7 @@ import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLInterModComms; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.event.FMLServerStoppingEvent; -import cpw.mods.fml.common.network.NetworkMod; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; @@ -91,18 +92,18 @@ import java.util.LinkedList; import java.util.TreeMap; import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.client.event.TextureStitchEvent; -import net.minecraftforge.common.Configuration; +import net.minecraftforge.common.config.Configuration; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.common.Property; -import net.minecraftforge.event.ForgeSubscribe; +import net.minecraftforge.common.config.Property; @Mod(name = "BuildCraft Builders", version = Version.VERSION, useMetadata = false, modid = "BuildCraft|Builders", dependencies = DefaultProps.DEPENDENCY_CORE) -@NetworkMod(channels = {DefaultProps.NET_CHANNEL_NAME}, packetHandler = PacketHandlerBuilders.class, clientSideRequired = true, serverSideRequired = true) -public class BuildCraftBuilders { +public class BuildCraftBuilders extends BuildCraftMod { public static final char BPT_SEP_CHARACTER = '-'; public static final int LIBRARY_PAGE_SIZE = 12; @@ -145,12 +146,16 @@ public class BuildCraftBuilders { @EventHandler public void init(FMLInitializationEvent evt) { + channels = NetworkRegistry.INSTANCE.newChannel + (DefaultProps.NET_CHANNEL_NAME + "-BUILDERS", new PacketHandlerBuilders()); + // Register gui handler - NetworkRegistry.instance().registerGuiHandler(instance, new GuiHandler()); + NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler()); // Register save handler MinecraftForge.EVENT_BUS.register(new EventHandlerBuilders()); + /* new BptBlock(0); // default bpt block new BptBlockIgnore(Block.snow.blockID); @@ -236,7 +241,7 @@ public class BuildCraftBuilders { new BptBlockInventory(libraryBlock.blockID); new BptBlockWallSide(markerBlock.blockID); - new BptBlockWallSide(pathMarkerBlock.blockID); + new BptBlockWallSide(pathMarkerBlock.blockID);*/ if (BuildCraftCore.loadDefaultRecipes) { loadRecipes(); @@ -246,16 +251,6 @@ public class BuildCraftBuilders { @EventHandler public void preInit(FMLPreInitializationEvent evt) { - Property templateItemId = BuildCraftCore.mainConfiguration.getItem("templateItem.id", DefaultProps.TEMPLATE_ITEM_ID); - Property blueprintItemId = BuildCraftCore.mainConfiguration.getItem("blueprintItem.id", DefaultProps.BLUEPRINT_ITEM_ID); - Property markerId = BuildCraftCore.mainConfiguration.getBlock("marker.id", DefaultProps.MARKER_ID); - Property pathMarkerId = BuildCraftCore.mainConfiguration.getBlock("pathMarker.id", DefaultProps.PATH_MARKER_ID); - Property fillerId = BuildCraftCore.mainConfiguration.getBlock("filler.id", DefaultProps.FILLER_ID); - Property builderId = BuildCraftCore.mainConfiguration.getBlock("builder.id", DefaultProps.BUILDER_ID); - Property architectId = BuildCraftCore.mainConfiguration.getBlock("architect.id", DefaultProps.ARCHITECT_ID); - Property libraryId = BuildCraftCore.mainConfiguration.getBlock("blueprintLibrary.id", DefaultProps.BLUEPRINT_LIBRARY_ID); - Property urbanistId = BuildCraftCore.mainConfiguration.getBlock("urbanist.id", DefaultProps.URBANIST_ID); - Property fillerDestroyProp = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "filler.destroy", DefaultProps.FILLER_DESTROY); fillerDestroyProp.comment = "If true, Filler will destroy blocks instead of breaking them."; fillerDestroy = fillerDestroyProp.getBoolean(DefaultProps.FILLER_DESTROY); @@ -268,42 +263,43 @@ public class BuildCraftBuilders { fillerLifespanNormalProp.comment = "Lifespan in ticks of items dropped by the filler from non-tough blocks (those that can be broken by hand)"; fillerLifespanNormal = fillerLifespanNormalProp.getInt(DefaultProps.FILLER_LIFESPAN_NORMAL); - templateItem = new ItemBlueprintTemplate(templateItemId.getInt()); + + templateItem = new ItemBlueprintTemplate(); templateItem.setUnlocalizedName("templateItem"); LanguageRegistry.addName(templateItem, "Template"); CoreProxy.proxy.registerItem(templateItem); - blueprintItem = new ItemBlueprintStandard(blueprintItemId.getInt()); + blueprintItem = new ItemBlueprintStandard(); blueprintItem.setUnlocalizedName("blueprintItem"); LanguageRegistry.addName(blueprintItem, "Blueprint"); CoreProxy.proxy.registerItem(blueprintItem); - markerBlock = new BlockMarker(markerId.getInt()); - CoreProxy.proxy.registerBlock(markerBlock.setUnlocalizedName("markerBlock")); + markerBlock = new BlockMarker(); + CoreProxy.proxy.registerBlock(markerBlock.setBlockName("markerBlock")); CoreProxy.proxy.addName(markerBlock, "Land Mark"); - pathMarkerBlock = new BlockPathMarker(pathMarkerId.getInt()); - CoreProxy.proxy.registerBlock(pathMarkerBlock.setUnlocalizedName("pathMarkerBlock")); + pathMarkerBlock = new BlockPathMarker(); + CoreProxy.proxy.registerBlock(pathMarkerBlock.setBlockName("pathMarkerBlock")); CoreProxy.proxy.addName(pathMarkerBlock, "Path Mark"); - fillerBlock = new BlockFiller(fillerId.getInt()); - CoreProxy.proxy.registerBlock(fillerBlock.setUnlocalizedName("fillerBlock")); + fillerBlock = new BlockFiller(); + CoreProxy.proxy.registerBlock(fillerBlock.setBlockName("fillerBlock")); CoreProxy.proxy.addName(fillerBlock, "Filler"); - builderBlock = new BlockBuilder(builderId.getInt()); - CoreProxy.proxy.registerBlock(builderBlock.setUnlocalizedName("builderBlock")); + builderBlock = new BlockBuilder(); + CoreProxy.proxy.registerBlock(builderBlock.setBlockName("builderBlock")); CoreProxy.proxy.addName(builderBlock, "Builder"); - architectBlock = new BlockArchitect(architectId.getInt()); - CoreProxy.proxy.registerBlock(architectBlock.setUnlocalizedName("architectBlock")); + architectBlock = new BlockArchitect(); + CoreProxy.proxy.registerBlock(architectBlock.setBlockName("architectBlock")); CoreProxy.proxy.addName(architectBlock, "Architect Table"); - libraryBlock = new BlockBlueprintLibrary(libraryId.getInt()); - CoreProxy.proxy.registerBlock(libraryBlock.setUnlocalizedName("libraryBlock")); + libraryBlock = new BlockBlueprintLibrary(); + CoreProxy.proxy.registerBlock(libraryBlock.setBlockName("libraryBlock")); CoreProxy.proxy.addName(libraryBlock, "Blueprint Library"); - urbanistBlock = new BlockUrbanist (urbanistId.getInt()); - CoreProxy.proxy.registerBlock(urbanistBlock.setUnlocalizedName("urbanistBlock")); + urbanistBlock = new BlockUrbanist (); + CoreProxy.proxy.registerBlock(urbanistBlock.setBlockName("urbanistBlock")); CoreProxy.proxy.addName(urbanistBlock, "Urbanist"); CoreProxy.proxy.registerTileEntity(TileUrbanist.class, "net.minecraft.src.builders.TileUrbanist"); @@ -347,17 +343,17 @@ public class BuildCraftBuilders { // new ItemStack(Item.dyePowder, 1, 0), 'p', Item.paper}); CoreProxy.proxy.addCraftingRecipe(new ItemStack(blueprintItem, 1), new Object[]{"ppp", "pip", "ppp", 'i', - new ItemStack(Item.dyePowder, 1, 4), 'p', Item.paper}); + new ItemStack(Items.dye, 1, 4), 'p', Items.paper}); CoreProxy.proxy.addCraftingRecipe(new ItemStack(markerBlock, 1), new Object[]{"l ", "r ", 'l', - new ItemStack(Item.dyePowder, 1, 4), 'r', Block.torchRedstoneActive}); + new ItemStack(Items.dye, 1, 4), 'r', Blocks.redstone_torch}); // CoreProxy.proxy.addCraftingRecipe(new ItemStack(pathMarkerBlock, 1), new Object[]{"l ", "r ", 'l', // new ItemStack(Item.dyePowder, 1, 2), 'r', Block.torchRedstoneActive}); CoreProxy.proxy.addCraftingRecipe(new ItemStack(fillerBlock, 1), new Object[]{"btb", "ycy", "gCg", 'b', - new ItemStack(Item.dyePowder, 1, 0), 't', markerBlock, 'y', new ItemStack(Item.dyePowder, 1, 11), - 'c', Block.workbench, 'g', BuildCraftCore.goldGearItem, 'C', Block.chest}); + new ItemStack(Items.dye, 1, 0), 't', markerBlock, 'y', new ItemStack(Items.dye, 1, 11), + 'c', Blocks.crafting_table, 'g', BuildCraftCore.goldGearItem, 'C', Blocks.chest}); // CoreProxy.proxy.addCraftingRecipe(new ItemStack(builderBlock, 1), new Object[]{"btb", "ycy", "gCg", 'b', // new ItemStack(Item.dyePowder, 1, 0), 't', markerBlock, 'y', new ItemStack(Item.dyePowder, 1, 11), @@ -369,7 +365,7 @@ public class BuildCraftBuilders { // new ItemStack(templateItem, 1)}); CoreProxy.proxy.addCraftingRecipe(new ItemStack(libraryBlock, 1), new Object[]{"bbb", "bBb", "bbb", 'b', - new ItemStack(blueprintItem), 'B', Block.bookShelf}); + new ItemStack(blueprintItem), 'B', Blocks.bookshelf}); } @EventHandler @@ -411,8 +407,8 @@ public class BuildCraftBuilders { return rootBptIndex; } - public static ItemStack getBptItemStack(int id, int damage, String name) { - ItemStack stack = new ItemStack(id, 1, damage); + public static ItemStack getBptItemStack(Item item, int damage, String name) { + ItemStack stack = new ItemStack(item, 1, damage); NBTTagCompound nbt = new NBTTagCompound(); if (name != null && !"".equals(name)) { nbt.setString("BptName", name); @@ -432,20 +428,20 @@ public class BuildCraftBuilders { TilePathMarker.clearAvailableMarkersList(); } - @ForgeSubscribe + @SubscribeEvent @SideOnly(Side.CLIENT) public void loadTextures(TextureStitchEvent.Pre evt) { - if (evt.map.textureType == 0) { + if (evt.map.getTextureType() == 0) { for (FillerPattern pattern : FillerPattern.patterns.values()) { pattern.registerIcon(evt.map); } } } - @ForgeSubscribe + @SubscribeEvent @SideOnly(Side.CLIENT) public void textureHook(TextureStitchEvent.Pre event) { - if (event.map.textureType == 1) { + if (event.map.getTextureType() == 1) { UrbanistToolsIconProvider.INSTANCE.registerIcons(event.map); } } diff --git a/common/buildcraft/BuildCraftCore.java b/common/buildcraft/BuildCraftCore.java index e11721a3..8053eca5 100644 --- a/common/buildcraft/BuildCraftCore.java +++ b/common/buildcraft/BuildCraftCore.java @@ -8,22 +8,30 @@ */ package buildcraft; +import static buildcraft.BuildCraftEnergy.spawnOilSprings; + import java.io.File; +import java.util.EnumMap; import java.util.TreeMap; import net.minecraft.block.Block; -import net.minecraft.block.BlockFluid; import net.minecraft.entity.EntityList; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.util.Icon; +import net.minecraft.network.Packet; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; import net.minecraftforge.client.event.TextureStitchEvent; -import net.minecraftforge.common.Configuration; +import net.minecraftforge.common.config.Configuration; import net.minecraftforge.common.IPlantable; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.common.Property; -import net.minecraftforge.event.ForgeSubscribe; +import net.minecraftforge.common.config.Property; import net.minecraftforge.oredict.OreDictionary; +import net.minecraftforge.fluids.BlockFluidBase; import net.minecraftforge.fluids.IFluidBlock; import buildcraft.api.core.BuildCraftAPI; import buildcraft.api.core.IIconProvider; @@ -48,6 +56,7 @@ import buildcraft.core.SpringPopulate; import buildcraft.core.TickHandlerCoreClient; import buildcraft.core.Version; import buildcraft.core.blueprints.BptItem; +import buildcraft.core.network.BuildCraftPacket; import buildcraft.core.network.EntityIds; import buildcraft.core.network.PacketHandler; import buildcraft.core.network.PacketUpdate; @@ -61,6 +70,7 @@ import buildcraft.core.triggers.BCTrigger; import buildcraft.core.triggers.DefaultActionProvider; import buildcraft.core.triggers.DefaultTriggerProvider; import buildcraft.core.triggers.TriggerFluidContainer; +import buildcraft.core.triggers.TriggerFluidContainerLevel; import buildcraft.core.triggers.TriggerInventory; import buildcraft.core.triggers.TriggerInventoryLevel; import buildcraft.core.triggers.TriggerMachine; @@ -73,6 +83,7 @@ import buildcraft.core.robots.EntityRobot; import buildcraft.core.robots.EntityRobotBuilder; import buildcraft.core.robots.EntityRobotPicker; import buildcraft.core.triggers.TriggerRedstoneInput; +import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.Instance; @@ -81,19 +92,17 @@ import cpw.mods.fml.common.event.FMLInterModComms; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.event.FMLServerStartingEvent; -import cpw.mods.fml.common.network.NetworkMod; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.network.FMLEmbeddedChannel; +import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.common.registry.EntityRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; -import cpw.mods.fml.common.registry.TickRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -@Mod(name = "BuildCraft", version = Version.VERSION, useMetadata = false, modid = "BuildCraft|Core", acceptedMinecraftVersions = "[1.6.4,1.7)", dependencies = "required-after:Forge@[9.11.1.953,)") -@NetworkMod(channels = {DefaultProps.NET_CHANNEL_NAME}, packetHandler = PacketHandler.class, clientSideRequired = true, serverSideRequired = true) -public class BuildCraftCore { - +@Mod(name = "BuildCraft", version = Version.VERSION, useMetadata = false, modid = "BuildCraft|Core", acceptedMinecraftVersions = "[1.7.2,1.8)", dependencies = "required-after:Forge@[10.12.0.1024,)") +public class BuildCraftCore extends BuildCraftMod { public static enum RenderMode { - Full, NoDynamic }; public static RenderMode render = RenderMode.Full; @@ -105,7 +114,10 @@ public class BuildCraftCore { public static int updateFactor = 10; public static long longUpdateFactor = 40; public static BuildCraftConfiguration mainConfiguration; + + // TODO: This doesn't seem used anymore. Remove if it's the case. public static TreeMap bufferedDescriptions = new TreeMap(); + public static final int trackedPassiveEntityId = 156; public static boolean continuousCurrentModel; public static Block springBlock; @@ -120,19 +132,18 @@ public class BuildCraftCore { public static Item robotBuilderItem; public static Item robotPickerItem; @SideOnly(Side.CLIENT) - public static Icon redLaserTexture; + public static IIcon redLaserTexture; @SideOnly(Side.CLIENT) - public static Icon blueLaserTexture; + public static IIcon blueLaserTexture; @SideOnly(Side.CLIENT) - public static Icon stripesLaserTexture; + public static IIcon stripesLaserTexture; @SideOnly(Side.CLIENT) - public static Icon transparentTexture; + public static IIcon transparentTexture; @SideOnly(Side.CLIENT) public static IIconProvider iconProvider; public static int blockByEntityModel; public static int legacyPipeModel; public static int markerModel; - public static int oilModel; public static BCTrigger triggerMachineActive = new TriggerMachine(true); public static BCTrigger triggerMachineInactive = new TriggerMachine(false); public static BCTrigger triggerEmptyInventory = new TriggerInventory(TriggerInventory.State.Empty); @@ -148,6 +159,9 @@ public class BuildCraftCore { public static BCTrigger triggerInventoryBelow25 = new TriggerInventoryLevel(TriggerInventoryLevel.TriggerType.BELOW_25); public static BCTrigger triggerInventoryBelow50 = new TriggerInventoryLevel(TriggerInventoryLevel.TriggerType.BELOW_50); public static BCTrigger triggerInventoryBelow75 = new TriggerInventoryLevel(TriggerInventoryLevel.TriggerType.BELOW_75); + public static BCTrigger triggerFluidContainerBelow25 = new TriggerFluidContainerLevel(TriggerFluidContainerLevel.TriggerType.BELOW_25); + public static BCTrigger triggerFluidContainerBelow50 = new TriggerFluidContainerLevel(TriggerFluidContainerLevel.TriggerType.BELOW_50); + public static BCTrigger triggerFluidContainerBelow75 = new TriggerFluidContainerLevel(TriggerFluidContainerLevel.TriggerType.BELOW_75); public static BCAction actionRedstone = new ActionRedstoneOutput(); public static BCAction actionOn = new ActionMachineControl(Mode.On); public static BCAction actionOff = new ActionMachineControl(Mode.Off); @@ -155,7 +169,7 @@ public class BuildCraftCore { public static boolean loadDefaultRecipes = true; public static boolean forcePneumaticPower = true; public static boolean consumeWaterSources = false; - public static BptItem[] itemBptProps = new BptItem[Item.itemsList.length]; + //public static BptItem[] itemBptProps = new BptItem[Item.itemsList.length]; @Instance("BuildCraft|Core") public static BuildCraftCore instance; @@ -202,30 +216,17 @@ public class BuildCraftCore { longFactor.comment = "delay between full client sync packets, increasing it saves bandwidth, decreasing makes for better client syncronization."; longUpdateFactor = longFactor.getInt(40); - Property wrenchId = BuildCraftCore.mainConfiguration.getItem("wrench.id", DefaultProps.WRENCH_ID); - - wrenchItem = (new ItemWrench(wrenchId.getInt(DefaultProps.WRENCH_ID))).setUnlocalizedName("wrenchItem"); + wrenchItem = (new ItemWrench()).setUnlocalizedName("wrenchItem"); LanguageRegistry.addName(wrenchItem, "Wrench"); CoreProxy.proxy.registerItem(wrenchItem); - int springId = BuildCraftCore.mainConfiguration.getBlock("springBlock.id", DefaultProps.SPRING_ID).getInt(DefaultProps.SPRING_ID); - - Property woodenGearId = BuildCraftCore.mainConfiguration.getItem("woodenGearItem.id", DefaultProps.WOODEN_GEAR_ID); - Property stoneGearId = BuildCraftCore.mainConfiguration.getItem("stoneGearItem.id", DefaultProps.STONE_GEAR_ID); - Property ironGearId = BuildCraftCore.mainConfiguration.getItem("ironGearItem.id", DefaultProps.IRON_GEAR_ID); - Property goldenGearId = BuildCraftCore.mainConfiguration.getItem("goldenGearItem.id", DefaultProps.GOLDEN_GEAR_ID); - Property diamondGearId = BuildCraftCore.mainConfiguration.getItem("diamondGearItem.id", DefaultProps.DIAMOND_GEAR_ID); - Property redstoneCrystalId = BuildCraftCore.mainConfiguration.getItem("redstoneCrystalItem.id", DefaultProps.REDSTONE_CRYSTAL_ID); - Property robotBaseItemId = BuildCraftCore.mainConfiguration.getItem("robotBaseItem.id", DefaultProps.ROBOT_BASE_ITEM_ID); - Property robotBuilderItemId = BuildCraftCore.mainConfiguration.getItem("robotBuilderItem.id", DefaultProps.ROBOT_BUILDER_ITEM_ID); - Property robotPickerItemId = BuildCraftCore.mainConfiguration.getItem("robotPickerItem.id", DefaultProps.ROBOT_PICKER_ITEM_ID); Property modifyWorldProp = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "modifyWorld", true); modifyWorldProp.comment = "set to false if BuildCraft should not generate custom blocks (e.g. oil)"; modifyWorld = modifyWorldProp.getBoolean(true); - if (BuildCraftCore.modifyWorld && springId > 0) { + if (BuildCraftCore.modifyWorld) { BlockSpring.EnumSpring.WATER.canGen = BuildCraftCore.mainConfiguration.get("worldgen", "waterSpring", true).getBoolean(true); - springBlock = new BlockSpring(springId).setUnlocalizedName("eternalSpring"); + springBlock = new BlockSpring().setBlockName("eternalSpring"); CoreProxy.proxy.registerBlock(springBlock, ItemSpring.class); } @@ -233,54 +234,37 @@ public class BuildCraftCore { consumeWaterSources = consumeWater.getBoolean(consumeWaterSources); consumeWater.comment = "set to true if the Pump should consume water"; - woodenGearItem = (new ItemBuildCraft(woodenGearId.getInt())).setUnlocalizedName("woodenGearItem"); + woodenGearItem = (new ItemBuildCraft()).setUnlocalizedName("woodenGearItem"); LanguageRegistry.addName(woodenGearItem, "Wooden Gear"); CoreProxy.proxy.registerItem(woodenGearItem); OreDictionary.registerOre("gearWood", new ItemStack(woodenGearItem)); - stoneGearItem = (new ItemBuildCraft(stoneGearId.getInt())).setUnlocalizedName("stoneGearItem"); + stoneGearItem = (new ItemBuildCraft()).setUnlocalizedName("stoneGearItem"); LanguageRegistry.addName(stoneGearItem, "Stone Gear"); CoreProxy.proxy.registerItem(stoneGearItem); OreDictionary.registerOre("gearStone", new ItemStack(stoneGearItem)); - ironGearItem = (new ItemBuildCraft(ironGearId.getInt())).setUnlocalizedName("ironGearItem"); + ironGearItem = (new ItemBuildCraft()).setUnlocalizedName("ironGearItem"); LanguageRegistry.addName(ironGearItem, "Iron Gear"); CoreProxy.proxy.registerItem(ironGearItem); OreDictionary.registerOre("gearIron", new ItemStack(ironGearItem)); - goldGearItem = (new ItemBuildCraft(goldenGearId.getInt())).setUnlocalizedName("goldGearItem"); + goldGearItem = (new ItemBuildCraft()).setUnlocalizedName("goldGearItem"); LanguageRegistry.addName(goldGearItem, "Gold Gear"); CoreProxy.proxy.registerItem(goldGearItem); OreDictionary.registerOre("gearGold", new ItemStack(goldGearItem)); - diamondGearItem = (new ItemBuildCraft(diamondGearId.getInt())).setUnlocalizedName("diamondGearItem"); + diamondGearItem = (new ItemBuildCraft()).setUnlocalizedName("diamondGearItem"); LanguageRegistry.addName(diamondGearItem, "Diamond Gear"); CoreProxy.proxy.registerItem(diamondGearItem); OreDictionary.registerOre("gearDiamond", new ItemStack(diamondGearItem)); - redstoneCrystal = (new ItemBuildCraft(redstoneCrystalId.getInt())).setUnlocalizedName("redstoneCrystal"); + redstoneCrystal = (new ItemBuildCraft()).setUnlocalizedName("redstoneCrystal"); LanguageRegistry.addName(redstoneCrystal, "Redstone Crystal"); CoreProxy.proxy.registerItem(redstoneCrystal); OreDictionary.registerOre("redstoneCrystal", new ItemStack(redstoneCrystal)); - robotBaseItem = (new ItemRobot(robotBaseItemId.getInt(), EntityRobot.class)).setUnlocalizedName("robotBaseItem"); - LanguageRegistry.addName(robotBaseItem, "Base Robot"); - CoreProxy.proxy.registerItem(robotBaseItem); - - robotBuilderItem = (new ItemRobot(robotBuilderItemId.getInt(), EntityRobotBuilder.class)).setUnlocalizedName("robotBuilderItem"); - LanguageRegistry.addName(robotBuilderItem, "Builder Robot"); - CoreProxy.proxy.registerItem(robotBuilderItem); - - robotPickerItem = (new ItemRobot(robotPickerItemId.getInt(), EntityRobotPicker.class)).setUnlocalizedName("robotPickerItem"); - LanguageRegistry.addName(robotPickerItem, "Picker Robot"); - CoreProxy.proxy.registerItem(robotPickerItem); - - - Property colorBlindProp = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "client.colorblindmode", false); - colorBlindProp.comment = "Set to true to enable alternate textures"; - colorBlindMode = colorBlindProp.getBoolean(false); - - MinecraftForge.EVENT_BUS.register(this); + MinecraftForge.EVENT_BUS.register(this); } finally { if (mainConfiguration.hasChanged()) { mainConfiguration.save(); @@ -291,7 +275,9 @@ public class BuildCraftCore { @EventHandler public void initialize(FMLInitializationEvent evt) { - // MinecraftForge.registerConnectionHandler(new ConnectionHandler()); + channels = NetworkRegistry.INSTANCE.newChannel + (DefaultProps.NET_CHANNEL_NAME + "-CORE", new PacketHandler()); + ActionManager.registerTriggerProvider(new DefaultTriggerProvider()); ActionManager.registerActionProvider(new DefaultActionProvider()); @@ -325,17 +311,19 @@ public class BuildCraftCore { @EventHandler public void postInit(FMLPostInitializationEvent event) { - for (Block block : Block.blocksList) { - if (block instanceof BlockFluid || block instanceof IFluidBlock || block instanceof IPlantable) { - BuildCraftAPI.softBlocks[block.blockID] = true; + for (Object o : Block.blockRegistry) { + Block block = (Block) o; + + if (block instanceof BlockFluidBase || block instanceof IFluidBlock || block instanceof IPlantable) { + BuildCraftAPI.softBlocks.add(block); } } - - BuildCraftAPI.softBlocks[Block.snow.blockID] = true; - BuildCraftAPI.softBlocks[Block.vine.blockID] = true; - BuildCraftAPI.softBlocks[Block.fire.blockID] = true; - TickRegistry.registerTickHandler(new TickHandlerCoreClient(), Side.CLIENT); - + + BuildCraftAPI.softBlocks.add(Blocks.snow); + BuildCraftAPI.softBlocks.add(Blocks.vine); + BuildCraftAPI.softBlocks.add(Blocks.fire); + + FMLCommonHandler.instance().bus().register(new TickHandlerCoreClient()); } @EventHandler @@ -343,14 +331,14 @@ public class BuildCraftCore { event.registerServerCommand(new CommandBuildCraft()); } - @ForgeSubscribe + @SubscribeEvent @SideOnly(Side.CLIENT) public void textureHook(TextureStitchEvent.Pre event) { - if (event.map.textureType == 1) { + if (event.map.getTextureType() == 1) { iconProvider = new CoreIconProvider(); iconProvider.registerIcons(event.map); ActionTriggerIconProvider.INSTANCE.registerIcons(event.map); - } else if (event.map.textureType == 0) { + } else if (event.map.getTextureType() == 0) { BuildCraftCore.redLaserTexture = event.map.registerIcon("buildcraft:blockRedLaser"); BuildCraftCore.blueLaserTexture = event.map.registerIcon("buildcraft:blockBlueLaser"); BuildCraftCore.stripesLaserTexture = event.map.registerIcon("buildcraft:blockStripesLaser"); @@ -360,13 +348,13 @@ public class BuildCraftCore { } public void loadRecipes() { - CoreProxy.proxy.addCraftingRecipe(new ItemStack(wrenchItem), "I I", " G ", " I ", 'I', Item.ingotIron, 'G', stoneGearItem); + CoreProxy.proxy.addCraftingRecipe(new ItemStack(wrenchItem), "I I", " G ", " I ", 'I', Items.iron_ingot, 'G', stoneGearItem); CoreProxy.proxy.addCraftingRecipe(new ItemStack(woodenGearItem), " S ", "S S", " S ", 'S', "stickWood"); CoreProxy.proxy.addCraftingRecipe(new ItemStack(stoneGearItem), " I ", "IGI", " I ", 'I', "cobblestone", 'G', woodenGearItem); - CoreProxy.proxy.addCraftingRecipe(new ItemStack(ironGearItem), " I ", "IGI", " I ", 'I', Item.ingotIron, 'G', stoneGearItem); - CoreProxy.proxy.addCraftingRecipe(new ItemStack(goldGearItem), " I ", "IGI", " I ", 'I', Item.ingotGold, 'G', ironGearItem); - CoreProxy.proxy.addCraftingRecipe(new ItemStack(diamondGearItem), " I ", "IGI", " I ", 'I', Item.diamond, 'G', goldGearItem); + CoreProxy.proxy.addCraftingRecipe(new ItemStack(ironGearItem), " I ", "IGI", " I ", 'I', Items.iron_ingot, 'G', stoneGearItem); + CoreProxy.proxy.addCraftingRecipe(new ItemStack(goldGearItem), " I ", "IGI", " I ", 'I', Items.gold_ingot, 'G', ironGearItem); + CoreProxy.proxy.addCraftingRecipe(new ItemStack(diamondGearItem), " I ", "IGI", " I ", 'I', Items.diamond, 'G', goldGearItem); } @EventHandler diff --git a/common/buildcraft/BuildCraftEnergy.java b/common/buildcraft/BuildCraftEnergy.java index fa886f95..981ae76c 100644 --- a/common/buildcraft/BuildCraftEnergy.java +++ b/common/buildcraft/BuildCraftEnergy.java @@ -37,6 +37,7 @@ import buildcraft.energy.worldgen.BiomeGenOilDesert; import buildcraft.energy.worldgen.BiomeGenOilOcean; import buildcraft.energy.worldgen.BiomeInitializer; import buildcraft.energy.worldgen.OilPopulate; +import buildcraft.transport.network.PacketHandlerTransport; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.Instance; @@ -44,7 +45,7 @@ import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLInterModComms; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; -import cpw.mods.fml.common.network.NetworkMod; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; import cpw.mods.fml.relauncher.Side; @@ -54,22 +55,22 @@ import java.util.TreeMap; import net.minecraft.block.Block; import net.minecraft.block.material.Material; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.biome.BiomeGenBase; import net.minecraftforge.client.event.TextureStitchEvent; -import net.minecraftforge.common.Configuration; +import net.minecraftforge.common.config.Configuration; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.common.Property; -import net.minecraftforge.event.ForgeSubscribe; +import net.minecraftforge.common.config.Property; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; @Mod(name = "BuildCraft Energy", version = Version.VERSION, useMetadata = false, modid = "BuildCraft|Energy", dependencies = DefaultProps.DEPENDENCY_CORE) -@NetworkMod(channels = {DefaultProps.NET_CHANNEL_NAME}, clientSideRequired = true, serverSideRequired = true) -public class BuildCraftEnergy { +public class BuildCraftEnergy extends BuildCraftMod { public final static int ENERGY_REMOVE_BLOCK = 25; public final static int ENERGY_EXTRACT_ITEM = 2; @@ -103,22 +104,7 @@ public class BuildCraftEnergy { public static BuildCraftEnergy instance; @EventHandler - public void preInit(FMLPreInitializationEvent evt) { - Property engineId = BuildCraftCore.mainConfiguration.getBlock("engine.id", DefaultProps.ENGINE_ID); - - // Update oil tag - int defaultOilId = DefaultProps.OIL_ID; - if (BuildCraftCore.mainConfiguration.hasKey(Configuration.CATEGORY_BLOCK, "oilStill.id")) { - defaultOilId = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_BLOCK, "oilStill.id", defaultOilId).getInt(defaultOilId); - BuildCraftCore.mainConfiguration.getCategory(Configuration.CATEGORY_BLOCK).remove("oilStill.id"); - } - int blockOilId = BuildCraftCore.mainConfiguration.getBlock("oil.id", defaultOilId).getInt(defaultOilId); - - int blockFuelId = BuildCraftCore.mainConfiguration.getBlock("fuel.id", DefaultProps.FUEL_ID).getInt(DefaultProps.FUEL_ID); - int blockRedplasmaId = BuildCraftCore.mainConfiguration.getBlock("redPlasma.id", DefaultProps.REDPLASMA_ID).getInt(DefaultProps.REDPLASMA_ID); - int bucketOilId = BuildCraftCore.mainConfiguration.getItem("bucketOil.id", DefaultProps.BUCKET_OIL_ID).getInt(DefaultProps.BUCKET_OIL_ID); - int bucketFuelId = BuildCraftCore.mainConfiguration.getItem("bucketFuel.id", DefaultProps.BUCKET_FUEL_ID).getInt(DefaultProps.BUCKET_FUEL_ID); - int bucketRedPlasmaId = BuildCraftCore.mainConfiguration.getItem("bucketRedPlasma.id", DefaultProps.BUCKET_REDPLASMA_ID).getInt(DefaultProps.BUCKET_REDPLASMA_ID); + public void preInit(FMLPreInitializationEvent evt) { int oilDesertBiomeId = BuildCraftCore.mainConfiguration.get("biomes", "oilDesert", DefaultProps.BIOME_OIL_DESERT).getInt(DefaultProps.BIOME_OIL_DESERT); int oilOceanBiomeId = BuildCraftCore.mainConfiguration.get("biomes", "oilOcean", DefaultProps.BIOME_OIL_OCEAN).getInt(DefaultProps.BIOME_OIL_OCEAN); canOilBurn = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "burnOil", true, "Can oil burn?").getBoolean(true); @@ -136,21 +122,21 @@ public class BuildCraftEnergy { } if (oilDesertBiomeId > 0) { - if (BiomeGenBase.biomeList[oilDesertBiomeId] != null) { + if (BiomeGenBase.getBiomeGenArray () [oilDesertBiomeId] != null) { throw new BiomeIdException("oilDesert", oilDesertBiomeId); } biomeOilDesert = BiomeGenOilDesert.makeBiome(oilDesertBiomeId); } if (oilOceanBiomeId > 0) { - if (BiomeGenBase.biomeList[oilOceanBiomeId] != null) { + if (BiomeGenBase.getBiomeGenArray () [oilOceanBiomeId] != null) { throw new BiomeIdException("oilOcean", oilOceanBiomeId); } biomeOilOcean = BiomeGenOilOcean.makeBiome(oilOceanBiomeId); } - engineBlock = new BlockEngine(engineId.getInt(DefaultProps.ENGINE_ID)); + engineBlock = new BlockEngine(); CoreProxy.proxy.registerBlock(engineBlock, ItemEngine.class); LanguageRegistry.addName(new ItemStack(engineBlock, 1, 0), "Redstone Engine"); @@ -171,18 +157,14 @@ public class BuildCraftEnergy { FluidRegistry.registerFluid(buildcraftFluidRedPlasma); fluidRedPlasma = FluidRegistry.getFluid("redplasma"); - //buildcraftFluidRedPlasma = new BCFluid("fuel"); - - if (fluidOil.getBlockID() == -1) { - if (blockOilId > 0) { - blockOil = new BlockBuildcraftFluid(blockOilId, fluidOil, Material.water).setFlammable(canOilBurn).setFlammability(0); - blockOil.setUnlocalizedName("blockOil"); - CoreProxy.proxy.addName(blockOil, "Oil"); - CoreProxy.proxy.registerBlock(blockOil); - fluidOil.setBlockID(blockOil); - } + if (fluidOil.getBlock() == null) { + blockOil = new BlockBuildcraftFluid(fluidOil, Material.water).setFlammable(canOilBurn).setFlammability(0); + blockOil.setBlockName("blockOil"); + CoreProxy.proxy.addName(blockOil, "Oil"); + CoreProxy.proxy.registerBlock(blockOil); + fluidOil.setBlock(blockOil); } else { - blockOil = Block.blocksList[fluidOil.getBlockID()]; + blockOil = fluidOil.getBlock(); } if (blockOil != null) { @@ -191,60 +173,57 @@ public class BuildCraftEnergy { BlockSpring.EnumSpring.OIL.liquidBlock = blockOil; } - if (fluidFuel.getBlockID() == -1) { - if (blockFuelId > 0) { - blockFuel = new BlockBuildcraftFluid(blockFuelId, fluidFuel, Material.water).setFlammable(true).setFlammability(5).setParticleColor(0.7F, 0.7F, 0.0F); - blockFuel.setUnlocalizedName("blockFuel"); - CoreProxy.proxy.addName(blockFuel, "Fuel"); - CoreProxy.proxy.registerBlock(blockFuel); - fluidFuel.setBlockID(blockFuel); - } + if (fluidFuel.getBlock() == null) { + blockFuel = new BlockBuildcraftFluid(fluidFuel, Material.water).setFlammable(true).setFlammability(5).setParticleColor(0.7F, 0.7F, 0.0F); + blockFuel.setBlockName("blockFuel"); + CoreProxy.proxy.addName(blockFuel, "Fuel"); + CoreProxy.proxy.registerBlock(blockFuel); + fluidFuel.setBlock(blockFuel); } else { - blockFuel = Block.blocksList[fluidFuel.getBlockID()]; + blockFuel = fluidFuel.getBlock(); } - if (fluidRedPlasma.getBlockID() == -1) { - if (blockRedplasmaId > 0) { - blockRedPlasma = new BlockBuildcraftFluid(blockRedplasmaId, fluidRedPlasma, Material.water).setFlammable(false).setParticleColor(0.9F, 0, 0); - blockRedPlasma.setUnlocalizedName("blockRedPlasma"); - CoreProxy.proxy.addName(blockRedPlasma, "Red Plasma"); - CoreProxy.proxy.registerBlock(blockRedPlasma); - fluidRedPlasma.setBlockID(blockRedPlasma); - } + if (fluidRedPlasma.getBlock() == null) { + blockRedPlasma = new BlockBuildcraftFluid(fluidRedPlasma, Material.water).setFlammable(false).setParticleColor(0.9F, 0, 0); + blockRedPlasma.setBlockName("blockRedPlasma"); + CoreProxy.proxy.addName(blockRedPlasma, "Red Plasma"); + CoreProxy.proxy.registerBlock(blockRedPlasma); + fluidRedPlasma.setBlock(blockRedPlasma); } else { - blockRedPlasma = Block.blocksList[fluidRedPlasma.getBlockID()]; + blockRedPlasma = fluidRedPlasma.getBlock(); } // Buckets - if (blockOil != null && bucketOilId > 0) { - bucketOil = new ItemBucketBuildcraft(bucketOilId, blockOil.blockID); - bucketOil.setUnlocalizedName("bucketOil").setContainerItem(Item.bucketEmpty); + if (blockOil != null) { + bucketOil = new ItemBucketBuildcraft(blockOil); + bucketOil.setUnlocalizedName("bucketOil").setContainerItem(Items.bucket); LanguageRegistry.addName(bucketOil, "Oil Bucket"); CoreProxy.proxy.registerItem(bucketOil); - FluidContainerRegistry.registerFluidContainer(FluidRegistry.getFluidStack("oil", FluidContainerRegistry.BUCKET_VOLUME), new ItemStack(bucketOil), new ItemStack(Item.bucketEmpty)); + FluidContainerRegistry.registerFluidContainer(FluidRegistry.getFluidStack("oil", FluidContainerRegistry.BUCKET_VOLUME), new ItemStack(bucketOil), new ItemStack(Items.bucket)); } - if (blockFuel != null && bucketFuelId > 0) { - bucketFuel = new ItemBucketBuildcraft(bucketFuelId, blockFuel.blockID); - bucketFuel.setUnlocalizedName("bucketFuel").setContainerItem(Item.bucketEmpty); + if (blockFuel != null) { + bucketFuel = new ItemBucketBuildcraft(blockFuel); + bucketFuel.setUnlocalizedName("bucketFuel").setContainerItem(Items.bucket); LanguageRegistry.addName(bucketFuel, "Fuel Bucket"); CoreProxy.proxy.registerItem(bucketFuel); - FluidContainerRegistry.registerFluidContainer(FluidRegistry.getFluidStack("fuel", FluidContainerRegistry.BUCKET_VOLUME), new ItemStack(bucketFuel), new ItemStack(Item.bucketEmpty)); + FluidContainerRegistry.registerFluidContainer(FluidRegistry.getFluidStack("fuel", FluidContainerRegistry.BUCKET_VOLUME), new ItemStack(bucketFuel), new ItemStack(Items.bucket)); } - if (blockRedPlasma != null && bucketRedPlasmaId > 0) { - bucketRedPlasma = new ItemBucketBuildcraft(bucketRedPlasmaId, blockRedPlasma.blockID); - bucketRedPlasma.setUnlocalizedName("bucketRedPlasma").setContainerItem(Item.bucketEmpty); + if (blockRedPlasma != null) { + bucketRedPlasma = new ItemBucketBuildcraft(blockRedPlasma); + bucketRedPlasma.setUnlocalizedName("bucketRedPlasma").setContainerItem(Items.bucket); LanguageRegistry.addName(bucketRedPlasma, "Red Plasma Bucket"); CoreProxy.proxy.registerItem(bucketRedPlasma); - FluidContainerRegistry.registerFluidContainer(FluidRegistry.getFluidStack("redplasma", FluidContainerRegistry.BUCKET_VOLUME), new ItemStack(bucketRedPlasma), new ItemStack(Item.bucketEmpty)); + FluidContainerRegistry.registerFluidContainer(FluidRegistry.getFluidStack("redplasma", FluidContainerRegistry.BUCKET_VOLUME), new ItemStack(bucketRedPlasma), new ItemStack(Items.bucket)); } - BucketHandler.INSTANCE.buckets.put(blockOil, bucketOil); - BucketHandler.INSTANCE.buckets.put(blockFuel, bucketFuel); - BucketHandler.INSTANCE.buckets.put(blockRedPlasma, bucketRedPlasma); - MinecraftForge.EVENT_BUS.register(BucketHandler.INSTANCE); + // TODO: Are these still really necessary? If not, remove the + // BucketHandler class as well. + //BucketHandler.INSTANCE.buckets.put(blockOil, bucketOil); + //BucketHandler.INSTANCE.buckets.put(blockFuel, bucketFuel); + //MinecraftForge.EVENT_BUS.register(BucketHandler.INSTANCE); BuildcraftRecipes.refinery.addRecipe(new FluidStack(fluidOil, 1), new FluidStack(fluidFuel, 1), 12, 1); @@ -255,19 +234,17 @@ public class BuildCraftEnergy { // Iron Engine Coolants IronEngineCoolant.addCoolant(FluidRegistry.getFluid("water"), 0.0023F); - IronEngineCoolant.addCoolant(Block.ice.blockID, 0, FluidRegistry.getFluidStack("water", FluidContainerRegistry.BUCKET_VOLUME * 2)); + IronEngineCoolant.addCoolant(Blocks.ice, 0, FluidRegistry.getFluidStack("water", FluidContainerRegistry.BUCKET_VOLUME * 2)); // Receiver / emitter - Property emitterId = BuildCraftCore.mainConfiguration.getBlock("energyEmitter.id", DefaultProps.EMITTER_ID); - emitterBlock = new BlockEnergyEmitter (emitterId.getInt()); - CoreProxy.proxy.registerBlock(emitterBlock.setUnlocalizedName("energyEmitterBlock")); + emitterBlock = new BlockEnergyEmitter (); + CoreProxy.proxy.registerBlock(emitterBlock.setBlockName("energyEmitterBlock")); CoreProxy.proxy.addName(emitterBlock, "Energy Emitter"); CoreProxy.proxy.registerTileEntity(TileEnergyEmitter.class, "net.minecraft.src.builders.TileEnergyEmitter"); - Property receiverId = BuildCraftCore.mainConfiguration.getBlock("energyReceiver.id", DefaultProps.RECEIVER_ID); - receiverBlock = new BlockEnergyReceiver (receiverId.getInt()); - CoreProxy.proxy.registerBlock(receiverBlock.setUnlocalizedName("energyReceiverBlock")); + receiverBlock = new BlockEnergyReceiver (); + CoreProxy.proxy.registerBlock(receiverBlock.setBlockName("energyReceiverBlock")); CoreProxy.proxy.addName(receiverBlock, "Energy Receiver"); CoreProxy.proxy.registerTileEntity(TileEnergyReceiver.class, "net.minecraft.src.builders.TileEnergyReceiver"); @@ -276,9 +253,12 @@ public class BuildCraftEnergy { @EventHandler public void init(FMLInitializationEvent evt) { - NetworkRegistry.instance().registerGuiHandler(instance, new GuiHandler()); + channels = NetworkRegistry.INSTANCE.newChannel + (DefaultProps.NET_CHANNEL_NAME + "-ENERGY", new PacketHandlerTransport()); + + NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler()); - new BptBlockEngine(engineBlock.blockID); + //new BptBlockEngine(engineBlock.blockID); if (BuildCraftCore.loadDefaultRecipes) { loadRecipes(); @@ -295,10 +275,10 @@ public class BuildCraftEnergy { } } - @ForgeSubscribe + @SubscribeEvent @SideOnly(Side.CLIENT) public void textureHook(TextureStitchEvent.Post event) { - if (event.map.textureType == 0) { + if (event.map.getTextureType() == 0) { buildcraftFluidOil.setIcons(blockOil.getBlockTextureFromSide(1), blockOil.getBlockTextureFromSide(2)); buildcraftFluidFuel.setIcons(blockFuel.getBlockTextureFromSide(1), blockFuel.getBlockTextureFromSide(2)); buildcraftFluidRedPlasma.setIcons(blockRedPlasma.getBlockTextureFromSide(1), blockRedPlasma.getBlockTextureFromSide(2)); @@ -307,116 +287,16 @@ public class BuildCraftEnergy { public static void loadRecipes() { CoreProxy.proxy.addCraftingRecipe(new ItemStack(engineBlock, 1, 0), - new Object[]{"www", " g ", "GpG", 'w', "plankWood", 'g', Block.glass, 'G', - BuildCraftCore.woodenGearItem, 'p', Block.pistonBase}); + new Object[]{"www", " g ", "GpG", 'w', "plankWood", 'g', Blocks.glass, 'G', + BuildCraftCore.woodenGearItem, 'p', Blocks.piston}); CoreProxy.proxy.addCraftingRecipe(new ItemStack(engineBlock, 1, 1), new Object[]{"www", " g ", "GpG", 'w', "cobblestone", - 'g', Block.glass, 'G', BuildCraftCore.stoneGearItem, 'p', Block.pistonBase}); - CoreProxy.proxy.addCraftingRecipe(new ItemStack(engineBlock, 1, 2), new Object[]{"www", " g ", "GpG", 'w', Item.ingotIron, - 'g', Block.glass, 'G', BuildCraftCore.ironGearItem, 'p', Block.pistonBase}); + 'g', Blocks.glass, 'G', BuildCraftCore.stoneGearItem, 'p', Blocks.piston}); + CoreProxy.proxy.addCraftingRecipe(new ItemStack(engineBlock, 1, 2), new Object[]{"www", " g ", "GpG", 'w', Items.iron_ingot, + 'g', Blocks.glass, 'G', BuildCraftCore.ironGearItem, 'p', Blocks.piston}); } @EventHandler public void processIMCRequests(FMLInterModComms.IMCEvent event) { InterModComms.processIMC(event); } - // public static int createPollution (World world, int i, int j, int k, int - // saturation) { - // int remainingSaturation = saturation; - // - // if (world.rand.nextFloat() > 0.7) { - // // Try to place an item on the sides - // - // LinkedList orientations = new LinkedList(); - // - // for (int id = -1; id <= 1; id += 2) { - // for (int kd = -1; kd <= 1; kd += 2) { - // if (canPollute(world, i + id, j, k + kd)) { - // orientations.add(new BlockIndex(i + id, j, k + kd)); - // } - // } - // } - // - // if (orientations.size() > 0) { - // BlockIndex toPollute = - // orientations.get(world.rand.nextInt(orientations.size())); - // - // int x = toPollute.i; - // int y = toPollute.j; - // int z = toPollute.k; - // - // if (world.getBlockId(x, y, z) == 0) { - // world.setBlock(x, y, z, - // BuildCraftEnergy.pollution.blockID, - // saturation * 16 / 100); - // - // saturationStored.put(new BlockIndex(x, y, z), new Integer( - // saturation)); - // remainingSaturation = 0; - // } else if (world.getBlockTileEntity(z, y, z) instanceof TilePollution) { - // remainingSaturation = updateExitingPollution(world, x, y, z, saturation); - // } - // } - // } - // - // if (remainingSaturation > 0) { - // if (world.getBlockId(i, j + 1, k) == 0) { - // if (j + 1 < 128) { - // world.setBlock(i, j + 1, k, - // BuildCraftEnergy.pollution.blockID, - // saturation * 16 / 100); - // saturationStored.put(new BlockIndex(i, j + 1, k), - // new Integer(remainingSaturation)); - // } - // - // remainingSaturation = 0; - // } else if (world.getBlockTileEntity(i, j + 1, k) instanceof - // TilePollution) { - // remainingSaturation = updateExitingPollution(world, i, j + 1, - // k, remainingSaturation); - // } - // } - // - // if (remainingSaturation == 0) { - // System.out.println ("EXIT 1"); - // return 0; - // } else if (remainingSaturation == saturation) { - // System.out.println ("EXIT 2"); - // return saturation; - // } else { - // System.out.println ("EXIT 3"); - // return createPollution (world, i, j, k, remainingSaturation); - // } - // } - // - // private static int updateExitingPollution (World world, int i, int j, int - // k, int saturation) { - // int remainingSaturation = saturation; - // - // TilePollution tile = (TilePollution) world.getBlockTileEntity( - // i, j, k); - // - // if (tile.saturation + saturation <= 100) { - // remainingSaturation = 0; - // tile.saturation += saturation; - // } else { - // remainingSaturation = (tile.saturation + saturation) - 100; - // tile.saturation += saturation - remainingSaturation; - // } - // - // world.setBlockMetadata(i, j, k, saturation * 16 / 100); - // world.markBlockNeedsUpdate(i, j, k); - // - // return remainingSaturation; - // } - // - // private static boolean canPollute (World world, int i, int j, int k) { - // if (world.getBlockId(i, j, k) == 0) { - // return true; - // } else { - // TileEntity tile = world.getBlockTileEntity(i, j, k); - // - // return (tile instanceof TilePollution && ((TilePollution) - // tile).saturation < 100); - // } - // } } diff --git a/common/buildcraft/BuildCraftFactory.java b/common/buildcraft/BuildCraftFactory.java index fc7e259c..7abb7d6c 100644 --- a/common/buildcraft/BuildCraftFactory.java +++ b/common/buildcraft/BuildCraftFactory.java @@ -11,6 +11,7 @@ package buildcraft; import buildcraft.core.DefaultProps; import buildcraft.core.InterModComms; import buildcraft.core.Version; +import buildcraft.core.network.PacketHandler; import buildcraft.core.proxy.CoreProxy; import buildcraft.core.utils.ConfigUtils; import buildcraft.factory.BlockAutoWorkbench; @@ -40,7 +41,9 @@ import buildcraft.factory.TileQuarry; import buildcraft.factory.TileRefinery; import buildcraft.factory.TileTank; import buildcraft.factory.network.PacketHandlerFactory; + import com.google.common.collect.Lists; + import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.Instance; @@ -48,27 +51,29 @@ import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLInterModComms; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; -import cpw.mods.fml.common.network.NetworkMod; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; + import java.util.List; + import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraftforge.client.event.TextureStitchEvent; -import net.minecraftforge.common.Configuration; +import net.minecraftforge.common.config.Configuration; import net.minecraftforge.common.ForgeChunkManager; import net.minecraftforge.common.ForgeChunkManager.Ticket; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.common.Property; -import net.minecraftforge.event.ForgeSubscribe; +import net.minecraftforge.common.config.Property; @Mod(name = "BuildCraft Factory", version = Version.VERSION, useMetadata = false, modid = "BuildCraft|Factory", dependencies = DefaultProps.DEPENDENCY_CORE) -@NetworkMod(channels = {DefaultProps.NET_CHANNEL_NAME}, packetHandler = PacketHandlerFactory.class, clientSideRequired = true, serverSideRequired = true) -public class BuildCraftFactory { +public class BuildCraftFactory extends BuildCraftMod { public static final int MINING_MJ_COST_PER_BLOCK = 64; public static BlockQuarry quarryBlock; @@ -103,7 +108,7 @@ public class BuildCraftFactory { int quarryX = ticket.getModData().getInteger("quarryX"); int quarryY = ticket.getModData().getInteger("quarryY"); int quarryZ = ticket.getModData().getInteger("quarryZ"); - TileQuarry tq = (TileQuarry) world.getBlockTileEntity(quarryX, quarryY, quarryZ); + TileQuarry tq = (TileQuarry) world.getTileEntity(quarryX, quarryY, quarryZ); tq.forceChunkLoading(ticket); } @@ -117,8 +122,8 @@ public class BuildCraftFactory { int quarryY = ticket.getModData().getInteger("quarryY"); int quarryZ = ticket.getModData().getInteger("quarryZ"); - int blId = world.getBlockId(quarryX, quarryY, quarryZ); - if (blId == quarryBlock.blockID) { + Block block = world.getBlock(quarryX, quarryY, quarryZ); + if (block == quarryBlock) { validTickets.add(ticket); } } @@ -128,7 +133,7 @@ public class BuildCraftFactory { @EventHandler public void load(FMLInitializationEvent evt) { - NetworkRegistry.instance().registerGuiHandler(instance, new GuiHandler()); + NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler()); // EntityRegistry.registerModEntity(EntityMechanicalArm.class, "bcMechanicalArm", EntityIds.MECHANICAL_ARM, instance, 50, 1, true); @@ -143,10 +148,10 @@ public class BuildCraftFactory { FactoryProxy.proxy.initializeTileEntities(); - new BptBlockAutoWorkbench(autoWorkbenchBlock.blockID); - new BptBlockFrame(frameBlock.blockID); - new BptBlockRefinery(refineryBlock.blockID); - new BptBlockTank(tankBlock.blockID); + //new BptBlockAutoWorkbench(autoWorkbenchBlock.blockID); + //new BptBlockFrame(frameBlock.blockID); + //new BptBlockRefinery(refineryBlock.blockID); + //new BptBlockTank(tankBlock.blockID); if (BuildCraftCore.loadDefaultRecipes) { loadRecipes(); @@ -155,6 +160,9 @@ public class BuildCraftFactory { @EventHandler public void initialize(FMLPreInitializationEvent evt) { + channels = NetworkRegistry.INSTANCE.newChannel + (DefaultProps.NET_CHANNEL_NAME + "-FACTORY", new PacketHandlerFactory()); + ConfigUtils genCat = new ConfigUtils(BuildCraftCore.mainConfiguration, Configuration.CATEGORY_GENERAL); allowMining = genCat.get("mining.enabled", true, "disables the recipes for automated mining machines"); @@ -168,72 +176,52 @@ public class BuildCraftFactory { + "Entries are comma seperated, banned fluids have precedence over allowed ones." + "Default is \"+/*/*,+/-1/Lava\" - the second redundant entry (\"+/-1/lava\") is there to show the format."; pumpDimensionList = new PumpDimensionList(pumpList.getString()); - - int miningWellId = BuildCraftCore.mainConfiguration.getBlock("miningWell.id", DefaultProps.MINING_WELL_ID).getInt(DefaultProps.MINING_WELL_ID); - int plainPipeId = BuildCraftCore.mainConfiguration.getBlock("drill.id", DefaultProps.DRILL_ID).getInt(DefaultProps.DRILL_ID); - int autoWorkbenchId = BuildCraftCore.mainConfiguration.getBlock("autoWorkbench.id", DefaultProps.AUTO_WORKBENCH_ID).getInt(DefaultProps.AUTO_WORKBENCH_ID); - int frameId = BuildCraftCore.mainConfiguration.getBlock("frame.id", DefaultProps.FRAME_ID).getInt(DefaultProps.FRAME_ID); - int quarryId = BuildCraftCore.mainConfiguration.getBlock("quarry.id", DefaultProps.QUARRY_ID).getInt(DefaultProps.QUARRY_ID); - int pumpId = BuildCraftCore.mainConfiguration.getBlock("pump.id", DefaultProps.PUMP_ID).getInt(DefaultProps.PUMP_ID); - int floodGateId = BuildCraftCore.mainConfiguration.getBlock("floodGate.id", DefaultProps.FLOOD_GATE_ID).getInt(DefaultProps.FLOOD_GATE_ID); - int tankId = BuildCraftCore.mainConfiguration.getBlock("tank.id", DefaultProps.TANK_ID).getInt(DefaultProps.TANK_ID); - int refineryId = BuildCraftCore.mainConfiguration.getBlock("refinery.id", DefaultProps.REFINERY_ID).getInt(DefaultProps.REFINERY_ID); - int hopperId = BuildCraftCore.mainConfiguration.getBlock("hopper.id", DefaultProps.HOPPER_ID).getInt(DefaultProps.HOPPER_ID); - + if (BuildCraftCore.mainConfiguration.hasChanged()) { BuildCraftCore.mainConfiguration.save(); } - if (miningWellId > 0) { - miningWellBlock = new BlockMiningWell(miningWellId); - CoreProxy.proxy.registerBlock(miningWellBlock.setUnlocalizedName("miningWellBlock")); - CoreProxy.proxy.addName(miningWellBlock, "Mining Well"); - } - if (plainPipeId > 0) { - plainPipeBlock = new BlockPlainPipe(plainPipeId); - CoreProxy.proxy.registerBlock(plainPipeBlock.setUnlocalizedName("plainPipeBlock")); - CoreProxy.proxy.addName(plainPipeBlock, "Mining Pipe"); - } - if (autoWorkbenchId > 0) { - autoWorkbenchBlock = new BlockAutoWorkbench(autoWorkbenchId); - CoreProxy.proxy.registerBlock(autoWorkbenchBlock.setUnlocalizedName("autoWorkbenchBlock")); - CoreProxy.proxy.addName(autoWorkbenchBlock, "Automatic Crafting Table"); - } - if (frameId > 0) { - frameBlock = new BlockFrame(frameId); - CoreProxy.proxy.registerBlock(frameBlock.setUnlocalizedName("frameBlock")); - CoreProxy.proxy.addName(frameBlock, "Frame"); - } - if (quarryId > 0) { - quarryBlock = new BlockQuarry(quarryId); - CoreProxy.proxy.registerBlock(quarryBlock.setUnlocalizedName("machineBlock")); - CoreProxy.proxy.addName(quarryBlock, "Quarry"); - } - if (tankId > 0) { - tankBlock = new BlockTank(tankId); - CoreProxy.proxy.registerBlock(tankBlock.setUnlocalizedName("tankBlock")); - CoreProxy.proxy.addName(tankBlock, "Tank"); - } - if (pumpId > 0) { - pumpBlock = new BlockPump(pumpId); - CoreProxy.proxy.registerBlock(pumpBlock.setUnlocalizedName("pumpBlock")); - CoreProxy.proxy.addName(pumpBlock, "Pump"); - } - if (floodGateId > 0) { - floodGateBlock = new BlockFloodGate(floodGateId); - CoreProxy.proxy.registerBlock(floodGateBlock.setUnlocalizedName("floodGateBlock")); - CoreProxy.proxy.addName(floodGateBlock, "Flood Gate"); - } - if (refineryId > 0) { - refineryBlock = new BlockRefinery(refineryId); - CoreProxy.proxy.registerBlock(refineryBlock.setUnlocalizedName("refineryBlock")); - CoreProxy.proxy.addName(refineryBlock, "Refinery"); - } - if (hopperId > 0) { - hopperBlock = new BlockHopper(hopperId); - CoreProxy.proxy.registerBlock(hopperBlock.setUnlocalizedName("blockHopper")); - CoreProxy.proxy.addName(hopperBlock, "Hopper"); - } + + miningWellBlock = new BlockMiningWell(); + CoreProxy.proxy.registerBlock(miningWellBlock.setBlockName("miningWellBlock")); + CoreProxy.proxy.addName(miningWellBlock, "Mining Well"); + + plainPipeBlock = new BlockPlainPipe(); + CoreProxy.proxy.registerBlock(plainPipeBlock.setBlockName("plainPipeBlock")); + CoreProxy.proxy.addName(plainPipeBlock, "Mining Pipe"); + + autoWorkbenchBlock = new BlockAutoWorkbench(); + CoreProxy.proxy.registerBlock(autoWorkbenchBlock.setBlockName("autoWorkbenchBlock")); + CoreProxy.proxy.addName(autoWorkbenchBlock, "Automatic Crafting Table"); + + frameBlock = new BlockFrame(); + CoreProxy.proxy.registerBlock(frameBlock.setBlockName("frameBlock")); + CoreProxy.proxy.addName(frameBlock, "Frame"); + + quarryBlock = new BlockQuarry(); + CoreProxy.proxy.registerBlock(quarryBlock.setBlockName("machineBlock")); + CoreProxy.proxy.addName(quarryBlock, "Quarry"); + + tankBlock = new BlockTank(); + CoreProxy.proxy.registerBlock(tankBlock.setBlockName("tankBlock")); + CoreProxy.proxy.addName(tankBlock, "Tank"); + + pumpBlock = new BlockPump(); + CoreProxy.proxy.registerBlock(pumpBlock.setBlockName("pumpBlock")); + CoreProxy.proxy.addName(pumpBlock, "Pump"); + + floodGateBlock = new BlockFloodGate(); + CoreProxy.proxy.registerBlock(floodGateBlock.setBlockName("floodGateBlock")); + CoreProxy.proxy.addName(floodGateBlock, "Flood Gate"); + + refineryBlock = new BlockRefinery(); + CoreProxy.proxy.registerBlock(refineryBlock.setBlockName("refineryBlock")); + CoreProxy.proxy.addName(refineryBlock, "Refinery"); + + hopperBlock = new BlockHopper(); + CoreProxy.proxy.registerBlock(hopperBlock.setBlockName("blockHopper")); + CoreProxy.proxy.addName(hopperBlock, "Hopper"); + FactoryProxy.proxy.initializeEntityRenders(); if (BuildCraftCore.mainConfiguration.hasChanged()) { @@ -251,10 +239,10 @@ public class BuildCraftFactory { "ipi", "igi", "iPi", - 'p', Item.redstone, - 'i', Item.ingotIron, + 'p', Items.redstone, + 'i', Items.iron_ingot, 'g', BuildCraftCore.ironGearItem, - 'P', Item.pickaxeIron); + 'P', Items.iron_pickaxe); if (quarryBlock != null) CoreProxy.proxy.addCraftingRecipe( @@ -263,16 +251,16 @@ public class BuildCraftFactory { "gig", "dDd", 'i', BuildCraftCore.ironGearItem, - 'p', Item.redstone, + 'p', Items.redstone, 'g', BuildCraftCore.goldGearItem, 'd', BuildCraftCore.diamondGearItem, - 'D', Item.pickaxeDiamond); + 'D', Items.diamond_pickaxe); if (pumpBlock != null && miningWellBlock != null) CoreProxy.proxy.addCraftingRecipe(new ItemStack(pumpBlock), "T", "W", - 'T', tankBlock != null ? tankBlock : Block.glass, + 'T', tankBlock != null ? tankBlock : Blocks.glass, 'W', miningWellBlock); } @@ -282,9 +270,9 @@ public class BuildCraftFactory { "iri", "iTi", "gpg", - 'r', Item.redstone, - 'i', Item.ingotIron, - 'T', tankBlock != null ? tankBlock : Block.glass, + 'r', Items.redstone, + 'i', Items.iron_ingot, + 'T', tankBlock != null ? tankBlock : Blocks.glass, 'g', BuildCraftCore.ironGearItem, 'p', BuildCraftTransport.pipeFluidsGold); } @@ -294,7 +282,7 @@ public class BuildCraftFactory { " g ", "gwg", " g ", - 'w', Block.workbench, + 'w', Blocks.crafting_table, 'g', BuildCraftCore.woodenGearItem); @@ -303,23 +291,23 @@ public class BuildCraftFactory { "ggg", "g g", "ggg", - 'g', Block.glass); + 'g', Blocks.glass); if (refineryBlock != null) CoreProxy.proxy.addCraftingRecipe(new ItemStack(refineryBlock), "RTR", "TGT", - 'T', tankBlock != null ? tankBlock : Block.glass, + 'T', tankBlock != null ? tankBlock : Blocks.glass, 'G', BuildCraftCore.diamondGearItem, - 'R', Block.torchRedstoneActive); + 'R', Blocks.redstone_torch); if (hopperBlock != null) CoreProxy.proxy.addCraftingRecipe(new ItemStack(hopperBlock), "ICI", "IGI", " I ", - 'I', Item.ingotIron, - 'C', Block.chest, + 'I', Items.iron_ingot, + 'C', Blocks.chest, 'G', BuildCraftCore.stoneGearItem); if (floodGateBlock != null) @@ -327,10 +315,10 @@ public class BuildCraftFactory { "IGI", "FTF", "IFI", - 'I', Item.ingotIron, - 'T', tankBlock != null ? tankBlock : Block.glass, + 'I', Items.iron_ingot, + 'T', tankBlock != null ? tankBlock : Blocks.glass, 'G', BuildCraftCore.ironGearItem, - 'F', new ItemStack(Block.fenceIron)); + 'F', new ItemStack(Blocks.iron_bars)); } @EventHandler @@ -338,10 +326,10 @@ public class BuildCraftFactory { InterModComms.processIMC(event); } - @ForgeSubscribe + @SubscribeEvent @SideOnly(Side.CLIENT) public void loadTextures(TextureStitchEvent.Pre evt) { - if (evt.map.textureType == 0) { + if (evt.map.getTextureType() == 0) { TextureMap terrainTextures = evt.map; FactoryProxyClient.pumpTexture = terrainTextures.registerIcon("buildcraft:pump_tube"); FactoryProxyClient.drillTexture = terrainTextures.registerIcon("buildcraft:blockDrillTexture"); diff --git a/common/buildcraft/BuildCraftMod.java b/common/buildcraft/BuildCraftMod.java new file mode 100755 index 00000000..4612a1f2 --- /dev/null +++ b/common/buildcraft/BuildCraftMod.java @@ -0,0 +1,46 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ +package buildcraft; + +import java.util.EnumMap; + +import cpw.mods.fml.common.network.FMLEmbeddedChannel; +import cpw.mods.fml.common.network.FMLOutboundHandler; +import cpw.mods.fml.common.network.FMLOutboundHandler.OutboundTarget; +import cpw.mods.fml.relauncher.Side; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.network.Packet; +import net.minecraft.world.World; +import buildcraft.core.network.BuildCraftPacket; + +public class BuildCraftMod { + public EnumMap channels; + + public void sendToPlayers(Packet packet, World world, int x, int y, int z, int maxDistance) { + channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.ALL); + channels.get(Side.SERVER).writeOutbound(packet); + } + + public void sendToPlayers(BuildCraftPacket packet, World world, int x, int y, int z, int maxDistance) { + channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.ALL); + channels.get(Side.SERVER).writeOutbound(packet); + } + + public void sendToPlayer(EntityPlayer entityplayer, BuildCraftPacket packet) { + channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.PLAYER); + channels.get(Side.SERVER).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(entityplayer); + channels.get(Side.SERVER).writeOutbound(packet); + } + + public void sendToServer(BuildCraftPacket packet) { + channels.get(Side.CLIENT).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(OutboundTarget.TOSERVER); + channels.get(Side.CLIENT).writeOutbound(packet); + } +} \ No newline at end of file diff --git a/common/buildcraft/BuildCraftSilicon.java b/common/buildcraft/BuildCraftSilicon.java index 0c4f5097..b593942f 100644 --- a/common/buildcraft/BuildCraftSilicon.java +++ b/common/buildcraft/BuildCraftSilicon.java @@ -17,6 +17,7 @@ import buildcraft.core.InterModComms; import buildcraft.silicon.ItemRedstoneChipset; import buildcraft.silicon.ItemRedstoneChipset.Chipset; import buildcraft.core.Version; +import buildcraft.core.network.PacketHandler; import buildcraft.core.proxy.CoreProxy; import buildcraft.silicon.BlockLaser; import buildcraft.silicon.BlockLaserTable; @@ -42,20 +43,22 @@ import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLInterModComms; import cpw.mods.fml.common.event.FMLPreInitializationEvent; -import cpw.mods.fml.common.network.NetworkMod; import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; + import java.util.ArrayList; import java.util.EnumSet; import java.util.List; + import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraftforge.common.Property; +import net.minecraftforge.common.config.Property; @Mod(name = "BuildCraft Silicon", version = Version.VERSION, useMetadata = false, modid = "BuildCraft|Silicon", dependencies = DefaultProps.DEPENDENCY_TRANSPORT) -@NetworkMod(channels = {DefaultProps.NET_CHANNEL_NAME}, packetHandler = PacketHandlerSilicon.class, clientSideRequired = true, serverSideRequired = true) -public class BuildCraftSilicon { +public class BuildCraftSilicon extends BuildCraftMod { public static ItemRedstoneChipset redstoneChipset; public static BlockLaser laserBlock; @@ -64,27 +67,21 @@ public class BuildCraftSilicon { public static BuildCraftSilicon instance; @EventHandler - public void preInit(FMLPreInitializationEvent evt) { - Property laserId = BuildCraftCore.mainConfiguration.getBlock("laser.id", DefaultProps.LASER_ID); - - Property assemblyTableId = BuildCraftCore.mainConfiguration.getBlock("assemblyTable.id", DefaultProps.ASSEMBLY_TABLE_ID); - - Property redstoneChipsetId = BuildCraftCore.mainConfiguration.getItem("redstoneChipset.id", DefaultProps.REDSTONE_CHIPSET); - + public void preInit(FMLPreInitializationEvent evt) { BuildCraftCore.mainConfiguration.save(); - laserBlock = new BlockLaser(laserId.getInt()); - CoreProxy.proxy.addName(laserBlock.setUnlocalizedName("laserBlock"), "Laser"); + laserBlock = new BlockLaser(); + CoreProxy.proxy.addName(laserBlock.setBlockName("laserBlock"), "Laser"); CoreProxy.proxy.registerBlock(laserBlock); - assemblyTableBlock = new BlockLaserTable(assemblyTableId.getInt()); + assemblyTableBlock = new BlockLaserTable(); CoreProxy.proxy.registerBlock(assemblyTableBlock, ItemLaserTable.class); LanguageRegistry.addName(new ItemStack(assemblyTableBlock, 0, 0), "Assembly Table"); LanguageRegistry.addName(new ItemStack(assemblyTableBlock, 0, 1), "Advanced Crafting Table"); LanguageRegistry.addName(new ItemStack(assemblyTableBlock, 0, 2), "Integration Table"); - redstoneChipset = new ItemRedstoneChipset(redstoneChipsetId.getInt()); + redstoneChipset = new ItemRedstoneChipset(); redstoneChipset.setUnlocalizedName("redstoneChipset"); CoreProxy.proxy.registerItem(redstoneChipset); redstoneChipset.registerItemStacks(); @@ -92,14 +89,17 @@ public class BuildCraftSilicon { @EventHandler public void init(FMLInitializationEvent evt) { - NetworkRegistry.instance().registerGuiHandler(instance, new GuiHandler()); + channels = NetworkRegistry.INSTANCE.newChannel + (DefaultProps.NET_CHANNEL_NAME + "-SILICON", new PacketHandlerSilicon()); + + NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler()); CoreProxy.proxy.registerTileEntity(TileLaser.class, "net.minecraft.src.buildcraft.factory.TileLaser"); CoreProxy.proxy.registerTileEntity(TileAssemblyTable.class, "net.minecraft.src.buildcraft.factory.TileAssemblyTable"); CoreProxy.proxy.registerTileEntity(TileAdvancedCraftingTable.class, "net.minecraft.src.buildcraft.factory.TileAssemblyAdvancedWorkbench"); CoreProxy.proxy.registerTileEntity(TileIntegrationTable.class, "net.minecraft.src.buildcraft.factory.TileIntegrationTable"); - new BptBlockRotateMeta(laserBlock.blockID, new int[]{2, 5, 3, 4}, true); - new BptBlockInventory(assemblyTableBlock.blockID); + //new BptBlockRotateMeta(laserBlock.blockID, new int[]{2, 5, 3, 4}, true); + //new BptBlockInventory(assemblyTableBlock.blockID); if (BuildCraftCore.loadDefaultRecipes) { loadRecipes(); @@ -115,51 +115,51 @@ public class BuildCraftSilicon { "ORR", "DDR", "ORR", - 'O', Block.obsidian, - 'R', Item.redstone, - 'D', Item.diamond); + 'O', Blocks.obsidian, + 'R', Items.redstone, + 'D', Items.diamond); CoreProxy.proxy.addCraftingRecipe(new ItemStack(assemblyTableBlock, 1, 0), "ORO", "ODO", "OGO", - 'O', Block.obsidian, - 'R', Item.redstone, - 'D', Item.diamond, + 'O', Blocks.obsidian, + 'R', Items.redstone, + 'D', Items.diamond, 'G', BuildCraftCore.diamondGearItem); CoreProxy.proxy.addCraftingRecipe(new ItemStack(assemblyTableBlock, 1, 1), "OWO", "OCO", "ORO", - 'O', Block.obsidian, - 'W', Block.workbench, - 'C', Block.chest, + 'O', Blocks.obsidian, + 'W', Blocks.crafting_table, + 'C', Blocks.chest, 'R', new ItemStack(redstoneChipset, 1, 0)); CoreProxy.proxy.addCraftingRecipe(new ItemStack(assemblyTableBlock, 1, 2), "ORO", "OCO", "OGO", - 'O', Block.obsidian, - 'R', Item.redstone, + 'O', Blocks.obsidian, + 'R', Items.redstone, 'C', new ItemStack(redstoneChipset, 1, 0), 'G', BuildCraftCore.diamondGearItem); // PIPE WIRE - BuildcraftRecipes.assemblyTable.addRecipe(500, PipeWire.RED.getStack(8), "dyeRed", 1, Item.redstone, Item.ingotIron); - BuildcraftRecipes.assemblyTable.addRecipe(500, PipeWire.BLUE.getStack(8), "dyeBlue", 1, Item.redstone, Item.ingotIron); - BuildcraftRecipes.assemblyTable.addRecipe(500, PipeWire.GREEN.getStack(8), "dyeGreen", 1, Item.redstone, Item.ingotIron); - BuildcraftRecipes.assemblyTable.addRecipe(500, PipeWire.YELLOW.getStack(8), "dyeYellow", 1, Item.redstone, Item.ingotIron); + BuildcraftRecipes.assemblyTable.addRecipe(500, PipeWire.RED.getStack(8), "dyeRed", 1, Items.redstone, Items.iron_ingot); + BuildcraftRecipes.assemblyTable.addRecipe(500, PipeWire.BLUE.getStack(8), "dyeBlue", 1, Items.redstone, Items.iron_ingot); + BuildcraftRecipes.assemblyTable.addRecipe(500, PipeWire.GREEN.getStack(8), "dyeGreen", 1, Items.redstone, Items.iron_ingot); + BuildcraftRecipes.assemblyTable.addRecipe(500, PipeWire.YELLOW.getStack(8), "dyeYellow", 1, Items.redstone, Items.iron_ingot); // CHIPSETS - BuildcraftRecipes.assemblyTable.addRecipe(10000, Chipset.RED.getStack(), Item.redstone); - BuildcraftRecipes.assemblyTable.addRecipe(20000, Chipset.IRON.getStack(), Item.redstone, Item.ingotIron); - BuildcraftRecipes.assemblyTable.addRecipe(40000, Chipset.GOLD.getStack(), Item.redstone, Item.ingotGold); - BuildcraftRecipes.assemblyTable.addRecipe(80000, Chipset.DIAMOND.getStack(), Item.redstone, Item.diamond); - BuildcraftRecipes.assemblyTable.addRecipe(40000, Chipset.PULSATING.getStack(2), Item.redstone, Item.enderPearl); - BuildcraftRecipes.assemblyTable.addRecipe(60000, Chipset.QUARTZ.getStack(), Item.redstone, Item.netherQuartz); - BuildcraftRecipes.assemblyTable.addRecipe(60000, Chipset.COMP.getStack(), Item.redstone, Item.comparator); + BuildcraftRecipes.assemblyTable.addRecipe(10000, Chipset.RED.getStack(), Items.redstone); + BuildcraftRecipes.assemblyTable.addRecipe(20000, Chipset.IRON.getStack(), Items.redstone, Items.iron_ingot); + BuildcraftRecipes.assemblyTable.addRecipe(40000, Chipset.GOLD.getStack(), Items.redstone, Items.gold_ingot); + BuildcraftRecipes.assemblyTable.addRecipe(80000, Chipset.DIAMOND.getStack(), Items.redstone, Items.diamond); + BuildcraftRecipes.assemblyTable.addRecipe(40000, Chipset.PULSATING.getStack(2), Items.redstone, Items.ender_pearl); + BuildcraftRecipes.assemblyTable.addRecipe(60000, Chipset.QUARTZ.getStack(), Items.redstone, Items.quartz); + BuildcraftRecipes.assemblyTable.addRecipe(60000, Chipset.COMP.getStack(), Items.redstone, Items.comparator); // GATES BuildcraftRecipes.assemblyTable.addRecipe(10000, ItemGate.makeGateItem(GateMaterial.REDSTONE, GateLogic.AND), Chipset.RED.getStack(), PipeWire.RED.getStack()); diff --git a/common/buildcraft/BuildCraftTransport.java b/common/buildcraft/BuildCraftTransport.java index dc422f41..1b0a9a5f 100644 --- a/common/buildcraft/BuildCraftTransport.java +++ b/common/buildcraft/BuildCraftTransport.java @@ -17,6 +17,7 @@ import buildcraft.core.DefaultProps; import buildcraft.core.InterModComms; import buildcraft.core.ItemBuildCraft; import buildcraft.core.Version; +import buildcraft.core.network.PacketHandler; import buildcraft.core.proxy.CoreProxy; import buildcraft.core.triggers.BCAction; import buildcraft.core.triggers.BCTrigger; @@ -46,7 +47,7 @@ import buildcraft.transport.ItemPipeWire; import buildcraft.transport.gates.GateExpansionRedstoneFader; import buildcraft.transport.gates.GateExpansionTimer; import buildcraft.transport.network.PacketHandlerTransport; -import buildcraft.transport.network.TransportConnectionHandler; +import buildcraft.transport.network.PacketPipeTransportTraveler; import buildcraft.transport.pipes.PipeFluidsCobblestone; import buildcraft.transport.pipes.PipeFluidsEmerald; import buildcraft.transport.pipes.PipeFluidsGold; @@ -100,7 +101,6 @@ import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLInterModComms.IMCEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; -import cpw.mods.fml.common.network.NetworkMod; import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; @@ -108,17 +108,18 @@ import cpw.mods.fml.common.registry.LanguageRegistry; import java.util.LinkedList; import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.world.World; -import net.minecraftforge.common.Configuration; -import net.minecraftforge.common.ForgeDirection; -import net.minecraftforge.common.Property; +import net.minecraftforge.common.config.Configuration; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.common.config.Property; @Mod(version = Version.VERSION, modid = "BuildCraft|Transport", name = "Buildcraft Transport", dependencies = DefaultProps.DEPENDENCY_CORE) -@NetworkMod(channels = {DefaultProps.NET_CHANNEL_NAME}, packetHandler = PacketHandlerTransport.class, connectionHandler = TransportConnectionHandler.class) -public class BuildCraftTransport { +public class BuildCraftTransport extends BuildCraftMod { public static BlockGenericPipe genericPipeBlock; public static float pipeDurability; @@ -210,22 +211,24 @@ public class BuildCraftTransport { return testStrings(liquids, world, i, j, k); } - private boolean testStrings(String[] excludedBlocks, World world, int i, int j, int k) { - int id = world.getBlockId(i, j, k); - Block block = Block.blocksList[id]; + private boolean testStrings(String[] excludedBlocks, World world, int i, int j, int k) { + Block block = world.getBlock(i, j, k); if (block == null) return false; int meta = world.getBlockMetadata(i, j, k); - for (String excluded : excludedBlocks) { + // TODO: the exculded list is not taken into account. This probably + // needs to be migrated to an implementation based on names instead + // of ids, low priority for now. + /*for (String excluded : excludedBlocks) { if (excluded.equals(block.getUnlocalizedName())) return false; String[] tokens = excluded.split(":"); if (tokens[0].equals(Integer.toString(id)) && (tokens.length == 1 || tokens[1].equals(Integer.toString(meta)))) return false; - } + }*/ return true; } } @@ -238,7 +241,7 @@ public class BuildCraftTransport { durability.comment = "How long a pipe will take to break"; pipeDurability = (float) durability.getDouble(DefaultProps.PIPES_DURABILITY); - Property exclusionItemList = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_BLOCK, "woodenPipe.item.exclusion", new String[0]); + Property exclusionItemList = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "woodenPipe.item.exclusion", new String[0]); String[] excludedItemBlocks = exclusionItemList.getStringList(); if (excludedItemBlocks != null) { @@ -248,7 +251,7 @@ public class BuildCraftTransport { } else excludedItemBlocks = new String[0]; - Property exclusionFluidList = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_BLOCK, "woodenPipe.liquid.exclusion", new String[0]); + Property exclusionFluidList = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_GENERAL, "woodenPipe.liquid.exclusion", new String[0]); String[] excludedFluidBlocks = exclusionFluidList.getStringList(); if (excludedFluidBlocks != null) { @@ -268,33 +271,28 @@ public class BuildCraftTransport { groupItemsTriggerProp.comment = "when reaching this amount of objects in a pipes, items will be automatically grouped"; groupItemsTrigger = groupItemsTriggerProp.getInt(); - - Property genericPipeId = BuildCraftCore.mainConfiguration.getBlock("pipe.id", DefaultProps.GENERIC_PIPE_ID); - - Property pipeWaterproofId = BuildCraftCore.mainConfiguration.getItem("pipeWaterproof.id", DefaultProps.PIPE_WATERPROOF_ID); - - pipeWaterproof = new ItemBuildCraft(pipeWaterproofId.getInt()); + pipeWaterproof = new ItemBuildCraft(); pipeWaterproof.setUnlocalizedName("pipeWaterproof"); LanguageRegistry.addName(pipeWaterproof, "Pipe Sealant"); CoreProxy.proxy.registerItem(pipeWaterproof); - genericPipeBlock = new BlockGenericPipe(genericPipeId.getInt()); - CoreProxy.proxy.registerBlock(genericPipeBlock.setUnlocalizedName("pipeBlock"), ItemBlock.class); + genericPipeBlock = new BlockGenericPipe(); + CoreProxy.proxy.registerBlock(genericPipeBlock.setBlockName("pipeBlock"), ItemBlock.class); - pipeItemsWood = buildPipe(DefaultProps.PIPE_ITEMS_WOOD_ID, PipeItemsWood.class, "Wooden Transport Pipe", "plankWood", Block.glass, "plankWood"); - pipeItemsEmerald = buildPipe(DefaultProps.PIPE_ITEMS_EMERALD_ID, PipeItemsEmerald.class, "Emerald Transport Pipe", Item.emerald, Block.glass, Item.emerald); - pipeItemsCobblestone = buildPipe(DefaultProps.PIPE_ITEMS_COBBLESTONE_ID, PipeItemsCobblestone.class, "Cobblestone Transport Pipe", "cobblestone", Block.glass, "cobblestone"); - pipeItemsStone = buildPipe(DefaultProps.PIPE_ITEMS_STONE_ID, PipeItemsStone.class, "Stone Transport Pipe", "stone", Block.glass, "stone"); - pipeItemsQuartz = buildPipe(DefaultProps.PIPE_ITEMS_QUARTZ_ID, PipeItemsQuartz.class, "Quartz Transport Pipe", Block.blockNetherQuartz, Block.glass, Block.blockNetherQuartz); - pipeItemsIron = buildPipe(DefaultProps.PIPE_ITEMS_IRON_ID, PipeItemsIron.class, "Iron Transport Pipe", Item.ingotIron, Block.glass, Item.ingotIron); - pipeItemsGold = buildPipe(DefaultProps.PIPE_ITEMS_GOLD_ID, PipeItemsGold.class, "Golden Transport Pipe", Item.ingotGold, Block.glass, Item.ingotGold); - pipeItemsDiamond = buildPipe(DefaultProps.PIPE_ITEMS_DIAMOND_ID, PipeItemsDiamond.class, "Diamond Transport Pipe", Item.diamond, Block.glass, Item.diamond); - pipeItemsObsidian = buildPipe(DefaultProps.PIPE_ITEMS_OBSIDIAN_ID, PipeItemsObsidian.class, "Obsidian Transport Pipe", Block.obsidian, Block.glass, Block.obsidian); - pipeItemsLapis = buildPipe(DefaultProps.PIPE_ITEMS_LAPIS_ID, PipeItemsLapis.class, "Lapis Transport Pipe", Block.blockLapis, Block.glass, Block.blockLapis); - pipeItemsDaizuli = buildPipe(DefaultProps.PIPE_ITEMS_DAIZULI_ID, PipeItemsDaizuli.class, "Daizuli Transport Pipe", Block.blockLapis, Block.glass, Item.diamond); - pipeItemsSandstone = buildPipe(DefaultProps.PIPE_ITEMS_SANDSTONE_ID, PipeItemsSandstone.class, "Sandstone Transport Pipe", Block.sandStone, Block.glass, Block.sandStone); - pipeItemsVoid = buildPipe(DefaultProps.PIPE_ITEMS_VOID_ID, PipeItemsVoid.class, "Void Transport Pipe", "dyeBlack", Block.glass, Item.redstone); - pipeItemsEmzuli = buildPipe(DefaultProps.PIPE_ITEMS_EMZULI_ID, PipeItemsEmzuli.class, "Emzuli Transport Pipe", Block.blockLapis, Block.glass, Item.emerald); + pipeItemsWood = buildPipe(DefaultProps.PIPE_ITEMS_WOOD_ID, PipeItemsWood.class, "Wooden Transport Pipe", "plankWood", Blocks.glass, "plankWood"); + pipeItemsEmerald = buildPipe(DefaultProps.PIPE_ITEMS_EMERALD_ID, PipeItemsEmerald.class, "Emerald Transport Pipe", Items.emerald, Blocks.glass, Items.emerald); + pipeItemsCobblestone = buildPipe(DefaultProps.PIPE_ITEMS_COBBLESTONE_ID, PipeItemsCobblestone.class, "Cobblestone Transport Pipe", "cobblestone", Blocks.glass, "cobblestone"); + pipeItemsStone = buildPipe(DefaultProps.PIPE_ITEMS_STONE_ID, PipeItemsStone.class, "Stone Transport Pipe", "stone", Blocks.glass, "stone"); + pipeItemsQuartz = buildPipe(DefaultProps.PIPE_ITEMS_QUARTZ_ID, PipeItemsQuartz.class, "Quartz Transport Pipe", Blocks.quartz_block, Blocks.glass, Blocks.quartz_block); + pipeItemsIron = buildPipe(DefaultProps.PIPE_ITEMS_IRON_ID, PipeItemsIron.class, "Iron Transport Pipe", Items.iron_ingot, Blocks.glass, Items.iron_ingot); + pipeItemsGold = buildPipe(DefaultProps.PIPE_ITEMS_GOLD_ID, PipeItemsGold.class, "Golden Transport Pipe", Items.gold_ingot, Blocks.glass, Items.gold_ingot); + pipeItemsDiamond = buildPipe(DefaultProps.PIPE_ITEMS_DIAMOND_ID, PipeItemsDiamond.class, "Diamond Transport Pipe", Items.diamond, Blocks.glass, Items.diamond); + pipeItemsObsidian = buildPipe(DefaultProps.PIPE_ITEMS_OBSIDIAN_ID, PipeItemsObsidian.class, "Obsidian Transport Pipe", Blocks.obsidian, Blocks.glass, Blocks.obsidian); + pipeItemsLapis = buildPipe(DefaultProps.PIPE_ITEMS_LAPIS_ID, PipeItemsLapis.class, "Lapis Transport Pipe", Blocks.lapis_block, Blocks.glass, Blocks.lapis_block); + pipeItemsDaizuli = buildPipe(DefaultProps.PIPE_ITEMS_DAIZULI_ID, PipeItemsDaizuli.class, "Daizuli Transport Pipe", Blocks.lapis_block, Blocks.glass, Items.diamond); + pipeItemsSandstone = buildPipe(DefaultProps.PIPE_ITEMS_SANDSTONE_ID, PipeItemsSandstone.class, "Sandstone Transport Pipe", Blocks.sandstone, Blocks.glass, Blocks.sandstone); + pipeItemsVoid = buildPipe(DefaultProps.PIPE_ITEMS_VOID_ID, PipeItemsVoid.class, "Void Transport Pipe", "dyeBlack", Blocks.glass, Items.redstone); + pipeItemsEmzuli = buildPipe(DefaultProps.PIPE_ITEMS_EMZULI_ID, PipeItemsEmzuli.class, "Emzuli Transport Pipe", Blocks.lapis_block, Blocks.glass, Items.emerald); pipeFluidsWood = buildPipe(DefaultProps.PIPE_LIQUIDS_WOOD_ID, PipeFluidsWood.class, "Wooden Waterproof Pipe", pipeWaterproof, pipeItemsWood); pipeFluidsCobblestone = buildPipe(DefaultProps.PIPE_LIQUIDS_COBBLESTONE_ID, PipeFluidsCobblestone.class, "Cobblestone Waterproof Pipe", pipeWaterproof, pipeItemsCobblestone); @@ -305,51 +303,77 @@ public class BuildCraftTransport { pipeFluidsSandstone = buildPipe(DefaultProps.PIPE_LIQUIDS_SANDSTONE_ID, PipeFluidsSandstone.class, "Sandstone Waterproof Pipe", pipeWaterproof, pipeItemsSandstone); pipeFluidsVoid = buildPipe(DefaultProps.PIPE_LIQUIDS_VOID_ID, PipeFluidsVoid.class, "Void Waterproof Pipe", pipeWaterproof, pipeItemsVoid); - pipePowerWood = buildPipe(DefaultProps.PIPE_POWER_WOOD_ID, PipePowerWood.class, "Wooden Kinesis Pipe", Item.redstone, pipeItemsWood); - pipePowerCobblestone = buildPipe(DefaultProps.PIPE_POWER_COBBLESTONE_ID, PipePowerCobblestone.class, "Cobblestone Kinesis Pipe", Item.redstone, pipeItemsCobblestone); - pipePowerStone = buildPipe(DefaultProps.PIPE_POWER_STONE_ID, PipePowerStone.class, "Stone Kinesis Pipe", Item.redstone, pipeItemsStone); - pipePowerQuartz = buildPipe(DefaultProps.PIPE_POWER_QUARTZ_ID, PipePowerQuartz.class, "Quartz Kinesis Pipe", Item.redstone, pipeItemsQuartz); - pipePowerIron = buildPipe(DefaultProps.PIPE_POWER_IRON_ID, PipePowerIron.class, "Iron Kinesis Pipe", Item.redstone, pipeItemsIron); - pipePowerGold = buildPipe(DefaultProps.PIPE_POWER_GOLD_ID, PipePowerGold.class, "Golden Kinesis Pipe", Item.redstone, pipeItemsGold); - pipePowerDiamond = buildPipe(DefaultProps.PIPE_POWER_DIAMOND_ID, PipePowerDiamond.class, "Diamond Kinesis Pipe", Item.redstone, pipeItemsDiamond); - pipePowerHeat = buildPipe(DefaultProps.PIPE_POWER_HEAT_ID, PipePowerHeat.class, "Heat Kinesis Pipe", Block.furnaceIdle, pipeItemsDiamond); + pipePowerWood = buildPipe(DefaultProps.PIPE_POWER_WOOD_ID, PipePowerWood.class, "Wooden Kinesis Pipe", Items.redstone, pipeItemsWood); + pipePowerCobblestone = buildPipe(DefaultProps.PIPE_POWER_COBBLESTONE_ID, PipePowerCobblestone.class, "Cobblestone Kinesis Pipe", Items.redstone, pipeItemsCobblestone); + pipePowerStone = buildPipe(DefaultProps.PIPE_POWER_STONE_ID, PipePowerStone.class, "Stone Kinesis Pipe", Items.redstone, pipeItemsStone); + pipePowerQuartz = buildPipe(DefaultProps.PIPE_POWER_QUARTZ_ID, PipePowerQuartz.class, "Quartz Kinesis Pipe", Items.redstone, pipeItemsQuartz); + pipePowerIron = buildPipe(DefaultProps.PIPE_POWER_IRON_ID, PipePowerIron.class, "Iron Kinesis Pipe", Items.redstone, pipeItemsIron); + pipePowerGold = buildPipe(DefaultProps.PIPE_POWER_GOLD_ID, PipePowerGold.class, "Golden Kinesis Pipe", Items.redstone, pipeItemsGold); + pipePowerDiamond = buildPipe(DefaultProps.PIPE_POWER_DIAMOND_ID, PipePowerDiamond.class, "Diamond Kinesis Pipe", Items.redstone, pipeItemsDiamond); + pipePowerHeat = buildPipe(DefaultProps.PIPE_POWER_HEAT_ID, PipePowerHeat.class, "Heat Kinesis Pipe", Blocks.furnace, pipeItemsDiamond); - pipeStructureCobblestone = buildPipe(DefaultProps.PIPE_STRUCTURE_COBBLESTONE_ID, PipeStructureCobblestone.class, "Cobblestone Structure Pipe", Block.gravel, pipeItemsCobblestone); + pipeStructureCobblestone = buildPipe(DefaultProps.PIPE_STRUCTURE_COBBLESTONE_ID, PipeStructureCobblestone.class, "Cobblestone Structure Pipe", Blocks.gravel, pipeItemsCobblestone); // Fix the recipe // pipeItemsStipes = createPipe(DefaultProps.PIPE_ITEMS_STRIPES_ID, PipeItemsStripes.class, "Stripes Transport Pipe", new ItemStack(Item.dyePowder, // 1, 0), Block.glass, new ItemStack(Item.dyePowder, 1, 11)); - int pipeWireId = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_ITEM, "pipeWire.id", DefaultProps.PIPE_WIRE).getInt(DefaultProps.PIPE_WIRE); - pipeWire = new ItemPipeWire(pipeWireId); + pipeWire = new ItemPipeWire(); LanguageRegistry.addName(pipeWire, "Pipe Wire"); CoreProxy.proxy.registerItem(pipeWire); PipeWire.item = pipeWire; - Property pipeGateId = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_ITEM, "pipeGate.id", DefaultProps.GATE_ID); - pipeGate = new ItemGate(pipeGateId.getInt()); + pipeGate = new ItemGate(); pipeGate.setUnlocalizedName("pipeGate"); CoreProxy.proxy.registerItem(pipeGate); - Property pipeFacadeId = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_ITEM, "pipeFacade.id", DefaultProps.PIPE_FACADE_ID); - facadeItem = new ItemFacade(pipeFacadeId.getInt()); + facadeItem = new ItemFacade(); facadeItem.setUnlocalizedName("pipeFacade"); CoreProxy.proxy.registerItem(facadeItem); - Property pipePlugId = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_ITEM, "pipePlug.id", DefaultProps.PIPE_PLUG_ID); - plugItem = new ItemPlug(pipePlugId.getInt()); + plugItem = new ItemPlug(); plugItem.setUnlocalizedName("pipePlug"); CoreProxy.proxy.registerItem(plugItem); - Property robotStationId = BuildCraftCore.mainConfiguration.get(Configuration.CATEGORY_ITEM, "robotStation.id", DefaultProps.ROBOT_STATION_ID); - robotStationItem = new ItemRobotStation(robotStationId.getInt()); + robotStationItem = new ItemRobotStation(); robotStationItem.setUnlocalizedName("robotStation"); CoreProxy.proxy.registerItem(robotStationItem); - Property filteredBufferId = BuildCraftCore.mainConfiguration.getBlock("filteredBuffer.id", DefaultProps.FILTERED_BUFFER_ID); - filteredBufferBlock = new BlockFilteredBuffer(filteredBufferId.getInt()); - CoreProxy.proxy.registerBlock(filteredBufferBlock.setUnlocalizedName("filteredBufferBlock")); + filteredBufferBlock = new BlockFilteredBuffer(); + CoreProxy.proxy.registerBlock(filteredBufferBlock.setBlockName("filteredBufferBlock")); + CoreProxy.proxy.addName(filteredBufferBlock, "Filtered Buffer"); + + for (PipeContents kind : PipeContents.values()) { + triggerPipe[kind.ordinal()] = new TriggerPipeContents(kind); + } + + for (PipeWire wire : PipeWire.values()) { + triggerPipeWireActive[wire.ordinal()] = new TriggerPipeSignal(true, wire); + triggerPipeWireInactive[wire.ordinal()] = new TriggerPipeSignal(false, wire); + actionPipeWire[wire.ordinal()] = new ActionSignalOutput(wire); + } + + for (Time time : TriggerClockTimer.Time.VALUES) { + triggerTimer[time.ordinal()] = new TriggerClockTimer(time); + } + + for (int level = 0; level < triggerRedstoneLevel.length; level++) { + triggerRedstoneLevel[level] = new TriggerRedstoneFaderInput(level + 1); + actionRedstoneLevel[level] = new ActionRedstoneFaderOutput(level + 1); + } + + for (EnumColor color : EnumColor.VALUES) { + actionPipeColor[color.ordinal()] = new ActionPipeColor(color); + } + + for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) { + actionPipeDirection[direction.ordinal()] = new ActionPipeDirection(direction); + } + + for (PowerMode limit : PowerMode.VALUES) { + actionPowerLimiter[limit.ordinal()] = new ActionPowerLimiter(limit); + } } finally { BuildCraftCore.mainConfiguration.save(); } @@ -357,6 +381,9 @@ public class BuildCraftTransport { @EventHandler public void init(FMLInitializationEvent evt) { + channels = NetworkRegistry.INSTANCE.newChannel + (DefaultProps.NET_CHANNEL_NAME + "-TRANSPORT", new PacketHandlerTransport()); + // Register connection handler // MinecraftForge.registerConnectionHandler(new ConnectionHandler()); @@ -374,14 +401,14 @@ public class BuildCraftTransport { // ModLoader.RegisterTileEntity(TileDockingStation.class, // "net.minecraft.src.buildcraft.TileDockingStation"); - new BptBlockPipe(genericPipeBlock.blockID); + //new BptBlockPipe(genericPipeBlock.blockID); - BuildCraftCore.itemBptProps[pipeItemsWood.itemID] = new BptItemPipeWooden(); - BuildCraftCore.itemBptProps[pipeFluidsWood.itemID] = new BptItemPipeWooden(); - BuildCraftCore.itemBptProps[pipeItemsIron.itemID] = new BptItemPipeIron(); - BuildCraftCore.itemBptProps[pipeFluidsIron.itemID] = new BptItemPipeIron(); - BuildCraftCore.itemBptProps[pipeItemsDiamond.itemID] = new BptItemPipeDiamond(); - BuildCraftCore.itemBptProps[pipeItemsEmerald.itemID] = new BptItemPipeEmerald(); + //BuildCraftCore.itemBptProps[pipeItemsWood.itemID] = new BptItemPipeWooden(); + //BuildCraftCore.itemBptProps[pipeFluidsWood.itemID] = new BptItemPipeWooden(); + //BuildCraftCore.itemBptProps[pipeItemsIron.itemID] = new BptItemPipeIron(); + //BuildCraftCore.itemBptProps[pipeFluidsIron.itemID] = new BptItemPipeIron(); + //BuildCraftCore.itemBptProps[pipeItemsDiamond.itemID] = new BptItemPipeDiamond(); + //BuildCraftCore.itemBptProps[pipeItemsEmerald.itemID] = new BptItemPipeEmerald(); ActionManager.registerTriggerProvider(new PipeTriggerProvider()); @@ -390,49 +417,18 @@ public class BuildCraftTransport { } TransportProxy.proxy.registerRenderers(); - NetworkRegistry.instance().registerGuiHandler(instance, new GuiHandler()); + NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler()); } @EventHandler public void postInit(FMLPostInitializationEvent evt) { ItemFacade.initialize(); - - for (PipeContents kind : PipeContents.values()) { - triggerPipe[kind.ordinal()] = new TriggerPipeContents(kind); - } - - for (PipeWire wire : PipeWire.values()) { - triggerPipeWireActive[wire.ordinal()] = new TriggerPipeSignal(true, wire); - triggerPipeWireInactive[wire.ordinal()] = new TriggerPipeSignal(false, wire); - actionPipeWire[wire.ordinal()] = new ActionSignalOutput(wire); - } - - for (Time time : TriggerClockTimer.Time.VALUES) { - triggerTimer[time.ordinal()] = new TriggerClockTimer(time); - } - - for (int level = 0; level < triggerRedstoneLevel.length; level++) { - triggerRedstoneLevel[level] = new TriggerRedstoneFaderInput(level + 1); - actionRedstoneLevel[level] = new ActionRedstoneFaderOutput(level + 1); - } - - for (EnumColor color : EnumColor.VALUES) { - actionPipeColor[color.ordinal()] = new ActionPipeColor(color); - } - - for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) { - actionPipeDirection[direction.ordinal()] = new ActionPipeDirection(direction); - } - - for (PowerMode limit : PowerMode.VALUES) { - actionPowerLimiter[limit.ordinal()] = new ActionPowerLimiter(limit); - } } public void loadRecipes() { // Add base recipe for pipe waterproof. - GameRegistry.addShapelessRecipe(new ItemStack(pipeWaterproof, 1), new ItemStack(Item.dyePowder, 1, 2)); + GameRegistry.addShapelessRecipe(new ItemStack(pipeWaterproof, 1), new ItemStack(Items.dye, 1, 2)); // Add pipe recipes for (PipeRecipe pipe : pipeRecipes) { @@ -445,8 +441,8 @@ public class BuildCraftTransport { CoreProxy.proxy.addCraftingRecipe(new ItemStack(filteredBufferBlock, 1), new Object[]{"wdw", "wcw", "wpw", 'w', "plankWood", 'd', - BuildCraftTransport.pipeItemsDiamond, 'c', Block.chest, 'p', - Block.pistonBase}); + BuildCraftTransport.pipeItemsDiamond, 'c', Blocks.chest, 'p', + Blocks.piston}); //Facade turning helper GameRegistry.addRecipe(facadeItem.new FacadeRecipe()); @@ -462,10 +458,7 @@ public class BuildCraftTransport { public static Item buildPipe(int defaultID, Class clas, String descr, Object... ingredients) { String name = Character.toLowerCase(clas.getSimpleName().charAt(0)) + clas.getSimpleName().substring(1); - Property prop = BuildCraftCore.mainConfiguration.getItem(name + ".id", defaultID); - - int id = prop.getInt(defaultID); - ItemPipe res = BlockGenericPipe.registerPipe(id, clas); + ItemPipe res = BlockGenericPipe.registerPipe(clas); res.setUnlocalizedName(clas.getSimpleName()); LanguageRegistry.addName(res, descr); @@ -495,4 +488,5 @@ public class BuildCraftTransport { return res; } + } diff --git a/common/buildcraft/api/blueprints/BlockSignature.java b/common/buildcraft/api/blueprints/BlockSignature.java index 51db24d4..519ce016 100644 --- a/common/buildcraft/api/blueprints/BlockSignature.java +++ b/common/buildcraft/api/blueprints/BlockSignature.java @@ -1,12 +1,11 @@ -/** - * Copyright (c) SpaceToad, 2011 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * - * BuildCraft is distributed under the terms of the Minecraft Mod Public + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.api.blueprints; public class BlockSignature { diff --git a/common/buildcraft/api/blueprints/BlueprintManager.java b/common/buildcraft/api/blueprints/BlueprintManager.java index c71b710e..07df78d5 100644 --- a/common/buildcraft/api/blueprints/BlueprintManager.java +++ b/common/buildcraft/api/blueprints/BlueprintManager.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.api.blueprints; import buildcraft.api.core.BuildCraftAPI; @@ -8,14 +16,14 @@ import net.minecraft.item.ItemStack; @Deprecated public class BlueprintManager { - public static BptBlock[] blockBptProps = new BptBlock[Block.blocksList.length]; + //public static BptBlock[] blockBptProps = new BptBlock[Block.blocksList.length]; public static ItemSignature getItemSignature(Item item) { ItemSignature sig = new ItemSignature(); - if (item.itemID >= Block.blocksList.length + BuildCraftAPI.LAST_ORIGINAL_ITEM) { - sig.itemClassName = item.getClass().getSimpleName(); - } + //if (item.itemID >= Block.blocksList.length + BuildCraftAPI.LAST_ORIGINAL_ITEM) { + // sig.itemClassName = item.getClass().getSimpleName(); + //} sig.itemName = item.getUnlocalizedName(new ItemStack(item)); @@ -23,13 +31,14 @@ public class BlueprintManager { } public static BlockSignature getBlockSignature(Block block) { - return BlueprintManager.blockBptProps[0].getSignature(block); + //return BlueprintManager.blockBptProps[0].getSignature(block); + return null; } static { // Initialize defaults for block properties. - for (int i = 0; i < BlueprintManager.blockBptProps.length; ++i) { - new BptBlock(i); - } + //for (int i = 0; i < BlueprintManager.blockBptProps.length; ++i) { + // new BptBlock(i); + //} } } diff --git a/common/buildcraft/api/blueprints/BptBlock.java b/common/buildcraft/api/blueprints/BptBlock.java index 4f48d35e..305cdee4 100644 --- a/common/buildcraft/api/blueprints/BptBlock.java +++ b/common/buildcraft/api/blueprints/BptBlock.java @@ -1,12 +1,11 @@ /** - * Copyright (c) SpaceToad, 2011 + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.api.blueprints; import buildcraft.api.core.BuildCraftAPI; @@ -49,7 +48,7 @@ public class BptBlock { public BptBlock(int blockId) { this.blockId = blockId; - BlueprintManager.blockBptProps[blockId] = this; + //BlueprintManager.blockBptProps[blockId] = this; } /** @@ -57,11 +56,11 @@ public class BptBlock { * buildBlock. */ public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList requirements) { - if (slot.blockId != 0) { + if (slot.block != null) { if (slot.storedRequirements.size() != 0) { requirements.addAll(slot.storedRequirements); } else { - requirements.add(new ItemStack(slot.blockId, 1, slot.meta)); + // requirements.add(new ItemStack(slot.blockId, 1, slot.meta)); } } } @@ -103,7 +102,7 @@ public class BptBlock { if (stack.stackSize == 0 && stack.getItem().getContainerItem() != null) { Item container = stack.getItem().getContainerItem(); - stack.itemID = container.itemID; + //stack.itemID = container.itemID; stack.stackSize = 1; stack.setItemDamage(0); } @@ -117,7 +116,8 @@ public class BptBlock { * Added metadata sensitivity //Krapht */ public boolean isValid(BptSlotInfo slot, IBptContext context) { - return slot.blockId == context.world().getBlockId(slot.x, slot.y, slot.z) && slot.meta == context.world().getBlockMetadata(slot.x, slot.y, slot.z); + //return slot.blockId == context.world().getBlockId(slot.x, slot.y, slot.z) && slot.meta == context.world().getBlockMetadata(slot.x, slot.y, slot.z); + return false; } /** @@ -132,19 +132,19 @@ public class BptBlock { */ public void buildBlock(BptSlotInfo slot, IBptContext context) { // Meta needs to be specified twice, depending on the block behavior - context.world().setBlock(slot.x, slot.y, slot.z, slot.blockId, slot.meta,3); - context.world().setBlockMetadataWithNotify(slot.x, slot.y, slot.z, slot.meta,3); + context.world().setBlock(slot.x, slot.y, slot.z, slot.block, slot.meta, 0); + //context.world().setBlockMetadataWithNotify(slot.x, slot.y, slot.z, slot.meta,3); - if (Block.blocksList[slot.blockId] instanceof BlockContainer) { - TileEntity tile = context.world().getBlockTileEntity(slot.x, slot.y, slot.z); + if (slot.block instanceof BlockContainer) { + TileEntity tile = context.world().getTileEntity(slot.x, slot.y, slot.z); - slot.cpt.setInteger("x", slot.x); - slot.cpt.setInteger("y", slot.y); - slot.cpt.setInteger("z", slot.z); + //slot.cpt.setInteger("x", slot.x); + //slot.cpt.setInteger("y", slot.y); + //slot.cpt.setInteger("z", slot.z); - if (tile != null) { - tile.readFromNBT(slot.cpt); - } + //if (tile != null) { + // tile.readFromNBT(slot.cpt); + //} } } @@ -162,8 +162,8 @@ public class BptBlock { * By default, if the block is a BlockContainer, tile information will be to save / load the block. */ public void initializeFromWorld(BptSlotInfo slot, IBptContext context, int x, int y, int z) { - if (Block.blocksList[slot.blockId] instanceof BlockContainer) { - TileEntity tile = context.world().getBlockTileEntity(x, y, z); + /*if (Block.blocksList[slot.blockId] instanceof BlockContainer) { + TileEntity tile = context.world().getTileEntity(x, y, z); if (tile != null) { tile.writeToNBT(slot.cpt); @@ -176,7 +176,7 @@ public class BptBlock { if (req != null) { slot.storedRequirements.addAll(req); } - } + }*/ } /** @@ -194,7 +194,7 @@ public class BptBlock { public BlockSignature getSignature(Block block) { BlockSignature sig = new BlockSignature(); - if (block.blockID > BuildCraftAPI.LAST_ORIGINAL_BLOCK) { + /*if (block.blockID > BuildCraftAPI.LAST_ORIGINAL_BLOCK) { sig.blockClassName = block.getClass().getSimpleName(); if (block instanceof BlockContainer) { @@ -205,7 +205,7 @@ public class BptBlock { sig.tileClassName = tile.getClass().getSimpleName(); } } - } + }*/ sig.blockName = block.getUnlocalizedName(); sig.replaceNullWithStar(); diff --git a/common/buildcraft/api/blueprints/BptBlockUtils.java b/common/buildcraft/api/blueprints/BptBlockUtils.java index a46d9b12..e5dfac7e 100644 --- a/common/buildcraft/api/blueprints/BptBlockUtils.java +++ b/common/buildcraft/api/blueprints/BptBlockUtils.java @@ -1,12 +1,11 @@ -/** - * Copyright (c) SpaceToad, 2011 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * - * BuildCraft is distributed under the terms of the Minecraft Mod Public + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.api.blueprints; import java.util.LinkedList; @@ -55,11 +54,11 @@ public class BptBlockUtils { ItemStack stacks[] = new ItemStack[list.tagCount()]; for (int i = 0; i < list.tagCount(); ++i) { - ItemStack stack = ItemStack.loadItemStackFromNBT((NBTTagCompound) list.tagAt(i)); + //ItemStack stack = ItemStack.loadItemStackFromNBT((NBTTagCompound) list.tagAt(i)); - if (stack != null && stack.itemID != 0 && stack.stackSize > 0) { - stacks[i] = context.mapItemStack(stack); - } + //if (stack != null && stack.itemID != 0 && stack.stackSize > 0) { + // stacks[i] = context.mapItemStack(stack); + //} } return stacks; @@ -75,7 +74,7 @@ public class BptBlockUtils { if (stack != null && stack.stackSize != 0) { stack.writeToNBT(cpt); - context.storeId(stack.itemID); + //context.storeId(stack.itemID); } } diff --git a/common/buildcraft/api/blueprints/BptSlotInfo.java b/common/buildcraft/api/blueprints/BptSlotInfo.java index 799a3b4f..afa74156 100644 --- a/common/buildcraft/api/blueprints/BptSlotInfo.java +++ b/common/buildcraft/api/blueprints/BptSlotInfo.java @@ -1,15 +1,16 @@ -/** - * Copyright (c) SpaceToad, 2011 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * - * BuildCraft is distributed under the terms of the Minecraft Mod Public + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.api.blueprints; import java.util.LinkedList; + +import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -20,7 +21,7 @@ import net.minecraft.nbt.NBTTagCompound; @Deprecated public class BptSlotInfo { - public int blockId = 0; + public Block block = null; public int meta = 0; public int x; public int y; @@ -44,7 +45,7 @@ public class BptSlotInfo { obj.x = x; obj.y = y; obj.z = z; - obj.blockId = blockId; + obj.block = block; obj.meta = meta; obj.cpt = (NBTTagCompound) cpt.copy(); diff --git a/common/buildcraft/api/blueprints/IBptContext.java b/common/buildcraft/api/blueprints/IBptContext.java index 8498bfd3..d785722b 100644 --- a/common/buildcraft/api/blueprints/IBptContext.java +++ b/common/buildcraft/api/blueprints/IBptContext.java @@ -1,12 +1,11 @@ -/** - * Copyright (c) SpaceToad, 2011 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * - * BuildCraft is distributed under the terms of the Minecraft Mod Public + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.api.blueprints; import buildcraft.api.core.IBox; diff --git a/common/buildcraft/api/blueprints/ItemSignature.java b/common/buildcraft/api/blueprints/ItemSignature.java index d6bd0310..b3fa2065 100644 --- a/common/buildcraft/api/blueprints/ItemSignature.java +++ b/common/buildcraft/api/blueprints/ItemSignature.java @@ -1,12 +1,11 @@ -/** - * Copyright (c) SpaceToad, 2011 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * - * BuildCraft is distributed under the terms of the Minecraft Mod Public + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.api.blueprints; @Deprecated diff --git a/common/buildcraft/api/bptblocks/BptBlockBed.java b/common/buildcraft/api/bptblocks/BptBlockBed.java index e2dae05c..e2f22e0c 100644 --- a/common/buildcraft/api/bptblocks/BptBlockBed.java +++ b/common/buildcraft/api/bptblocks/BptBlockBed.java @@ -1,18 +1,20 @@ /** - * Copyright (c) SpaceToad, 2011 + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.api.bptblocks; import buildcraft.api.blueprints.BptBlock; import buildcraft.api.blueprints.BptSlotInfo; import buildcraft.api.blueprints.IBptContext; + import java.util.LinkedList; + +import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -26,7 +28,7 @@ public class BptBlockBed extends BptBlock { @Override public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList requirements) { if ((slot.meta & 8) == 0) { - requirements.add(new ItemStack(Item.bed)); + requirements.add(new ItemStack(Items.bed)); } } @@ -56,7 +58,7 @@ public class BptBlockBed extends BptBlock { if ((slot.meta & 8) != 0) return; - context.world().setBlock(slot.x, slot.y, slot.z, slot.blockId, slot.meta,1); + //context.world().setBlock(slot.x, slot.y, slot.z, slot.block, slot.meta,1); int x2 = slot.x; int z2 = slot.z; @@ -76,7 +78,7 @@ public class BptBlockBed extends BptBlock { break; } - context.world().setBlock(x2, slot.y, z2, slot.blockId, slot.meta + 8,1); + //context.world().setBlock(x2, slot.y, z2, slot.block, slot.meta + 8,1); } @Override diff --git a/common/buildcraft/api/bptblocks/BptBlockCustomStack.java b/common/buildcraft/api/bptblocks/BptBlockCustomStack.java index 79aef15c..1087520f 100644 --- a/common/buildcraft/api/bptblocks/BptBlockCustomStack.java +++ b/common/buildcraft/api/bptblocks/BptBlockCustomStack.java @@ -1,12 +1,11 @@ -/** - * Copyright (c) SpaceToad, 2011 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * - * BuildCraft is distributed under the terms of the Minecraft Mod Public + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.api.bptblocks; import buildcraft.api.blueprints.BptBlock; diff --git a/common/buildcraft/api/bptblocks/BptBlockDelegate.java b/common/buildcraft/api/bptblocks/BptBlockDelegate.java index 035dc556..45c4891e 100644 --- a/common/buildcraft/api/bptblocks/BptBlockDelegate.java +++ b/common/buildcraft/api/bptblocks/BptBlockDelegate.java @@ -1,27 +1,29 @@ -/** - * Copyright (c) SpaceToad, 2011 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * - * BuildCraft is distributed under the terms of the Minecraft Mod Public + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.api.bptblocks; import buildcraft.api.blueprints.BlueprintManager; import buildcraft.api.blueprints.BptBlock; import buildcraft.api.blueprints.BptSlotInfo; import buildcraft.api.blueprints.IBptContext; + import java.util.LinkedList; + +import net.minecraft.block.Block; import net.minecraft.item.ItemStack; @Deprecated public class BptBlockDelegate extends BptBlock { - final int delegateTo; + final Block delegateTo; - public BptBlockDelegate(int blockId, int delegateTo) { + public BptBlockDelegate(int blockId, Block delegateTo) { super(blockId); this.delegateTo = delegateTo; @@ -30,36 +32,38 @@ public class BptBlockDelegate extends BptBlock { @Override public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList requirements) { BptSlotInfo newSlot = slot.clone(); - slot.blockId = delegateTo; + slot.block = delegateTo; - if (BlueprintManager.blockBptProps[delegateTo] != null) { - BlueprintManager.blockBptProps[delegateTo].addRequirements(newSlot, context, requirements); - } else { - super.addRequirements(newSlot, context, requirements); - } + //if (BlueprintManager.blockBptProps[delegateTo] != null) { + // BlueprintManager.blockBptProps[delegateTo].addRequirements(newSlot, context, requirements); + //} else { + // super.addRequirements(newSlot, context, requirements); + //} } @Override public boolean isValid(BptSlotInfo slot, IBptContext context) { BptSlotInfo newSlot = slot.clone(); - slot.blockId = delegateTo; + slot.block = delegateTo; - if (BlueprintManager.blockBptProps[delegateTo] != null) - return BlueprintManager.blockBptProps[delegateTo].isValid(newSlot, context); - else - return super.isValid(newSlot, context); + //if (BlueprintManager.blockBptProps[delegateTo] != null) + // return BlueprintManager.blockBptProps[delegateTo].isValid(newSlot, context); + //else + // return super.isValid(newSlot, context); + + return false; } @Override public void rotateLeft(BptSlotInfo slot, IBptContext context) { BptSlotInfo newSlot = slot.clone(); - slot.blockId = delegateTo; + slot.block = delegateTo; - if (BlueprintManager.blockBptProps[delegateTo] != null) { - BlueprintManager.blockBptProps[delegateTo].rotateLeft(newSlot, context); - } else { - super.rotateLeft(newSlot, context); - } + //if (BlueprintManager.blockBptProps[delegateTo] != null) { + // BlueprintManager.blockBptProps[delegateTo].rotateLeft(newSlot, context); + //} else { + // super.rotateLeft(newSlot, context); + //} } } diff --git a/common/buildcraft/api/bptblocks/BptBlockDirt.java b/common/buildcraft/api/bptblocks/BptBlockDirt.java index 365cbc45..12720bf3 100644 --- a/common/buildcraft/api/bptblocks/BptBlockDirt.java +++ b/common/buildcraft/api/bptblocks/BptBlockDirt.java @@ -1,12 +1,11 @@ /** - * Copyright (c) SpaceToad, 2011 + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.api.bptblocks; import buildcraft.api.blueprints.BptBlock; @@ -25,18 +24,19 @@ public class BptBlockDirt extends BptBlock { @Override public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList requirements) { - requirements.add(new ItemStack(Block.dirt)); + //requirements.add(new ItemStack(Block.dirt)); } @Override public void buildBlock(BptSlotInfo slot, IBptContext context) { - context.world().setBlock(slot.x, slot.y, slot.z, Block.dirt.blockID, slot.meta,1); + //context.world().setBlock(slot.x, slot.y, slot.z, Block.dirt.blockID, slot.meta,1); } @Override public boolean isValid(BptSlotInfo slot, IBptContext context) { - int id = context.world().getBlockId(slot.x, slot.y, slot.z); + //int id = context.world().getBlockId(slot.x, slot.y, slot.z); - return id == Block.dirt.blockID || id == Block.grass.blockID || id == Block.tilledField.blockID; + //return id == Block.dirt.blockID || id == Block.grass.blockID || id == Block.tilledField.blockID; + return false; } } diff --git a/common/buildcraft/api/bptblocks/BptBlockDoor.java b/common/buildcraft/api/bptblocks/BptBlockDoor.java index 196e83b3..dedb75e8 100644 --- a/common/buildcraft/api/bptblocks/BptBlockDoor.java +++ b/common/buildcraft/api/bptblocks/BptBlockDoor.java @@ -1,12 +1,11 @@ /** - * Copyright (c) SpaceToad, 2011 + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.api.bptblocks; import buildcraft.api.blueprints.BptBlock; @@ -61,8 +60,8 @@ public class BptBlockDoor extends BptBlock { @Override public void buildBlock(BptSlotInfo slot, IBptContext context) { - context.world().setBlock(slot.x, slot.y, slot.z, slot.blockId, slot.meta,1); - context.world().setBlock(slot.x, slot.y + 1, slot.z, slot.blockId, slot.meta + 8,1); + //context.world().setBlock(slot.x, slot.y, slot.z, slot.blockId, slot.meta,1); + //context.world().setBlock(slot.x, slot.y + 1, slot.z, slot.blockId, slot.meta + 8,1); context.world().setBlockMetadataWithNotify(slot.x, slot.y + 1, slot.z, slot.meta + 8,1); context.world().setBlockMetadataWithNotify(slot.x, slot.y, slot.z, slot.meta,1); diff --git a/common/buildcraft/api/bptblocks/BptBlockFluid.java b/common/buildcraft/api/bptblocks/BptBlockFluid.java index 1769c394..dc5cd325 100644 --- a/common/buildcraft/api/bptblocks/BptBlockFluid.java +++ b/common/buildcraft/api/bptblocks/BptBlockFluid.java @@ -1,12 +1,11 @@ /** - * Copyright (c) SpaceToad, 2011 + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.api.bptblocks; import buildcraft.api.blueprints.BptBlock; @@ -35,9 +34,9 @@ public class BptBlockFluid extends BptBlock { @Override public boolean isValid(BptSlotInfo slot, IBptContext context) { - if (slot.meta == 0) - return slot.blockId == context.world().getBlockId(slot.x, slot.y, slot.z) && context.world().getBlockMetadata(slot.x, slot.y, slot.z) == 0; - else + //if (slot.meta == 0) + // return slot.blockId == context.world().getBlockId(slot.x, slot.y, slot.z) && context.world().getBlockMetadata(slot.x, slot.y, slot.z) == 0; + //else return true; } @@ -53,9 +52,9 @@ public class BptBlockFluid extends BptBlock { @Override public void buildBlock(BptSlotInfo slot, IBptContext context) { - if (slot.meta == 0) { - context.world().setBlock(slot.x, slot.y, slot.z, slot.blockId, 0,1); - } + //if (slot.meta == 0) { + // context.world().setBlock(slot.x, slot.y, slot.z, slot.blockId, 0,1); + //} } } diff --git a/common/buildcraft/api/bptblocks/BptBlockIgnore.java b/common/buildcraft/api/bptblocks/BptBlockIgnore.java index 12a058bc..465143ca 100644 --- a/common/buildcraft/api/bptblocks/BptBlockIgnore.java +++ b/common/buildcraft/api/bptblocks/BptBlockIgnore.java @@ -1,12 +1,11 @@ -/** - * Copyright (c) SpaceToad, 2011 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * - * BuildCraft is distributed under the terms of the Minecraft Mod Public + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.api.bptblocks; import buildcraft.api.blueprints.BptBlock; @@ -24,7 +23,7 @@ public class BptBlockIgnore extends BptBlock { @Override public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList requirements) { - requirements.add(new ItemStack(slot.blockId, 0, 0)); + //requirements.add(new ItemStack(slot.blockId, 0, 0)); } @Override diff --git a/common/buildcraft/api/bptblocks/BptBlockIgnoreMeta.java b/common/buildcraft/api/bptblocks/BptBlockIgnoreMeta.java index 7f39f637..4f60fb2f 100644 --- a/common/buildcraft/api/bptblocks/BptBlockIgnoreMeta.java +++ b/common/buildcraft/api/bptblocks/BptBlockIgnoreMeta.java @@ -1,12 +1,11 @@ -/** - * Copyright (c) SpaceToad, 2011 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * - * BuildCraft is distributed under the terms of the Minecraft Mod Public + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.api.bptblocks; import buildcraft.api.blueprints.BptBlock; @@ -24,11 +23,12 @@ public class BptBlockIgnoreMeta extends BptBlock { @Override public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList requirements) { - requirements.add(new ItemStack(slot.blockId, 1, 0)); + //requirements.add(new ItemStack(slot.blockId, 1, 0)); } @Override public boolean isValid(BptSlotInfo slot, IBptContext context) { - return slot.blockId == context.world().getBlockId(slot.x, slot.y, slot.z); + //return slot.blockId == context.world().getBlockId(slot.x, slot.y, slot.z); + return false; } } diff --git a/common/buildcraft/api/bptblocks/BptBlockInventory.java b/common/buildcraft/api/bptblocks/BptBlockInventory.java index 0cebe58f..e307eb18 100644 --- a/common/buildcraft/api/bptblocks/BptBlockInventory.java +++ b/common/buildcraft/api/bptblocks/BptBlockInventory.java @@ -1,3 +1,12 @@ + +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.api.bptblocks; import buildcraft.api.blueprints.BptBlock; @@ -17,7 +26,7 @@ public class BptBlockInventory extends BptBlock { public void buildBlock(BptSlotInfo slot, IBptContext context) { super.buildBlock(slot, context); - IInventory inv = (IInventory) context.world().getBlockTileEntity(slot.x, slot.y, slot.z); + IInventory inv = (IInventory) context.world().getTileEntity(slot.x, slot.y, slot.z); for (int i = 0; i < inv.getSizeInventory(); ++i) { inv.setInventorySlotContents(i, null); diff --git a/common/buildcraft/api/bptblocks/BptBlockLever.java b/common/buildcraft/api/bptblocks/BptBlockLever.java index b9a8e1c4..d731c238 100644 --- a/common/buildcraft/api/bptblocks/BptBlockLever.java +++ b/common/buildcraft/api/bptblocks/BptBlockLever.java @@ -1,12 +1,11 @@ -/** - * Copyright (c) SpaceToad, 2011 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * - * BuildCraft is distributed under the terms of the Minecraft Mod Public + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.api.bptblocks; import buildcraft.api.blueprints.BptSlotInfo; @@ -23,7 +22,7 @@ public class BptBlockLever extends BptBlockWallSide { @Override public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList requirements) { - requirements.add(new ItemStack(slot.blockId, 1, 0)); + //requirements.add(new ItemStack(slot.blockId, 1, 0)); } @Override diff --git a/common/buildcraft/api/bptblocks/BptBlockPiston.java b/common/buildcraft/api/bptblocks/BptBlockPiston.java index b12693bd..8e3950cb 100644 --- a/common/buildcraft/api/bptblocks/BptBlockPiston.java +++ b/common/buildcraft/api/bptblocks/BptBlockPiston.java @@ -1,12 +1,11 @@ /** - * Copyright (c) SpaceToad, 2011 + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.api.bptblocks; import buildcraft.api.blueprints.BptSlotInfo; @@ -23,7 +22,7 @@ public class BptBlockPiston extends BptBlockRotateMeta { public void buildBlock(BptSlotInfo slot, IBptContext context) { int meta = slot.meta & 7; - context.world().setBlock(slot.x, slot.y, slot.z, slot.blockId, meta,1); + //context.world().setBlock(slot.x, slot.y, slot.z, slot.blockId, meta,1); } } diff --git a/common/buildcraft/api/bptblocks/BptBlockPumpkin.java b/common/buildcraft/api/bptblocks/BptBlockPumpkin.java index 16049346..4eff9e4c 100644 --- a/common/buildcraft/api/bptblocks/BptBlockPumpkin.java +++ b/common/buildcraft/api/bptblocks/BptBlockPumpkin.java @@ -1,12 +1,11 @@ -/** - * Copyright (c) SpaceToad, 2011 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * - * BuildCraft is distributed under the terms of the Minecraft Mod Public + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.api.bptblocks; import buildcraft.api.blueprints.BptBlock; @@ -24,12 +23,13 @@ public class BptBlockPumpkin extends BptBlock { @Override public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList requirements) { - requirements.add(new ItemStack(slot.blockId, 1, 0)); + //requirements.add(new ItemStack(slot.blockId, 1, 0)); } @Override public boolean isValid(BptSlotInfo slot, IBptContext context) { - return slot.blockId == context.world().getBlockId(slot.x, slot.y, slot.z); + //return slot.blockId == context.world().getBlockId(slot.x, slot.y, slot.z); + return false; } @Override diff --git a/common/buildcraft/api/bptblocks/BptBlockRedstoneRepeater.java b/common/buildcraft/api/bptblocks/BptBlockRedstoneRepeater.java index 8ac4f023..8852cb98 100644 --- a/common/buildcraft/api/bptblocks/BptBlockRedstoneRepeater.java +++ b/common/buildcraft/api/bptblocks/BptBlockRedstoneRepeater.java @@ -1,12 +1,11 @@ -/** - * Copyright (c) SpaceToad, 2011 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * - * BuildCraft is distributed under the terms of the Minecraft Mod Public + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.api.bptblocks; import buildcraft.api.blueprints.BptBlock; @@ -25,7 +24,7 @@ public class BptBlockRedstoneRepeater extends BptBlock { @Override public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList requirements) { - requirements.add(new ItemStack(Item.redstoneRepeater)); + //requirements.add(new ItemStack(Item.redstoneRepeater)); } @Override diff --git a/common/buildcraft/api/bptblocks/BptBlockRotateInventory.java b/common/buildcraft/api/bptblocks/BptBlockRotateInventory.java index 6fcc30a8..e0b9bd67 100644 --- a/common/buildcraft/api/bptblocks/BptBlockRotateInventory.java +++ b/common/buildcraft/api/bptblocks/BptBlockRotateInventory.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.api.bptblocks; import buildcraft.api.blueprints.BptSlotInfo; @@ -16,7 +24,7 @@ public class BptBlockRotateInventory extends BptBlockRotateMeta { public void buildBlock(BptSlotInfo slot, IBptContext context) { super.buildBlock(slot, context); - IInventory inv = (IInventory) context.world().getBlockTileEntity(slot.x, slot.y, slot.z); + IInventory inv = (IInventory) context.world().getTileEntity(slot.x, slot.y, slot.z); for (int i = 0; i < inv.getSizeInventory(); ++i) { inv.setInventorySlotContents(i, null); diff --git a/common/buildcraft/api/bptblocks/BptBlockRotateMeta.java b/common/buildcraft/api/bptblocks/BptBlockRotateMeta.java index 4352b660..9066ee62 100644 --- a/common/buildcraft/api/bptblocks/BptBlockRotateMeta.java +++ b/common/buildcraft/api/bptblocks/BptBlockRotateMeta.java @@ -1,12 +1,11 @@ -/** - * Copyright (c) SpaceToad, 2011 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * - * BuildCraft is distributed under the terms of the Minecraft Mod Public + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.api.bptblocks; import buildcraft.api.blueprints.BptBlock; @@ -43,12 +42,13 @@ public class BptBlockRotateMeta extends BptBlock { @Override public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList requirements) { - requirements.add(new ItemStack(slot.blockId, 1, 0)); + //requirements.add(new ItemStack(slot.blockId, 1, 0)); } @Override public boolean isValid(BptSlotInfo slot, IBptContext context) { - return slot.blockId == context.world().getBlockId(slot.x, slot.y, slot.z); + //return slot.blockId == context.world().getBlockId(slot.x, slot.y, slot.z); + return false; } @Override diff --git a/common/buildcraft/api/bptblocks/BptBlockSign.java b/common/buildcraft/api/bptblocks/BptBlockSign.java index f7bd1338..29af85d4 100644 --- a/common/buildcraft/api/bptblocks/BptBlockSign.java +++ b/common/buildcraft/api/bptblocks/BptBlockSign.java @@ -1,12 +1,11 @@ /** - * Copyright (c) SpaceToad, 2011 + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.api.bptblocks; import buildcraft.api.blueprints.BlockSignature; @@ -31,7 +30,7 @@ public class BptBlockSign extends BptBlock { @Override public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList requirements) { - requirements.add(new ItemStack(Item.sign)); + //requirements.add(new ItemStack(Item.sign)); } @Override diff --git a/common/buildcraft/api/bptblocks/BptBlockStairs.java b/common/buildcraft/api/bptblocks/BptBlockStairs.java index 4dc061a4..391112c9 100644 --- a/common/buildcraft/api/bptblocks/BptBlockStairs.java +++ b/common/buildcraft/api/bptblocks/BptBlockStairs.java @@ -1,12 +1,11 @@ -/** - * Copyright (c) SpaceToad, 2011 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * - * BuildCraft is distributed under the terms of the Minecraft Mod Public + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.api.bptblocks; import buildcraft.api.blueprints.BptBlock; @@ -24,12 +23,13 @@ public class BptBlockStairs extends BptBlock { @Override public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList requirements) { - requirements.add(new ItemStack(slot.blockId, 1, 0)); + //requirements.add(new ItemStack(slot.blockId, 1, 0)); } @Override public boolean isValid(BptSlotInfo slot, IBptContext context) { - return slot.blockId == context.world().getBlockId(slot.x, slot.y, slot.z); + //return slot.blockId == context.world().getBlockId(slot.x, slot.y, slot.z); + return false; } @Override diff --git a/common/buildcraft/api/bptblocks/BptBlockWallSide.java b/common/buildcraft/api/bptblocks/BptBlockWallSide.java index 74ff3f0f..ac0d8ada 100644 --- a/common/buildcraft/api/bptblocks/BptBlockWallSide.java +++ b/common/buildcraft/api/bptblocks/BptBlockWallSide.java @@ -1,12 +1,11 @@ -/** - * Copyright (c) SpaceToad, 2011 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * - * BuildCraft is distributed under the terms of the Minecraft Mod Public + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.api.bptblocks; import buildcraft.api.blueprints.BptBlock; @@ -24,7 +23,7 @@ public class BptBlockWallSide extends BptBlock { @Override public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList requirements) { - requirements.add(new ItemStack(slot.blockId, 1, 0)); + //requirements.add(new ItemStack(slot.blockId, 1, 0)); } @Override diff --git a/common/buildcraft/api/builder/BlockHandler.java b/common/buildcraft/api/builder/BlockHandler.java index a6670091..160a200f 100644 --- a/common/buildcraft/api/builder/BlockHandler.java +++ b/common/buildcraft/api/builder/BlockHandler.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.api.builder; import java.util.ArrayList; @@ -5,8 +13,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import buildcraft.builders.blueprints.IBlueprintBuilderAgent; -import buildcraft.builders.blueprints.BlueprintBuilder.SchematicBuilder; import net.minecraft.block.Block; import net.minecraft.inventory.IInventory; import net.minecraft.item.Item; @@ -14,7 +20,9 @@ import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; +import buildcraft.builders.blueprints.BlueprintBuilder.SchematicBuilder; +import buildcraft.builders.blueprints.IBlueprintBuilderAgent; /** * BlockHandlers are used to serialize blocks for saving/loading from @@ -22,41 +30,45 @@ import net.minecraftforge.common.ForgeDirection; * * To implement your own, you should extend this class and override the * functions as needed. - * - * @author CovertJaguar */ public class BlockHandler { - private static final Map handlers = new HashMap(); + private static final Map handlers = new HashMap(); private final int id; public static BlockHandler get(Item item) { - if (item == null) + if (item == null) { return null; - return get(item.itemID); + } else { + return get(item); + } } public static BlockHandler get(Block block) { - if (block == null) + if (block == null) { return null; - return get(block.blockID); + } else { + return get(block); + } } public static BlockHandler get(int id) { BlockHandler handler = handlers.get(id); + if (handler == null) { handler = new BlockHandler(id); registerHandler(id, handler); } + return handler; } public static void registerHandler(Block block, BlockHandler handler) { - handlers.put(block.blockID, handler); + handlers.put(block, handler); } public static void registerHandler(Item item, BlockHandler handler) { - handlers.put(item.itemID, handler); + handlers.put(item, handler); } public static void registerHandler(int id, BlockHandler handler) { @@ -79,21 +91,22 @@ public class BlockHandler { * We will also skip any blocks that drop actual items like Ore blocks. */ public boolean canSaveToSchematic(World world, int x, int y, int z) { - if (!(Item.itemsList[id] instanceof ItemBlock)) - return false; + Block block = Block.getBlockById(id); - Block block = Block.blocksList[id]; - if (block == null) + if (block == null) { return false; + } int meta = world.getBlockMetadata(x, y, z); - try { - if (block.idDropped(meta, null, 0) != id) - return false; + try { + if (block.getItemDropped(meta, null, 0) != Item.getItemFromBlock(block)) { + return false; + } } catch (NullPointerException ex) { return false; } + return !block.hasTileEntity(meta); } @@ -105,21 +118,24 @@ public class BlockHandler { * We will also skip any blocks that drop actual items like Ore blocks. */ public boolean canSaveToSchematic(ItemStack stack) { - if (stack == null) - return false; - if (!(stack.getItem() instanceof ItemBlock)) + if (stack == null) { return false; + } - if (id > Block.blocksList.length) + if (!(stack.getItem() instanceof ItemBlock)) { return false; + } - Block block = Block.blocksList[id]; - if (block == null) + Block block = Block.getBlockById(id); + + if (block == null) { return false; + } try { - if (block.idDropped(stack.getItemDamage(), null, 0) != id) + if (block.getItemDropped(stack.getItemDamage(), null, 0) != Item.getItemFromBlock(block)) { return false; + } } catch (NullPointerException ex) { return false; } @@ -159,8 +175,9 @@ public class BlockHandler { */ public List getCostForSchematic(NBTTagCompound data) { List cost = new ArrayList(); - Block block = Block.blocksList[id]; - cost.add(new ItemStack(block.idDropped(data.getByte("blockMeta"), BlueprintHelpers.RANDOM, 0), 1, block.damageDropped(data.getByte("blockMeta")))); + Block block = Block.getBlockById(id); + cost.add(new ItemStack(block.getItemDropped(data.getByte("blockMeta"), BlueprintHelpers.RANDOM, 0), 1, block.damageDropped(data.getByte("blockMeta")))); + return cost; } @@ -203,8 +220,10 @@ public class BlockHandler { if (builderInventory != null) { List requiredItems = getCostForSchematic(builder.schematic.data); List slotsToConsume = new ArrayList(); + for (ItemStack cost : requiredItems) { boolean found = false; + for (int slot = 0; slot < builderInventory.getSizeInventory(); slot++) { if (areItemsEqual(builderInventory.getStackInSlot(slot), cost)) { slotsToConsume.add(slot); @@ -212,22 +231,26 @@ public class BlockHandler { break; } } - if (!found) + + if (!found) { return false; + } } for (Integer slot : slotsToConsume) { builderInventory.setInventorySlotContents(slot, BlueprintHelpers.consumeItem(builderInventory.getStackInSlot(slot))); } } - return world.setBlock(builder.getX(), builder.getY(), builder.getZ(), Block.blocksList[id].blockID, builder.schematic.data.getByte("blockMeta"), 3); + + return world.setBlock(builder.getX(), builder.getY(), builder.getZ(), Block.getBlockById(id), 0, 3); } /** * Checks if the block matches the schematic. */ public boolean doesBlockMatchSchematic(World world, int x, int y, int z, ForgeDirection blueprintOrientation, NBTTagCompound data) { - if (id != world.getBlockId(x, y, z)) + if (Block.getBlockById(id) != world.getBlock(x, y, z)) { return false; + } return !data.hasKey("blockMeta") || data.getByte("blockMeta") == world.getBlockMetadata(x, y, z); } diff --git a/common/buildcraft/api/builder/BlueprintHelpers.java b/common/buildcraft/api/builder/BlueprintHelpers.java index e5360c1d..a253e861 100644 --- a/common/buildcraft/api/builder/BlueprintHelpers.java +++ b/common/buildcraft/api/builder/BlueprintHelpers.java @@ -1,13 +1,19 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.api.builder; import java.util.Random; import net.minecraft.item.ItemStack; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; /** * A collection of helpful functions to make your life easier. - * - * @author CovertJaguar */ public class BlueprintHelpers { @@ -43,7 +49,7 @@ public class BlueprintHelpers { public static ItemStack consumeItem(ItemStack stack) { if (stack.stackSize == 1) { if (stack.getItem().hasContainerItem()) { - return stack.getItem().getContainerItemStack(stack); + return stack.getItem().getContainerItem(stack); } else { return null; } diff --git a/common/buildcraft/api/core/BuildCraftAPI.java b/common/buildcraft/api/core/BuildCraftAPI.java index 87c45fdf..4dadfae9 100644 --- a/common/buildcraft/api/core/BuildCraftAPI.java +++ b/common/buildcraft/api/core/BuildCraftAPI.java @@ -1,14 +1,16 @@ /** - * Copyright (c) SpaceToad, 2011 + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.api.core; +import java.util.HashSet; +import java.util.Set; + import net.minecraft.block.Block; public class BuildCraftAPI { @@ -16,5 +18,5 @@ public class BuildCraftAPI { public static final int LAST_ORIGINAL_BLOCK = 122; public static final int LAST_ORIGINAL_ITEM = 126; - public static final boolean[] softBlocks = new boolean[Block.blocksList.length]; + public static final Set softBlocks = new HashSet(); } diff --git a/common/buildcraft/api/core/IAreaProvider.java b/common/buildcraft/api/core/IAreaProvider.java index fa905d2c..2338e0c7 100644 --- a/common/buildcraft/api/core/IAreaProvider.java +++ b/common/buildcraft/api/core/IAreaProvider.java @@ -1,12 +1,11 @@ -/** - * Copyright (c) SpaceToad, 2011 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * - * BuildCraft is distributed under the terms of the Minecraft Mod Public + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.api.core; /** diff --git a/common/buildcraft/api/core/IBox.java b/common/buildcraft/api/core/IBox.java index 6337a96c..bfcafe6c 100644 --- a/common/buildcraft/api/core/IBox.java +++ b/common/buildcraft/api/core/IBox.java @@ -1,12 +1,11 @@ -/** - * Copyright (c) SpaceToad, 2011 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * - * BuildCraft is distributed under the terms of the Minecraft Mod Public + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.api.core; import net.minecraft.world.World; diff --git a/common/buildcraft/api/core/IIconProvider.java b/common/buildcraft/api/core/IIconProvider.java index 666d32e3..3df0b6d9 100644 --- a/common/buildcraft/api/core/IIconProvider.java +++ b/common/buildcraft/api/core/IIconProvider.java @@ -1,9 +1,17 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.api.core; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.client.renderer.texture.IconRegister; -import net.minecraft.util.Icon; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.util.IIcon; public interface IIconProvider { @@ -12,13 +20,13 @@ public interface IIconProvider { * @return */ @SideOnly(Side.CLIENT) - public Icon getIcon(int iconIndex); + public IIcon getIcon(int iconIndex); /** * A call for the provider to register its Icons. This may be called multiple times but should only be executed once per provider * @param iconRegister */ @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister iconRegister); + public void registerIcons(IIconRegister iconRegister); } diff --git a/common/buildcraft/api/core/LaserKind.java b/common/buildcraft/api/core/LaserKind.java index 24e66dba..85f5ce8e 100644 --- a/common/buildcraft/api/core/LaserKind.java +++ b/common/buildcraft/api/core/LaserKind.java @@ -1,12 +1,11 @@ -/** - * Copyright (c) SpaceToad, 2011 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * - * BuildCraft is distributed under the terms of the Minecraft Mod Public + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.api.core; public enum LaserKind { diff --git a/common/buildcraft/api/core/Position.java b/common/buildcraft/api/core/Position.java index 5cdddbc8..3ea1a731 100644 --- a/common/buildcraft/api/core/Position.java +++ b/common/buildcraft/api/core/Position.java @@ -1,17 +1,16 @@ /** - * Copyright (c) SpaceToad, 2011 + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.api.core; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; public class Position { diff --git a/common/buildcraft/api/core/SafeTimeTracker.java b/common/buildcraft/api/core/SafeTimeTracker.java index 14d94230..46ca2809 100644 --- a/common/buildcraft/api/core/SafeTimeTracker.java +++ b/common/buildcraft/api/core/SafeTimeTracker.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.api.core; diff --git a/common/buildcraft/api/core/StackWrapper.java b/common/buildcraft/api/core/StackWrapper.java index f46652c4..a155c1cd 100644 --- a/common/buildcraft/api/core/StackWrapper.java +++ b/common/buildcraft/api/core/StackWrapper.java @@ -1,19 +1,16 @@ -/* - * Copyright (c) SpaceToad, 2011-2012 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * + * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.api.core; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -/** - * - * @author CovertJaguar - */ public class StackWrapper { public final ItemStack stack; @@ -25,10 +22,15 @@ public class StackWrapper { @Override public int hashCode() { int hash = 5; - hash = 67 * hash + stack.itemID; + + hash = 67 * hash + stack.getItem().hashCode(); + hash = 67 * hash + stack.getItemDamage(); - if (stack.stackTagCompound != null) + + if (stack.stackTagCompound != null) { hash = 67 * hash + stack.stackTagCompound.hashCode(); + } + return hash; } @@ -39,7 +41,7 @@ public class StackWrapper { if (getClass() != obj.getClass()) return false; final StackWrapper other = (StackWrapper) obj; - if (stack.itemID != other.stack.itemID) + if (stack.getItem() != other.stack.getItem()) return false; if (stack.getHasSubtypes() && stack.getItemDamage() != other.stack.getItemDamage()) return false; diff --git a/common/buildcraft/api/filler/FillerManager.java b/common/buildcraft/api/filler/FillerManager.java index ae104c59..cd774d46 100644 --- a/common/buildcraft/api/filler/FillerManager.java +++ b/common/buildcraft/api/filler/FillerManager.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.api.filler; public class FillerManager { diff --git a/common/buildcraft/api/filler/IFillerPattern.java b/common/buildcraft/api/filler/IFillerPattern.java index 45dce17b..6c1c4182 100644 --- a/common/buildcraft/api/filler/IFillerPattern.java +++ b/common/buildcraft/api/filler/IFillerPattern.java @@ -1,11 +1,19 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.api.filler; import buildcraft.api.core.IBox; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Icon; -import net.minecraftforge.common.ForgeDirection; +import net.minecraft.util.IIcon; +import net.minecraftforge.common.util.ForgeDirection; public interface IFillerPattern { @@ -23,7 +31,7 @@ public interface IFillerPattern { public IPatternIterator createPatternIterator(TileEntity tile, IBox box, ForgeDirection orientation); @SideOnly(Side.CLIENT) - public Icon getIcon(); + public IIcon getIcon(); public String getDisplayName(); } diff --git a/common/buildcraft/api/filler/IFillerRegistry.java b/common/buildcraft/api/filler/IFillerRegistry.java index f0b4c950..ec9bf29f 100644 --- a/common/buildcraft/api/filler/IFillerRegistry.java +++ b/common/buildcraft/api/filler/IFillerRegistry.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.api.filler; import buildcraft.api.gates.IAction; diff --git a/common/buildcraft/api/filler/IPatternIterator.java b/common/buildcraft/api/filler/IPatternIterator.java index 0ea8c202..efce4c43 100644 --- a/common/buildcraft/api/filler/IPatternIterator.java +++ b/common/buildcraft/api/filler/IPatternIterator.java @@ -1,7 +1,7 @@ -/* - * Copyright (c) SpaceToad, 2011-2012 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * + * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt @@ -10,10 +10,6 @@ package buildcraft.api.filler; import net.minecraft.item.ItemStack; -/** - * - * @author CovertJaguar - */ public interface IPatternIterator { public boolean iteratePattern(ItemStack stackToPlace); diff --git a/common/buildcraft/api/fuels/IronEngineCoolant.java b/common/buildcraft/api/fuels/IronEngineCoolant.java index 50c2097c..3e1de954 100644 --- a/common/buildcraft/api/fuels/IronEngineCoolant.java +++ b/common/buildcraft/api/fuels/IronEngineCoolant.java @@ -1,15 +1,19 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.api.fuels; import buildcraft.api.core.StackWrapper; + import java.util.HashMap; import java.util.Map; + +import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.Fluid; @@ -60,7 +64,7 @@ public final class IronEngineCoolant { * @param coolant */ public static void addCoolant(final ItemStack stack, final FluidStack coolant) { - if (stack != null && Item.itemsList[stack.itemID] != null && coolant != null) { + if (stack != null && stack.getItem() != null && coolant != null) { solidCoolants.put(new StackWrapper(stack), coolant); } } @@ -73,8 +77,12 @@ public final class IronEngineCoolant { * @param stack * @param coolant */ - public static void addCoolant(final int itemId, final int metadata, final FluidStack coolant) { - addCoolant(new ItemStack(itemId, 1, metadata), coolant); + public static void addCoolant(final Item item, final int metadata, final FluidStack coolant) { + addCoolant(new ItemStack(item, 1, metadata), coolant); + } + + public static void addCoolant(final Block block, final int metadata, final FluidStack coolant) { + addCoolant(new ItemStack(block, 1, metadata), coolant); } public static boolean isCoolant(Fluid fluid) { diff --git a/common/buildcraft/api/fuels/IronEngineFuel.java b/common/buildcraft/api/fuels/IronEngineFuel.java index 3ab5ca2a..20b14eb5 100644 --- a/common/buildcraft/api/fuels/IronEngineFuel.java +++ b/common/buildcraft/api/fuels/IronEngineFuel.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.api.fuels; diff --git a/common/buildcraft/api/gates/ActionManager.java b/common/buildcraft/api/gates/ActionManager.java index a4b3a5ba..44e4b741 100644 --- a/common/buildcraft/api/gates/ActionManager.java +++ b/common/buildcraft/api/gates/ActionManager.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.api.gates; import buildcraft.api.transport.IPipeTile; diff --git a/common/buildcraft/api/gates/GateExpansionController.java b/common/buildcraft/api/gates/GateExpansionController.java index 3f047ac5..20f38713 100644 --- a/common/buildcraft/api/gates/GateExpansionController.java +++ b/common/buildcraft/api/gates/GateExpansionController.java @@ -1,7 +1,7 @@ -/* - * Copyright (c) SpaceToad, 2011-2012 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * + * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt @@ -12,10 +12,6 @@ import java.util.List; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; -/** - * - * @author CovertJaguar - */ public abstract class GateExpansionController { public final IGateExpansion type; diff --git a/common/buildcraft/api/gates/GateExpansions.java b/common/buildcraft/api/gates/GateExpansions.java index d3ec09df..b8732442 100644 --- a/common/buildcraft/api/gates/GateExpansions.java +++ b/common/buildcraft/api/gates/GateExpansions.java @@ -1,7 +1,7 @@ -/* - * Copyright (c) SpaceToad, 2011-2012 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * + * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt @@ -15,10 +15,6 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; -/** - * - * @author CovertJaguar - */ public final class GateExpansions { private static final Map expansions = new HashMap(); diff --git a/common/buildcraft/api/gates/IAction.java b/common/buildcraft/api/gates/IAction.java index 689d22a9..38f134eb 100644 --- a/common/buildcraft/api/gates/IAction.java +++ b/common/buildcraft/api/gates/IAction.java @@ -1,19 +1,27 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.api.gates; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.client.renderer.texture.IconRegister; -import net.minecraft.util.Icon; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.util.IIcon; public interface IAction { String getUniqueTag(); @SideOnly(Side.CLIENT) - Icon getIcon(); + IIcon getIcon(); @SideOnly(Side.CLIENT) - void registerIcons(IconRegister iconRegister); + void registerIcons(IIconRegister iconRegister); boolean hasParameter(); diff --git a/common/buildcraft/api/gates/IActionProvider.java b/common/buildcraft/api/gates/IActionProvider.java index 6c64b57e..6712ca6f 100644 --- a/common/buildcraft/api/gates/IActionProvider.java +++ b/common/buildcraft/api/gates/IActionProvider.java @@ -1,12 +1,11 @@ -/** - * Copyright (c) SpaceToad, 2011 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * - * BuildCraft is distributed under the terms of the Minecraft Mod Public + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.api.gates; import java.util.LinkedList; diff --git a/common/buildcraft/api/gates/IActionReceptor.java b/common/buildcraft/api/gates/IActionReceptor.java index c4637adc..86916298 100644 --- a/common/buildcraft/api/gates/IActionReceptor.java +++ b/common/buildcraft/api/gates/IActionReceptor.java @@ -1,12 +1,11 @@ -/** - * Copyright (c) SpaceToad, 2012 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * - * BuildCraft is distributed under the terms of the Minecraft Mod Public + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.api.gates; public interface IActionReceptor { diff --git a/common/buildcraft/api/gates/IGateExpansion.java b/common/buildcraft/api/gates/IGateExpansion.java index 46ea76a0..361f0a4d 100644 --- a/common/buildcraft/api/gates/IGateExpansion.java +++ b/common/buildcraft/api/gates/IGateExpansion.java @@ -1,21 +1,17 @@ -/* - * Copyright (c) SpaceToad, 2011-2012 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * + * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.api.gates; -import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Icon; +import net.minecraft.util.IIcon; -/** - * - * @author CovertJaguar - */ public interface IGateExpansion { String getUniqueIdentifier(); @@ -24,11 +20,11 @@ public interface IGateExpansion { GateExpansionController makeController(TileEntity pipeTile); - void registerBlockOverlay(IconRegister iconRegister); + void registerBlockOverlay(IIconRegister iconRegister); - void registerItemOverlay(IconRegister iconRegister); + void registerItemOverlay(IIconRegister iconRegister); - Icon getOverlayBlock(); + IIcon getOverlayBlock(); - Icon getOverlayItem(); + IIcon getOverlayItem(); } diff --git a/common/buildcraft/api/gates/IOverrideDefaultTriggers.java b/common/buildcraft/api/gates/IOverrideDefaultTriggers.java index 8a2e47c6..a105f52d 100644 --- a/common/buildcraft/api/gates/IOverrideDefaultTriggers.java +++ b/common/buildcraft/api/gates/IOverrideDefaultTriggers.java @@ -1,12 +1,11 @@ -/** - * Copyright (c) SpaceToad, 2011 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * - * BuildCraft is distributed under the terms of the Minecraft Mod Public + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.api.gates; import java.util.LinkedList; diff --git a/common/buildcraft/api/gates/ITileTrigger.java b/common/buildcraft/api/gates/ITileTrigger.java index 2063cbb8..93c84e01 100644 --- a/common/buildcraft/api/gates/ITileTrigger.java +++ b/common/buildcraft/api/gates/ITileTrigger.java @@ -1,7 +1,7 @@ -/* - * Copyright (c) SpaceToad, 2011-2012 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * + * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt @@ -9,12 +9,8 @@ package buildcraft.api.gates; import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; -/** - * - * @author CovertJaguar - */ public interface ITileTrigger extends ITrigger { /** diff --git a/common/buildcraft/api/gates/ITrigger.java b/common/buildcraft/api/gates/ITrigger.java index e3b15d82..affc418b 100644 --- a/common/buildcraft/api/gates/ITrigger.java +++ b/common/buildcraft/api/gates/ITrigger.java @@ -1,9 +1,17 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.api.gates; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.client.renderer.texture.IconRegister; -import net.minecraft.util.Icon; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.util.IIcon; public interface ITrigger { @@ -16,10 +24,10 @@ public interface ITrigger { String getUniqueTag(); @SideOnly(Side.CLIENT) - Icon getIcon(); + IIcon getIcon(); @SideOnly(Side.CLIENT) - void registerIcons(IconRegister iconRegister); + void registerIcons(IIconRegister iconRegister); /** * Return true if this trigger can accept parameters diff --git a/common/buildcraft/api/gates/ITriggerParameter.java b/common/buildcraft/api/gates/ITriggerParameter.java index b097667a..8570cf0f 100644 --- a/common/buildcraft/api/gates/ITriggerParameter.java +++ b/common/buildcraft/api/gates/ITriggerParameter.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.api.gates; import net.minecraft.item.ItemStack; diff --git a/common/buildcraft/api/gates/ITriggerProvider.java b/common/buildcraft/api/gates/ITriggerProvider.java index 471eac10..1966e73b 100644 --- a/common/buildcraft/api/gates/ITriggerProvider.java +++ b/common/buildcraft/api/gates/ITriggerProvider.java @@ -1,12 +1,11 @@ -/** - * Copyright (c) SpaceToad, 2011 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * - * BuildCraft is distributed under the terms of the Minecraft Mod Public + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.api.gates; import buildcraft.api.transport.IPipeTile; diff --git a/common/buildcraft/api/gates/TriggerParameter.java b/common/buildcraft/api/gates/TriggerParameter.java index 6295d1cd..46336c15 100644 --- a/common/buildcraft/api/gates/TriggerParameter.java +++ b/common/buildcraft/api/gates/TriggerParameter.java @@ -1,14 +1,14 @@ -/** - * Copyright (c) SpaceToad, 2011 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * - * BuildCraft is distributed under the terms of the Minecraft Mod Public + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.api.gates; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -49,7 +49,7 @@ public class TriggerParameter implements ITriggerParameter { if (stack != null) { NBTTagCompound tagCompound = new NBTTagCompound(); stack.writeToNBT(tagCompound); - compound.setCompoundTag("stack", tagCompound); + compound.setTag("stack", tagCompound); } } @@ -63,7 +63,7 @@ public class TriggerParameter implements ITriggerParameter { // Legacy code to prevent existing gates from losing their contents int itemID = compound.getInteger("itemID"); if (itemID != 0) { - stack = new ItemStack(itemID, 1, compound.getInteger("itemDMG")); + stack = new ItemStack((Item) Item.itemRegistry.getObject(itemID), 1, compound.getInteger("itemDMG")); return; } diff --git a/common/buildcraft/api/inventory/ISpecialInventory.java b/common/buildcraft/api/inventory/ISpecialInventory.java index 27b735d4..827a7a7d 100644 --- a/common/buildcraft/api/inventory/ISpecialInventory.java +++ b/common/buildcraft/api/inventory/ISpecialInventory.java @@ -1,9 +1,18 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.api.inventory; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; +@Deprecated public interface ISpecialInventory extends IInventory { /** diff --git a/common/buildcraft/api/power/ILaserTarget.java b/common/buildcraft/api/power/ILaserTarget.java index b4808004..8f859158 100644 --- a/common/buildcraft/api/power/ILaserTarget.java +++ b/common/buildcraft/api/power/ILaserTarget.java @@ -1,18 +1,13 @@ -/* - * Copyright (c) SpaceToad, 2011-2012 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * + * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.api.power; -/** - * Specifies a Tile Entity that can receive power via laser beam. - * - * @author cpw - */ public interface ILaserTarget { /** diff --git a/common/buildcraft/api/power/IPowerEmitter.java b/common/buildcraft/api/power/IPowerEmitter.java index 7ccf62b9..4bb48497 100644 --- a/common/buildcraft/api/power/IPowerEmitter.java +++ b/common/buildcraft/api/power/IPowerEmitter.java @@ -1,22 +1,20 @@ -/* - * Copyright (c) SpaceToad, 2011-2012 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * + * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.api.power; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; /** * Essentially only used for Wooden Power Pipe connection rules. * * This Tile Entity interface allows you to indicate that a block can emit power * from a specific side. - * - * @author CovertJaguar */ public interface IPowerEmitter { diff --git a/common/buildcraft/api/power/IPowerReceptor.java b/common/buildcraft/api/power/IPowerReceptor.java index 48b84c90..79586e9e 100644 --- a/common/buildcraft/api/power/IPowerReceptor.java +++ b/common/buildcraft/api/power/IPowerReceptor.java @@ -1,20 +1,19 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.api.power; import net.minecraft.world.World; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; /** * This interface should be implemented by any Tile Entity that wishes to be * able to receive power. - * - * @author CovertJaguar */ public interface IPowerReceptor { diff --git a/common/buildcraft/api/power/PowerHandler.java b/common/buildcraft/api/power/PowerHandler.java index f9c2eed2..8979086e 100644 --- a/common/buildcraft/api/power/PowerHandler.java +++ b/common/buildcraft/api/power/PowerHandler.java @@ -1,15 +1,16 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.api.power; import buildcraft.api.core.SafeTimeTracker; import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; /** * The PowerHandler is similar to FluidTank in that it holds your power and @@ -26,8 +27,6 @@ import net.minecraftforge.common.ForgeDirection; * * @see IPowerReceptor * @see IPowerEmitter - * - * @author CovertJaguar */ public final class PowerHandler { @@ -335,7 +334,7 @@ public final class PowerHandler { public void writeToNBT(NBTTagCompound data, String tag) { NBTTagCompound nbt = new NBTTagCompound(); nbt.setDouble("energyStored", energyStored); - data.setCompoundTag(tag, nbt); + data.setTag(tag, nbt); } public final class PowerReceiver { diff --git a/common/buildcraft/api/recipes/BuildcraftRecipes.java b/common/buildcraft/api/recipes/BuildcraftRecipes.java index 57f7e092..0454944d 100644 --- a/common/buildcraft/api/recipes/BuildcraftRecipes.java +++ b/common/buildcraft/api/recipes/BuildcraftRecipes.java @@ -1,17 +1,13 @@ -/* - * Copyright (c) SpaceToad, 2011-2012 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * + * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.api.recipes; -/** - * - * @author CovertJaguar - */ public final class BuildcraftRecipes { public static IAssemblyRecipeManager assemblyTable; diff --git a/common/buildcraft/api/recipes/IAssemblyRecipeManager.java b/common/buildcraft/api/recipes/IAssemblyRecipeManager.java index 10fb3bc9..30530919 100644 --- a/common/buildcraft/api/recipes/IAssemblyRecipeManager.java +++ b/common/buildcraft/api/recipes/IAssemblyRecipeManager.java @@ -1,7 +1,7 @@ -/* - * Copyright (c) SpaceToad, 2011-2012 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * + * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt @@ -11,10 +11,6 @@ package buildcraft.api.recipes; import java.util.List; import net.minecraft.item.ItemStack; -/** - * - * @author CovertJaguar - */ public interface IAssemblyRecipeManager { public static interface IAssemblyRecipe { diff --git a/common/buildcraft/api/recipes/IIntegrationRecipeManager.java b/common/buildcraft/api/recipes/IIntegrationRecipeManager.java index 9f796dbd..8b03055f 100644 --- a/common/buildcraft/api/recipes/IIntegrationRecipeManager.java +++ b/common/buildcraft/api/recipes/IIntegrationRecipeManager.java @@ -1,7 +1,7 @@ -/* - * Copyright (c) SpaceToad, 2011-2012 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * + * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt @@ -15,8 +15,6 @@ import net.minecraft.item.ItemStack; * The Integration Table's primary purpose is to modify an input item's NBT * data. As such its not a "traditional" type of recipe. Rather than predefined * inputs and outputs, it takes an input and transforms it. - * - * @author CovertJaguar */ public interface IIntegrationRecipeManager { diff --git a/common/buildcraft/api/recipes/IRefineryRecipeManager.java b/common/buildcraft/api/recipes/IRefineryRecipeManager.java index 01ca1a88..5e353a11 100644 --- a/common/buildcraft/api/recipes/IRefineryRecipeManager.java +++ b/common/buildcraft/api/recipes/IRefineryRecipeManager.java @@ -1,7 +1,7 @@ -/* - * Copyright (c) SpaceToad, 2011-2012 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * + * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt @@ -11,10 +11,6 @@ package buildcraft.api.recipes; import java.util.SortedSet; import net.minecraftforge.fluids.FluidStack; -/** - * - * @author CovertJaguar - */ public interface IRefineryRecipeManager { void addRecipe(FluidStack ingredient, FluidStack result, int energy, int delay); diff --git a/common/buildcraft/api/tools/IToolPipette.java b/common/buildcraft/api/tools/IToolPipette.java index d636523d..bca9d267 100644 --- a/common/buildcraft/api/tools/IToolPipette.java +++ b/common/buildcraft/api/tools/IToolPipette.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.api.tools; import net.minecraft.item.ItemStack; diff --git a/common/buildcraft/api/tools/IToolWrench.java b/common/buildcraft/api/tools/IToolWrench.java index bd0c3c59..a6c56e8d 100644 --- a/common/buildcraft/api/tools/IToolWrench.java +++ b/common/buildcraft/api/tools/IToolWrench.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.api.tools; import net.minecraft.entity.player.EntityPlayer; diff --git a/common/buildcraft/api/transport/IExtractionHandler.java b/common/buildcraft/api/transport/IExtractionHandler.java index e912f65b..4d56659e 100644 --- a/common/buildcraft/api/transport/IExtractionHandler.java +++ b/common/buildcraft/api/transport/IExtractionHandler.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.api.transport; import net.minecraft.world.World; diff --git a/common/buildcraft/api/transport/IPipeConnection.java b/common/buildcraft/api/transport/IPipeConnection.java index cbb1d003..39f14ee9 100644 --- a/common/buildcraft/api/transport/IPipeConnection.java +++ b/common/buildcraft/api/transport/IPipeConnection.java @@ -1,14 +1,15 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.api.transport; import buildcraft.api.transport.IPipeTile.PipeType; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; public interface IPipeConnection { diff --git a/common/buildcraft/api/transport/IPipeDefinition.java b/common/buildcraft/api/transport/IPipeDefinition.java index 4f5382a8..73a1c890 100644 --- a/common/buildcraft/api/transport/IPipeDefinition.java +++ b/common/buildcraft/api/transport/IPipeDefinition.java @@ -1,30 +1,26 @@ -/* - * Copyright (c) SpaceToad, 2011-2012 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * + * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.api.transport; -import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Icon; +import net.minecraft.util.IIcon; -/** - * - * @author CovertJaguar - */ public interface IPipeDefinition { String getUniqueTag(); - void registerIcons(IconRegister iconRegister); + void registerIcons(IIconRegister iconRegister); - Icon getIcon(int index); + IIcon getIcon(int index); - Icon getItemIcon(); + IIcon getItemIcon(); PipeBehavior makePipeBehavior(TileEntity tile); } diff --git a/common/buildcraft/api/transport/IPipeTile.java b/common/buildcraft/api/transport/IPipeTile.java index 00b76ce9..22f287f2 100644 --- a/common/buildcraft/api/transport/IPipeTile.java +++ b/common/buildcraft/api/transport/IPipeTile.java @@ -1,14 +1,15 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.api.transport; import net.minecraft.item.ItemStack; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; public interface IPipeTile { diff --git a/common/buildcraft/api/transport/PipeBehavior.java b/common/buildcraft/api/transport/PipeBehavior.java index bf1c2123..66c528cb 100644 --- a/common/buildcraft/api/transport/PipeBehavior.java +++ b/common/buildcraft/api/transport/PipeBehavior.java @@ -1,7 +1,7 @@ -/* - * Copyright (c) SpaceToad, 2011-2012 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * + * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt @@ -11,12 +11,8 @@ package buildcraft.api.transport; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; -/** - * - * @author CovertJaguar - */ public abstract class PipeBehavior { public final TileEntity tile; diff --git a/common/buildcraft/api/transport/PipeManager.java b/common/buildcraft/api/transport/PipeManager.java index c78c86e2..ae7bd918 100644 --- a/common/buildcraft/api/transport/PipeManager.java +++ b/common/buildcraft/api/transport/PipeManager.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.api.transport; import java.util.ArrayList; diff --git a/common/buildcraft/api/transport/PipeWire.java b/common/buildcraft/api/transport/PipeWire.java index a668ba55..8024e6bb 100644 --- a/common/buildcraft/api/transport/PipeWire.java +++ b/common/buildcraft/api/transport/PipeWire.java @@ -1,7 +1,7 @@ -/* - * Copyright (c) SpaceToad, 2011-2012 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * + * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt @@ -12,10 +12,6 @@ import java.util.Locale; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -/** - * - * @author CovertJaguar - */ public enum PipeWire { RED, BLUE, GREEN, YELLOW; diff --git a/common/buildcraft/builders/BlockArchitect.java b/common/buildcraft/builders/BlockArchitect.java index f23b454c..f8ce90cb 100644 --- a/common/buildcraft/builders/BlockArchitect.java +++ b/common/buildcraft/builders/BlockArchitect.java @@ -1,12 +1,11 @@ /** - * Copyright (c) SpaceToad, 2011 + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.builders; import buildcraft.BuildCraftBuilders; @@ -18,36 +17,39 @@ import buildcraft.core.proxy.CoreProxy; import buildcraft.core.utils.Utils; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; + import java.util.ArrayList; + +import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; -import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Icon; +import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; public class BlockArchitect extends BlockContainer { - Icon blockTextureSides; - Icon blockTextureFront; - Icon blockTextureTopPos; - Icon blockTextureTopNeg; - Icon blockTextureTopArchitect; + IIcon blockTextureSides; + IIcon blockTextureFront; + IIcon blockTextureTopPos; + IIcon blockTextureTopNeg; + IIcon blockTextureTopArchitect; - public BlockArchitect(int i) { - super(i, Material.iron); + public BlockArchitect() { + super(Material.iron); setHardness(5F); setCreativeTab(CreativeTabBuildCraft.MACHINES.get()); } @Override - public TileEntity createNewTileEntity(World var1) { + public TileEntity createNewTileEntity(World world, int metadata) { return new TileArchitect(); } @@ -84,7 +86,7 @@ public class BlockArchitect extends BlockContainer { return true; } else { - if (!CoreProxy.proxy.isRenderWorld(world)) { + if (!world.isRemote) { entityplayer.openGui(BuildCraftBuilders.instance, GuiIds.ARCHITECT_TABLE, world, i, j, k); } return true; @@ -93,10 +95,10 @@ public class BlockArchitect extends BlockContainer { } @Override - public void breakBlock(World world, int i, int j, int k, int par5, int par6) { + public void breakBlock(World world, int i, int j, int k, Block block, int par6) { Utils.preDestroyBlock(world, i, j, k); - super.breakBlock(world, i, j, k, par5, par6); + super.breakBlock(world, i, j, k, block, par6); } @Override @@ -109,7 +111,8 @@ public class BlockArchitect extends BlockContainer { } @SuppressWarnings({ "all" }) - public Icon getBlockTexture(IBlockAccess iblockaccess, int i, int j, int k, int l) { + @Override + public IIcon getIcon(IBlockAccess iblockaccess, int i, int j, int k, int l) { int m = iblockaccess.getBlockMetadata(i, j, k); if (l == 1) @@ -119,7 +122,7 @@ public class BlockArchitect extends BlockContainer { } @Override - public Icon getIcon(int i, int j) { + public IIcon getIcon(int i, int j) { if (j == 0 && i == 3) return blockTextureFront; @@ -132,15 +135,9 @@ public class BlockArchitect extends BlockContainer { return blockTextureSides; } - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - public void addCreativeItems(ArrayList itemList) { - itemList.add(new ItemStack(this)); - } - @Override @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister par1IconRegister) + public void registerBlockIcons(IIconRegister par1IconRegister) { blockTextureSides = par1IconRegister.registerIcon("buildcraft:architect_sides"); blockTextureTopNeg = par1IconRegister.registerIcon("buildcraft:architect_top_neg"); diff --git a/common/buildcraft/builders/BlockBlueprintLibrary.java b/common/buildcraft/builders/BlockBlueprintLibrary.java index befd2041..655667a0 100644 --- a/common/buildcraft/builders/BlockBlueprintLibrary.java +++ b/common/buildcraft/builders/BlockBlueprintLibrary.java @@ -1,12 +1,11 @@ /** - * Copyright (c) SpaceToad, 2011 + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.builders; import buildcraft.BuildCraftBuilders; @@ -20,21 +19,21 @@ import java.util.ArrayList; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; -import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Icon; +import net.minecraft.util.IIcon; import net.minecraft.world.World; public class BlockBlueprintLibrary extends BlockContainer { - private Icon textureTop; - private Icon textureSide; + private IIcon textureTop; + private IIcon textureSide; - public BlockBlueprintLibrary(int i) { - super(i, Material.wood); + public BlockBlueprintLibrary() { + super(Material.wood); setCreativeTab(CreativeTabBuildCraft.MACHINES.get()); setHardness(5F); } @@ -47,10 +46,10 @@ public class BlockBlueprintLibrary extends BlockContainer { if (entityplayer.isSneaking()) return false; - TileBlueprintLibrary tile = (TileBlueprintLibrary) world.getBlockTileEntity(i, j, k); + TileBlueprintLibrary tile = (TileBlueprintLibrary) world.getTileEntity(i, j, k); - if (!tile.locked || entityplayer.username.equals(tile.owner)) - if (!CoreProxy.proxy.isRenderWorld(world)) { + if (!tile.locked || entityplayer.getDisplayName().equals(tile.owner)) + if (!world.isRemote) { entityplayer.openGui(BuildCraftBuilders.instance, GuiIds.BLUEPRINT_LIBRARY, world, i, j, k); } @@ -58,12 +57,12 @@ public class BlockBlueprintLibrary extends BlockContainer { } @Override - public TileEntity createNewTileEntity(World var1) { + public TileEntity createNewTileEntity(World world, int metadata) { return new TileBlueprintLibrary(); } @Override - public Icon getIcon(int i, int j) { + public IIcon getIcon(int i, int j) { switch (i) { case 0: case 1: @@ -75,21 +74,15 @@ public class BlockBlueprintLibrary extends BlockContainer { @Override public void onBlockPlacedBy(World world, int i, int j, int k, EntityLivingBase entityliving, ItemStack stack) { - if (CoreProxy.proxy.isSimulating(world) && entityliving instanceof EntityPlayer) { - TileBlueprintLibrary tile = (TileBlueprintLibrary) world.getBlockTileEntity(i, j, k); - tile.owner = ((EntityPlayer) entityliving).username; + if (!world.isRemote && entityliving instanceof EntityPlayer) { + TileBlueprintLibrary tile = (TileBlueprintLibrary) world.getTileEntity(i, j, k); + tile.owner = ((EntityPlayer) entityliving).getDisplayName(); } } - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - public void addCreativeItems(ArrayList itemList) { - itemList.add(new ItemStack(this)); - } - @Override @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister par1IconRegister) + public void registerBlockIcons(IIconRegister par1IconRegister) { textureTop = par1IconRegister.registerIcon("buildcraft:library_topbottom"); textureSide = par1IconRegister.registerIcon("buildcraft:library_side"); diff --git a/common/buildcraft/builders/BlockBuilder.java b/common/buildcraft/builders/BlockBuilder.java index 090df842..7ffb08cf 100644 --- a/common/buildcraft/builders/BlockBuilder.java +++ b/common/buildcraft/builders/BlockBuilder.java @@ -19,37 +19,38 @@ import cpw.mods.fml.relauncher.SideOnly; import java.util.ArrayList; +import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; -import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Icon; +import net.minecraft.util.IIcon; import net.minecraft.world.World; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; public class BlockBuilder extends BlockContainer { - Icon blockTextureTop; - Icon blockTextureSide; - Icon blockTextureFront; + IIcon blockTextureTop; + IIcon blockTextureSide; + IIcon blockTextureFront; - public BlockBuilder(int i) { - super(i, Material.iron); + public BlockBuilder() { + super(Material.iron); setHardness(5F); setCreativeTab(CreativeTabBuildCraft.MACHINES.get()); } @Override - public TileEntity createNewTileEntity(World var1) { + public TileEntity createNewTileEntity(World world, int metadata) { return new TileBuilder(); } @Override - public Icon getIcon(int i, int j) { + public IIcon getIcon(int i, int j) { if (j == 0 && i == 3) return blockTextureFront; @@ -97,7 +98,7 @@ public class BlockBuilder extends BlockContainer { return true; } else { - if (!CoreProxy.proxy.isRenderWorld(world)) { + if (!world.isRemote) { entityplayer.openGui(BuildCraftBuilders.instance, GuiIds.BUILDER, world, i, j, k); } return true; @@ -114,20 +115,14 @@ public class BlockBuilder extends BlockContainer { } @Override - public void breakBlock(World world, int x, int y, int z, int par5, int par6) { + public void breakBlock(World world, int x, int y, int z, Block block, int par6) { Utils.preDestroyBlock(world, x, y, z); - super.breakBlock(world, x, y, z, par5, par6); - } - - @SuppressWarnings({"unchecked", "rawtypes"}) - @Override - public void addCreativeItems(ArrayList itemList) { - itemList.add(new ItemStack(this)); + super.breakBlock(world, x, y, z, block, par6); } @Override @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister par1IconRegister) { + public void registerBlockIcons(IIconRegister par1IconRegister) { blockTextureTop = par1IconRegister.registerIcon("buildcraft:builder_top"); blockTextureSide = par1IconRegister.registerIcon("buildcraft:builder_side"); blockTextureFront = par1IconRegister.registerIcon("buildcraft:builder_front"); diff --git a/common/buildcraft/builders/BlockFiller.java b/common/buildcraft/builders/BlockFiller.java index 0bc65309..f77c04d2 100644 --- a/common/buildcraft/builders/BlockFiller.java +++ b/common/buildcraft/builders/BlockFiller.java @@ -1,12 +1,11 @@ /** - * Copyright (c) SpaceToad, 2011 + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.builders; import buildcraft.BuildCraftBuilders; @@ -17,26 +16,29 @@ import buildcraft.core.proxy.CoreProxy; import buildcraft.core.utils.Utils; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; + import java.util.ArrayList; + +import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; -import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Icon; +import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; public class BlockFiller extends BlockContainer { - Icon textureSides; - Icon textureTopOn; - Icon textureTopOff; + IIcon textureSides; + IIcon textureTopOn; + IIcon textureTopOff; public IFillerPattern currentPattern; - public BlockFiller(int i) { - super(i, Material.iron); + public BlockFiller() { + super(Material.iron); setHardness(5F); setCreativeTab(CreativeTabBuildCraft.MACHINES.get()); @@ -49,7 +51,7 @@ public class BlockFiller extends BlockContainer { if (entityplayer.isSneaking()) return false; - if (!CoreProxy.proxy.isRenderWorld(world)) { + if (!world.isRemote) { entityplayer.openGui(BuildCraftBuilders.instance, GuiIds.FILLER, world, i, j, k); } return true; @@ -57,9 +59,9 @@ public class BlockFiller extends BlockContainer { } @Override - public Icon getBlockTexture(IBlockAccess world, int x, int y, int z, int side) { + public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { int m = world.getBlockMetadata(x, y, z); - TileEntity tile = world.getBlockTileEntity(x, y, z); + TileEntity tile = world.getTileEntity(x, y, z); if (tile != null && tile instanceof TileFiller) { TileFiller filler = (TileFiller) tile; @@ -78,7 +80,7 @@ public class BlockFiller extends BlockContainer { } @Override - public Icon getIcon(int i, int j) { + public IIcon getIcon(int i, int j) { if (i == 0 || i == 1) return textureTopOn; else @@ -86,25 +88,19 @@ public class BlockFiller extends BlockContainer { } @Override - public TileEntity createNewTileEntity(World var1) { + public TileEntity createNewTileEntity(World world, int metadata) { return new TileFiller(); } @Override - public void breakBlock(World world, int x, int y, int z, int par5, int par6) { + public void breakBlock(World world, int x, int y, int z, Block block, int par6) { Utils.preDestroyBlock(world, x, y, z); - super.breakBlock(world, x, y, z, par5, par6); - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - public void addCreativeItems(ArrayList itemList) { - itemList.add(new ItemStack(this)); + super.breakBlock(world, x, y, z, block, par6); } @Override @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister par1IconRegister) { + public void registerBlockIcons(IIconRegister par1IconRegister) { textureTopOn = par1IconRegister.registerIcon("buildcraft:blockFillerTopOn"); textureTopOff = par1IconRegister.registerIcon("buildcraft:blockFillerTopOff"); textureSides = par1IconRegister.registerIcon("buildcraft:blockFillerSides"); diff --git a/common/buildcraft/builders/BlockMarker.java b/common/buildcraft/builders/BlockMarker.java index f4001be8..7340f814 100644 --- a/common/buildcraft/builders/BlockMarker.java +++ b/common/buildcraft/builders/BlockMarker.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.builders; @@ -13,24 +14,27 @@ import buildcraft.core.CreativeTabBuildCraft; import buildcraft.core.utils.Utils; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; + import java.util.ArrayList; + +import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; -import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; public class BlockMarker extends BlockContainer { - public BlockMarker(int i) { - super(i, Material.circuits); + public BlockMarker() { + super(Material.circuits); - setLightValue(0.5F); + setLightLevel(0.5F); setCreativeTab(CreativeTabBuildCraft.MACHINES.get()); } @@ -80,20 +84,20 @@ public class BlockMarker extends BlockContainer { } @Override - public TileEntity createNewTileEntity(World var1) { + public TileEntity createNewTileEntity(World world, int metadata) { return new TileMarker(); } @Override public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer entityplayer, int par6, float par7, float par8, float par9) { - ((TileMarker) world.getBlockTileEntity(i, j, k)).tryConnection(); + ((TileMarker) world.getTileEntity(i, j, k)).tryConnection(); return true; } @Override - public void breakBlock(World world, int x, int y, int z, int par5, int par6) { + public void breakBlock(World world, int x, int y, int z, Block block, int par6) { Utils.preDestroyBlock(world, x, y, z); - super.breakBlock(world, x, y, z, par5, par6); + super.breakBlock(world, x, y, z, block, par6); } @Override @@ -112,8 +116,8 @@ public class BlockMarker extends BlockContainer { } @Override - public void onNeighborBlockChange(World world, int x, int y, int z, int blockId) { - ((TileMarker) world.getBlockTileEntity(x, y, z)).updateSignals(); + public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { + ((TileMarker) world.getTileEntity(x, y, z)).updateSignals(); dropTorchIfCantStay(world, x, y, z); } @@ -137,20 +141,14 @@ public class BlockMarker extends BlockContainer { private void dropTorchIfCantStay(World world, int x, int y, int z) { int meta = world.getBlockMetadata(x, y, z); if (!canPlaceBlockOnSide(world, x, y, z, meta)) { - dropBlockAsItem(world, x, y, z, BuildCraftBuilders.markerBlock.blockID, 0); - world.setBlock(x, y, z, 0); + dropBlockAsItem(world, x, y, z, 0, 0); + world.setBlockToAir(x, y, z); } } - @SuppressWarnings({"unchecked", "rawtypes"}) - @Override - public void addCreativeItems(ArrayList itemList) { - itemList.add(new ItemStack(this)); - } - @Override @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister iconRegister) { + public void registerBlockIcons(IIconRegister iconRegister) { this.blockIcon = iconRegister.registerIcon("buildcraft:blockMarker"); } } diff --git a/common/buildcraft/builders/BlockPathMarker.java b/common/buildcraft/builders/BlockPathMarker.java index 7389ac49..129e1dec 100644 --- a/common/buildcraft/builders/BlockPathMarker.java +++ b/common/buildcraft/builders/BlockPathMarker.java @@ -1,64 +1,59 @@ /** - * Copyright (c) SpaceToad, 2011 + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.builders; import buildcraft.core.utils.Utils; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; + import java.util.ArrayList; -import net.minecraft.client.renderer.texture.IconRegister; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Icon; +import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; public class BlockPathMarker extends BlockMarker { - private Icon activeMarker; + private IIcon activeMarker; - public BlockPathMarker(int i) { - super(i); + public BlockPathMarker() { } @Override - public TileEntity createNewTileEntity(World var1) { + public TileEntity createNewTileEntity(World world, int metadata) { return new TilePathMarker(); } @Override - public void breakBlock(World world, int x, int y, int z, int par5, int par6) { + public void breakBlock(World world, int x, int y, int z, Block block, int par6) { Utils.preDestroyBlock(world, x, y, z); - super.breakBlock(world, x, y, z, par5, par6); + super.breakBlock(world, x, y, z, block, par6); } @SuppressWarnings({ "all" }) // @Override (client only) - public Icon getBlockTexture(IBlockAccess iblockaccess, int i, int j, int k, int l) { - TilePathMarker marker = (TilePathMarker) iblockaccess.getBlockTileEntity(i, j, k); + public IIcon getIcon(IBlockAccess iblockaccess, int i, int j, int k, int l) { + TilePathMarker marker = (TilePathMarker) iblockaccess.getTileEntity(i, j, k); if (l == 1 || (marker != null && marker.tryingToConnect)) return activeMarker; else - return super.getBlockTexture(iblockaccess, i, j, k, l); - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - public void addCreativeItems(ArrayList itemList) { - itemList.add(new ItemStack(this)); + return super.getIcon(iblockaccess, i, j, k, l); } @Override @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister par1IconRegister) + public void registerBlockIcons(IIconRegister par1IconRegister) { blockIcon = par1IconRegister.registerIcon("buildcraft:blockPathMarker"); activeMarker = par1IconRegister.registerIcon("buildcraft:blockPathMarkerActive"); diff --git a/common/buildcraft/builders/BuilderProxy.java b/common/buildcraft/builders/BuilderProxy.java index de38e264..f2bb842a 100644 --- a/common/buildcraft/builders/BuilderProxy.java +++ b/common/buildcraft/builders/BuilderProxy.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.builders; import cpw.mods.fml.common.SidedProxy; diff --git a/common/buildcraft/builders/BuilderProxyClient.java b/common/buildcraft/builders/BuilderProxyClient.java index f06a6569..05734cc7 100644 --- a/common/buildcraft/builders/BuilderProxyClient.java +++ b/common/buildcraft/builders/BuilderProxyClient.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.builders; import buildcraft.BuildCraftBuilders; diff --git a/common/buildcraft/builders/BuildersProxy.java b/common/buildcraft/builders/BuildersProxy.java index 4d0166dd..dedfb570 100644 --- a/common/buildcraft/builders/BuildersProxy.java +++ b/common/buildcraft/builders/BuildersProxy.java @@ -1,12 +1,11 @@ /** - * Copyright (c) SpaceToad, 2011 + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.builders; import net.minecraft.block.Block; @@ -15,7 +14,7 @@ import net.minecraft.world.World; public class BuildersProxy { public static boolean canPlaceTorch(World world, int i, int j, int k) { - Block block = Block.blocksList[world.getBlockId(i, j, k)]; + Block block = world.getBlock(i, j, k); if (block == null || !block.renderAsNormalBlock()) return false; diff --git a/common/buildcraft/builders/ClientBuilderHook.java b/common/buildcraft/builders/ClientBuilderHook.java index d68e43b1..62d59507 100644 --- a/common/buildcraft/builders/ClientBuilderHook.java +++ b/common/buildcraft/builders/ClientBuilderHook.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.builders; import buildcraft.BuildCraftBuilders; diff --git a/common/buildcraft/builders/EventHandlerBuilders.java b/common/buildcraft/builders/EventHandlerBuilders.java index be4ac781..27ea7402 100644 --- a/common/buildcraft/builders/EventHandlerBuilders.java +++ b/common/buildcraft/builders/EventHandlerBuilders.java @@ -1,21 +1,21 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.builders; import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.relauncher.Side; -import net.minecraftforge.event.ForgeSubscribe; import net.minecraftforge.event.world.WorldEvent; public class EventHandlerBuilders { - @ForgeSubscribe + @SubscribeEvent public void handleWorldLoad(WorldEvent.Load event) { // Temporary solution // Please remove the world Load event when world Unload event gets implimented @@ -24,7 +24,7 @@ public class EventHandlerBuilders { } } - @ForgeSubscribe + @SubscribeEvent public void handleWorldUnload(WorldEvent.Unload event) { // When a world unloads clean from the list of available markers the ones // that were on the unloaded world diff --git a/common/buildcraft/builders/GuiHandler.java b/common/buildcraft/builders/GuiHandler.java index 3e0e20de..67bccb9b 100644 --- a/common/buildcraft/builders/GuiHandler.java +++ b/common/buildcraft/builders/GuiHandler.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.builders; import buildcraft.builders.gui.ContainerBlueprintLibrary; @@ -25,7 +33,7 @@ public class GuiHandler implements IGuiHandler { if (!world.blockExists(x, y, z)) return null; - TileEntity tile = world.getBlockTileEntity(x, y, z); + TileEntity tile = world.getTileEntity(x, y, z); switch (ID) { @@ -67,7 +75,7 @@ public class GuiHandler implements IGuiHandler { if (!world.blockExists(x, y, z)) return null; - TileEntity tile = world.getBlockTileEntity(x, y, z); + TileEntity tile = world.getTileEntity(x, y, z); switch (ID) { @@ -92,10 +100,11 @@ public class GuiHandler implements IGuiHandler { return new ContainerFiller(player.inventory, (TileFiller) tile); case GuiIds.URBANIST: - System.out.println ("CREATE U FROM SERVER: " + CoreProxy.proxy.isSimulating(tile.worldObj)); - if (!(tile instanceof TileUrbanist)) + if (!(tile instanceof TileUrbanist)) { return null; - return new ContainerUrbanist(player.inventory, (TileUrbanist) tile); + } else { + return new ContainerUrbanist(player.inventory, (TileUrbanist) tile); + } default: return null; diff --git a/common/buildcraft/builders/IBuilderHook.java b/common/buildcraft/builders/IBuilderHook.java index 4a7ae238..ce06a593 100644 --- a/common/buildcraft/builders/IBuilderHook.java +++ b/common/buildcraft/builders/IBuilderHook.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.builders; import buildcraft.core.blueprints.BptRootIndex; diff --git a/common/buildcraft/builders/ItemBlueprint.java b/common/buildcraft/builders/ItemBlueprint.java index 860e8e46..c486578f 100644 --- a/common/buildcraft/builders/ItemBlueprint.java +++ b/common/buildcraft/builders/ItemBlueprint.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011-2012 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.builders; @@ -23,8 +24,8 @@ import buildcraft.builders.blueprints.BlueprintId; public abstract class ItemBlueprint extends ItemBuildCraft { - public ItemBlueprint(int i) { - super(i); + public ItemBlueprint() { + super(); setMaxStackSize(1); setCreativeTab(CreativeTabBuildCraft.MACHINES.get()); } diff --git a/common/buildcraft/builders/ItemBlueprintStandard.java b/common/buildcraft/builders/ItemBlueprintStandard.java index 66f31c37..b555a283 100644 --- a/common/buildcraft/builders/ItemBlueprintStandard.java +++ b/common/buildcraft/builders/ItemBlueprintStandard.java @@ -1,28 +1,29 @@ /** - * Copyright (c) SpaceToad, 2011-2012 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.builders; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.client.renderer.texture.IconRegister; -import net.minecraft.util.Icon; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.util.IIcon; public class ItemBlueprintStandard extends ItemBlueprint { - private Icon cleanBlueprint; - private Icon usedBlueprint; + private IIcon cleanBlueprint; + private IIcon usedBlueprint; - public ItemBlueprintStandard(int i) { - super(i); + public ItemBlueprintStandard() { + super(); } @Override - public Icon getIconFromDamage(int damage) { + public IIcon getIconFromDamage(int damage) { if (damage == 0) return cleanBlueprint; else @@ -31,7 +32,7 @@ public class ItemBlueprintStandard extends ItemBlueprint { @Override @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister par1IconRegister) { + public void registerIcons(IIconRegister par1IconRegister) { cleanBlueprint = par1IconRegister.registerIcon("buildcraft:blueprint_clean"); usedBlueprint = par1IconRegister.registerIcon("buildcraft:blueprint_used"); } diff --git a/common/buildcraft/builders/ItemBlueprintTemplate.java b/common/buildcraft/builders/ItemBlueprintTemplate.java index 4e1ee7ef..4c3faa9a 100644 --- a/common/buildcraft/builders/ItemBlueprintTemplate.java +++ b/common/buildcraft/builders/ItemBlueprintTemplate.java @@ -1,20 +1,27 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.builders; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.client.renderer.texture.IconRegister; -import net.minecraft.util.Icon; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.util.IIcon; -public class ItemBlueprintTemplate extends ItemBlueprint { +public class ItemBlueprintTemplate extends ItemBptBase { + private IIcon usedTemplate; - private Icon usedTemplate; - - public ItemBlueprintTemplate(int i) { - super(i); + public ItemBlueprintTemplate() { + super(); } @Override - public Icon getIconFromDamage(int i) { + public IIcon getIconFromDamage(int i) { if (i == 0) return itemIcon; else @@ -23,7 +30,7 @@ public class ItemBlueprintTemplate extends ItemBlueprint { @Override @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister par1IconRegister) { + public void registerIcons(IIconRegister par1IconRegister) { itemIcon = par1IconRegister.registerIcon("buildcraft:template_clean"); usedTemplate = par1IconRegister.registerIcon("buildcraft:template_used"); } diff --git a/common/buildcraft/builders/ItemBptBase.java b/common/buildcraft/builders/ItemBptBase.java new file mode 100644 index 00000000..05bf9171 --- /dev/null +++ b/common/buildcraft/builders/ItemBptBase.java @@ -0,0 +1,57 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ +package buildcraft.builders; + +import buildcraft.BuildCraftBuilders; +import buildcraft.core.CreativeTabBuildCraft; +import buildcraft.core.ItemBuildCraft; +import buildcraft.core.blueprints.BptBase; +import buildcraft.core.proxy.CoreProxy; +import java.util.List; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +public abstract class ItemBptBase extends ItemBuildCraft { + + public ItemBptBase() { + super(); + + maxStackSize = 1; + setCreativeTab(CreativeTabBuildCraft.MACHINES.get()); + } + + @SuppressWarnings({ "all" }) + // @Override (client only) + public abstract IIcon getIconFromDamage(int i); + + @SuppressWarnings({ "all" }) + // @Override (client only) + public void addInformation(ItemStack itemstack, EntityPlayer player, List list, boolean advanced) { + if (itemstack.hasTagCompound() && itemstack.getTagCompound().hasKey("BptName")) { + list.add(itemstack.getTagCompound().getString("BptName")); + } + } + + @Override + public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) { + if (!world.isRemote) { + BptBase bpt = BuildCraftBuilders.getBptRootIndex().getBluePrint(itemStack.getItemDamage()); + if (bpt != null) + return BuildCraftBuilders.getBptItemStack(itemStack.getItem(), itemStack.getItemDamage(), bpt.getName()); + } + return itemStack; + } + + @Override + public void onUpdate(ItemStack itemstack, World world, Entity entity, int i, boolean flag) { + } +} diff --git a/common/buildcraft/builders/ItemBptBluePrint.java b/common/buildcraft/builders/ItemBptBluePrint.java new file mode 100644 index 00000000..7fb4d5d0 --- /dev/null +++ b/common/buildcraft/builders/ItemBptBluePrint.java @@ -0,0 +1,41 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ +package buildcraft.builders; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.util.IIcon; + +public class ItemBptBluePrint extends ItemBptBase { + + private IIcon cleanBlueprint; + private IIcon usedBlueprint; + + public ItemBptBluePrint() { + super(); + setCreativeTab(null); + } + + @Override + public IIcon getIconFromDamage(int i) { + if (i == 0) + return cleanBlueprint; + else + return usedBlueprint; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister par1IconRegister) + { + cleanBlueprint = par1IconRegister.registerIcon("buildcraft:blueprint_clean"); + usedBlueprint = par1IconRegister.registerIcon("buildcraft:blueprint_used"); + } +} diff --git a/common/buildcraft/builders/TileArchitect.java b/common/buildcraft/builders/TileArchitect.java index 75e3546d..3ca41567 100644 --- a/common/buildcraft/builders/TileArchitect.java +++ b/common/buildcraft/builders/TileArchitect.java @@ -1,12 +1,19 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.builders; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraftforge.common.util.ForgeDirection; import buildcraft.BuildCraftBuilders; import buildcraft.api.core.IAreaProvider; import buildcraft.api.core.LaserKind; @@ -30,7 +37,7 @@ import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; public class TileArchitect extends TileBuildCraft implements IInventory { @@ -47,7 +54,7 @@ public class TileArchitect extends TileBuildCraft implements IInventory { public void updateEntity() { super.updateEntity(); - if (CoreProxy.proxy.isSimulating(worldObj) && isComputing) { + if (!worldObj.isRemote && isComputing) { if (computingTime < 200) { computingTime++; } else { @@ -70,7 +77,7 @@ public class TileArchitect extends TileBuildCraft implements IInventory { } } - if (!CoreProxy.proxy.isRenderWorld(worldObj) && box.isInitialized()) { + if (!worldObj.isRemote && box.isInitialized()) { box.createLasers(worldObj, LaserKind.Stripes); } @@ -97,6 +104,7 @@ public class TileArchitect extends TileBuildCraft implements IInventory { blueprint.anchorY = yCoord - box.yMin; blueprint.anchorZ = zCoord - box.zMin; + blueprint.anchorOrientation = ForgeDirection.getOrientation(worldObj.getBlockMetadata(xCoord, yCoord, zCoord)); BuildCraftBuilders.serverDB.add(blueprint); @@ -108,7 +116,7 @@ public class TileArchitect extends TileBuildCraft implements IInventory { private Blueprint createMaskBlueprint(Box box) { Blueprint blueprint = Blueprint.create(box.sizeX(), box.sizeY(), box.sizeZ()); - for (int x = box.xMin; x <= box.xMax; ++x) { + /*for (int x = box.xMin; x <= box.xMax; ++x) { for (int y = box.yMin; y <= box.yMax; ++y) { for (int z = box.zMin; z <= box.zMax; ++z) { if (worldObj.isAirBlock(x, y, z)) @@ -120,7 +128,7 @@ public class TileArchitect extends TileBuildCraft implements IInventory { blueprint.setSchematic(x - box.xMin, y - box.yMin, z - box.zMin, worldObj, block); } } - } + }*/ return blueprint; } @@ -131,11 +139,15 @@ public class TileArchitect extends TileBuildCraft implements IInventory { for (int x = box.xMin; x <= box.xMax; ++x) { for (int y = box.yMin; y <= box.yMax; ++y) { for (int z = box.zMin; z <= box.zMax; ++z) { - if (worldObj.isAirBlock(x, y, z)) + if (worldObj.isAirBlock(x, y, z)) { continue; - Block block = Block.blocksList[worldObj.getBlockId(x, y, z)]; - if (block == null) + } + + Block block = worldObj.getBlock(x, y, z); + + if (block == null) { continue; + } blueprint.setSchematic(x - box.xMin, y - box.yMin, z - box.zMin, worldObj, block); } @@ -211,7 +223,7 @@ public class TileArchitect extends TileBuildCraft implements IInventory { } @Override - public String getInvName() { + public String getInventoryName() { return "Template"; } @@ -227,7 +239,7 @@ public class TileArchitect extends TileBuildCraft implements IInventory { @Override public boolean isUseableByPlayer(EntityPlayer entityplayer) { - return worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) == this; + return worldObj.getTileEntity(xCoord, yCoord, zCoord) == this; } @Override @@ -241,10 +253,10 @@ public class TileArchitect extends TileBuildCraft implements IInventory { box.initialize(nbttagcompound.getCompoundTag("box")); } - NBTTagList nbttaglist = nbttagcompound.getTagList("Items"); + NBTTagList nbttaglist = nbttagcompound.getTagList("Items", Utils.NBTTag_Types.NBTTagCompound.ordinal()); items = new ItemStack[getSizeInventory()]; for (int i = 0; i < nbttaglist.tagCount(); i++) { - NBTTagCompound nbttagcompound1 = (NBTTagCompound) nbttaglist.tagAt(i); + NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i); int j = nbttagcompound1.getByte("Slot") & 0xff; if (j >= 0 && j < items.length) { items[j] = ItemStack.loadItemStackFromNBT(nbttagcompound1); @@ -340,11 +352,16 @@ public class TileArchitect extends TileBuildCraft implements IInventory { } @Override - public void openChest() { + public void openInventory() { } @Override - public void closeChest() { + public void closeInventory() { + } + + @Override + public boolean hasCustomInventoryName() { + return false; } } diff --git a/common/buildcraft/builders/TileBlueprintLibrary.java b/common/buildcraft/builders/TileBlueprintLibrary.java index 24d195d8..c37abe11 100644 --- a/common/buildcraft/builders/TileBlueprintLibrary.java +++ b/common/buildcraft/builders/TileBlueprintLibrary.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.builders; import buildcraft.BuildCraftBuilders; @@ -52,6 +60,10 @@ public class TileBlueprintLibrary extends TileBuildCraft implements IInventory { @Override public void initialize() { super.initialize(); + + if (!worldObj.isRemote) { + setCurrentPage(getNextPage(null)); + } } public ArrayList getNextPage(String after) { @@ -222,7 +234,7 @@ public class TileBlueprintLibrary extends TileBuildCraft implements IInventory { } @Override - public String getInvName() { + public String getInventoryName() { return ""; } @@ -238,22 +250,24 @@ public class TileBlueprintLibrary extends TileBuildCraft implements IInventory { @Override public boolean isUseableByPlayer(EntityPlayer entityplayer) { - return worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) == this; + return worldObj.getTileEntity(xCoord, yCoord, zCoord) == this; } @Override - public void openChest() { + public void openInventory() { } @Override - public void closeChest() { + public void closeInventory() { } @Override public void updateEntity() { super.updateEntity(); - if (CoreProxy.proxy.isRenderWorld(worldObj)) + + if (worldObj.isRemote) { return; + } if (progressIn > 0 && progressIn < 100) { progressIn++; @@ -290,10 +304,11 @@ public class TileBlueprintLibrary extends TileBuildCraft implements IInventory { if (progressOut == 100 && stack[3] == null) { if (selected > -1 && selected < currentPage.size()) { BptBase bpt = currentPage.get(selected); - setInventorySlotContents(3, BuildCraftBuilders.getBptItemStack(stack[2].itemID, bpt.position, bpt.getName())); + setInventorySlotContents(3, BuildCraftBuilders.getBptItemStack(stack[2].getItem(), bpt.position, bpt.getName())); } else { - setInventorySlotContents(3, BuildCraftBuilders.getBptItemStack(stack[2].itemID, 0, null)); + setInventorySlotContents(3, BuildCraftBuilders.getBptItemStack(stack[2].getItem(), 0, null)); } + setInventorySlotContents(2, null); } } @@ -303,4 +318,9 @@ public class TileBlueprintLibrary extends TileBuildCraft implements IInventory { BuildCraftBuilders.clientDB.add(bpt); updateCurrentNames(); } + + @Override + public boolean hasCustomInventoryName() { + return false; + } } diff --git a/common/buildcraft/builders/TileBuilder.java b/common/buildcraft/builders/TileBuilder.java index 3f76f440..a6283a8e 100644 --- a/common/buildcraft/builders/TileBuilder.java +++ b/common/buildcraft/builders/TileBuilder.java @@ -33,8 +33,13 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.common.ForgeDirection; -import static net.minecraftforge.common.ForgeDirection.*; + +import net.minecraftforge.common.util.ForgeDirection; + +import net.minecraft.nbt.NBTTagList; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraftforge.common.util.ForgeDirection; public class TileBuilder extends TileBuildCraft implements IBuilderInventory, IPowerReceptor, IMachine { @@ -60,8 +65,9 @@ public class TileBuilder extends TileBuildCraft implements IBuilderInventory, IP public void updateEntity() { super.updateEntity(); - if (worldObj.isRemote) + if (worldObj.isRemote) { return; + } setupBuilder(); } @@ -94,22 +100,22 @@ public class TileBuilder extends TileBuildCraft implements IBuilderInventory, IP builderDone = false; } if (!builderDone && blueprintBuilder == null && blueprint != null) { - ForgeDirection blueprintOrientation = NORTH; + ForgeDirection blueprintOrientation = ForgeDirection.NORTH; switch (ForgeDirection.getOrientation(getBlockMetadata())) { case WEST: - blueprintOrientation = blueprintOrientation.getRotation(UP); + blueprintOrientation = blueprintOrientation.getRotation(ForgeDirection.UP); case SOUTH: - blueprintOrientation = blueprintOrientation.getRotation(UP); + blueprintOrientation = blueprintOrientation.getRotation(ForgeDirection.UP); case EAST: - blueprintOrientation = blueprintOrientation.getRotation(UP); + blueprintOrientation = blueprintOrientation.getRotation(ForgeDirection.UP); } switch (blueprint.anchorOrientation) { case WEST: - blueprintOrientation = blueprintOrientation.getRotation(DOWN); + blueprintOrientation = blueprintOrientation.getRotation(ForgeDirection.DOWN); case SOUTH: - blueprintOrientation = blueprintOrientation.getRotation(DOWN); + blueprintOrientation = blueprintOrientation.getRotation(ForgeDirection.DOWN); case EAST: - blueprintOrientation = blueprintOrientation.getRotation(DOWN); + blueprintOrientation = blueprintOrientation.getRotation(ForgeDirection.DOWN); } blueprintBuilder = new BlueprintBuilder(blueprint, worldObj, xCoord, yCoord, zCoord, blueprintOrientation); blueprintIterator = blueprintBuilder.getBuilders().listIterator(); @@ -139,19 +145,21 @@ public class TileBuilder extends TileBuildCraft implements IBuilderInventory, IP } } + private void build() { - if (blueprintBuilder == null) + if (blueprintBuilder == null) { return; - - if (blueprintIterator == null) + } else if (blueprintIterator == null) { return; - - if (!blueprintIterator.hasNext()) + } else if (!blueprintIterator.hasNext()) { return; + } float mj = 25; - if (powerHandler.useEnergy(mj, mj, true) != mj) + + if (powerHandler.useEnergy(mj, mj, true) != mj) { return; + } if (builderRobot == null) { builderRobot = new EntityRobotBuilder(worldObj, box); @@ -198,7 +206,7 @@ public class TileBuilder extends TileBuildCraft implements IBuilderInventory, IP } @Override - public String getInvName() { + public String getInventoryName() { return "Builder"; } @@ -217,7 +225,7 @@ public class TileBuilder extends TileBuildCraft implements IBuilderInventory, IP @Override public boolean isUseableByPlayer(EntityPlayer entityplayer) { - return worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) == this; + return worldObj.getTileEntity(xCoord, yCoord, zCoord) == this; } @Override @@ -290,11 +298,11 @@ public class TileBuilder extends TileBuildCraft implements IBuilderInventory, IP } @Override - public void openChest() { + public void openInventory() { } @Override - public void closeChest() { + public void closeInventory() { } @Override @@ -321,4 +329,9 @@ public class TileBuilder extends TileBuildCraft implements IBuilderInventory, IP public boolean allowAction(IAction action) { return false; } + + @Override + public boolean hasCustomInventoryName() { + return false; + } } diff --git a/common/buildcraft/builders/TileFiller.java b/common/buildcraft/builders/TileFiller.java index a4d18f55..9eb3ab83 100644 --- a/common/buildcraft/builders/TileFiller.java +++ b/common/buildcraft/builders/TileFiller.java @@ -1,12 +1,14 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.builders; +import buildcraft.BuildCraftBuilders; import buildcraft.BuildCraftCore; import buildcraft.api.core.IAreaProvider; import buildcraft.api.core.LaserKind; @@ -35,14 +37,17 @@ import buildcraft.core.proxy.CoreProxy; import buildcraft.core.triggers.ActionMachineControl; import buildcraft.core.triggers.ActionMachineControl.Mode; import buildcraft.core.utils.Utils; +import io.netty.buffer.ByteBuf; + import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; public class TileFiller extends TileBuildCraft implements IInventory, IPowerReceptor, IMachine, IActionReceptor, IGuiReturnHandler { @@ -70,7 +75,7 @@ public class TileFiller extends TileBuildCraft implements IInventory, IPowerRece public void initialize() { super.initialize(); - if (!CoreProxy.proxy.isRenderWorld(worldObj)) { + if (!worldObj.isRemote) { IAreaProvider a = Utils.getNearbyAreaProvider(worldObj, xCoord, yCoord, zCoord); if (a != null) { @@ -80,7 +85,7 @@ public class TileFiller extends TileBuildCraft implements IInventory, IPowerRece ((TileMarker) a).removeFromWorld(); } - if (!CoreProxy.proxy.isRenderWorld(worldObj) && box.isInitialized()) { + if (!worldObj.isRemote && box.isInitialized()) { box.createLasers(worldObj, LaserKind.Stripes); } sendNetworkUpdate(); @@ -100,7 +105,7 @@ public class TileFiller extends TileBuildCraft implements IInventory, IPowerRece @Override public void doWork(PowerHandler workProvider) { - if (CoreProxy.proxy.isRenderWorld(worldObj)) + if (worldObj.isRemote) return; if (done) return; @@ -167,7 +172,7 @@ public class TileFiller extends TileBuildCraft implements IInventory, IPowerRece } @Override - public String getInvName() { + public String getInventoryName() { return "Filler"; } @@ -214,7 +219,7 @@ public class TileFiller extends TileBuildCraft implements IInventory, IPowerRece @Override public boolean isUseableByPlayer(EntityPlayer entityplayer) { - if (worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) != this) + if (worldObj.getTileEntity(xCoord, yCoord, zCoord) != this) return false; return entityplayer.getDistanceSq(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D) <= 64D; } @@ -243,21 +248,21 @@ public class TileFiller extends TileBuildCraft implements IInventory, IPowerRece public PacketPayload getPacketPayload() { PacketPayloadStream payload = new PacketPayloadStream(new PacketPayloadStream.StreamWriter() { @Override - public void writeData(DataOutputStream data) throws IOException { + public void writeData(ByteBuf data) { box.writeToStream(data); data.writeBoolean(done); - data.writeUTF(currentPattern.getUniqueTag()); + Utils.writeUTF(data, currentPattern.getUniqueTag()); } }); return payload; } - public void handlePacketPayload(DataInputStream data) throws IOException { + public void handlePacketPayload(ByteBuf data) { boolean initialized = box.isInitialized(); box.readFromStream(data); done = data.readBoolean(); - setPattern(FillerManager.registry.getPattern(data.readUTF())); + setPattern(FillerManager.registry.getPattern(Utils.readUTF(data))); worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); if (!initialized && box.isInitialized()) { @@ -296,11 +301,11 @@ public class TileFiller extends TileBuildCraft implements IInventory, IPowerRece } @Override - public void openChest() { + public void openInventory() { } @Override - public void closeChest() { + public void closeInventory() { } @Override @@ -328,12 +333,17 @@ public class TileFiller extends TileBuildCraft implements IInventory, IPowerRece } @Override - public void writeGuiData(DataOutputStream data) throws IOException { - data.writeUTF(currentPattern.getUniqueTag()); + public void writeGuiData(ByteBuf data) { + Utils.writeUTF(data, currentPattern.getUniqueTag()); } @Override - public void readGuiData(DataInputStream data, EntityPlayer player) throws IOException { - setPattern(FillerManager.registry.getPattern(data.readUTF())); + public void readGuiData(ByteBuf data, EntityPlayer player) { + setPattern(FillerManager.registry.getPattern(Utils.readUTF(data))); + } + + @Override + public boolean hasCustomInventoryName() { + return false; } } diff --git a/common/buildcraft/builders/TileMarker.java b/common/buildcraft/builders/TileMarker.java index d36a7ce3..54e237d1 100644 --- a/common/buildcraft/builders/TileMarker.java +++ b/common/buildcraft/builders/TileMarker.java @@ -1,12 +1,11 @@ /** - * Copyright (c) SpaceToad, 2011 + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.builders; import buildcraft.BuildCraftBuilders; @@ -19,6 +18,7 @@ import buildcraft.core.network.PacketUpdate; import buildcraft.core.network.NetworkData; import buildcraft.core.proxy.CoreProxy; import buildcraft.core.utils.Utils; +import net.minecraft.block.Block; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; @@ -54,7 +54,7 @@ public class TileMarker extends TileBuildCraft implements IAreaProvider { return null; if (marker == null) { - marker = (TileMarker) world.getBlockTileEntity(x, y, z); + marker = (TileMarker) world.getTileEntity(x, y, z); } return marker; @@ -90,7 +90,7 @@ public class TileMarker extends TileBuildCraft implements IAreaProvider { boolean showSignals = false; public void updateSignals() { - if (CoreProxy.proxy.isSimulating(worldObj)) { + if (!worldObj.isRemote) { showSignals = worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord); sendNetworkUpdate(); } @@ -145,15 +145,16 @@ public class TileMarker extends TileBuildCraft implements IAreaProvider { for (int i = 0; i < 3; ++i) { if (initVect[i] != null) { - linkTo((TileMarker) worldObj.getBlockTileEntity((int) initVect[i].x, (int) initVect[i].y, (int) initVect[i].z), i); + linkTo((TileMarker) worldObj.getTileEntity((int) initVect[i].x, (int) initVect[i].y, (int) initVect[i].z), i); } } } } public void tryConnection() { - if (CoreProxy.proxy.isRenderWorld(worldObj)) + if (worldObj.isRemote) { return; + } for (int j = 0; j < 3; ++j) { if (!origin.isSet() || !origin.vect[j].isSet()) { @@ -165,8 +166,6 @@ public class TileMarker extends TileBuildCraft implements IAreaProvider { } void setVect(int n) { - int markerId = BuildCraftBuilders.markerBlock.blockID; - int[] coords = new int[3]; coords[0] = xCoord; @@ -177,10 +176,10 @@ public class TileMarker extends TileBuildCraft implements IAreaProvider { for (int j = 1; j < maxSize; ++j) { coords[n] += j; - int blockId = worldObj.getBlockId(coords[0], coords[1], coords[2]); + Block block = worldObj.getBlock(coords[0], coords[1], coords[2]); - if (blockId == markerId) { - TileMarker marker = (TileMarker) worldObj.getBlockTileEntity(coords[0], coords[1], coords[2]); + if (block == BuildCraftBuilders.markerBlock) { + TileMarker marker = (TileMarker) worldObj.getTileEntity(coords[0], coords[1], coords[2]); if (linkTo(marker, n)) { break; @@ -190,10 +189,10 @@ public class TileMarker extends TileBuildCraft implements IAreaProvider { coords[n] -= j; coords[n] -= j; - blockId = worldObj.getBlockId(coords[0], coords[1], coords[2]); + block = worldObj.getBlock(coords[0], coords[1], coords[2]); - if (blockId == markerId) { - TileMarker marker = (TileMarker) worldObj.getBlockTileEntity(coords[0], coords[1], coords[2]); + if (block == BuildCraftBuilders.markerBlock) { + TileMarker marker = (TileMarker) worldObj.getTileEntity(coords[0], coords[1], coords[2]); if (linkTo(marker, n)) { break; @@ -391,7 +390,7 @@ public class TileMarker extends TileBuildCraft implements IAreaProvider { signals = null; - if (CoreProxy.proxy.isSimulating(worldObj) && markerOrigin != null && markerOrigin != this) { + if (!worldObj.isRemote && markerOrigin != null && markerOrigin != this) { markerOrigin.sendNetworkUpdate(); } } @@ -405,15 +404,15 @@ public class TileMarker extends TileBuildCraft implements IAreaProvider { for (TileWrapper m : o.vect.clone()) { if (m.isSet()) { - worldObj.setBlock(m.x, m.y, m.z, 0); + worldObj.setBlockToAir(m.x, m.y, m.z); - BuildCraftBuilders.markerBlock.dropBlockAsItem(worldObj, m.x, m.y, m.z, BuildCraftBuilders.markerBlock.blockID, 0); + BuildCraftBuilders.markerBlock.dropBlockAsItem(worldObj, m.x, m.y, m.z, 0, 0); } } - worldObj.setBlock(o.vectO.x, o.vectO.y, o.vectO.z, 0); + worldObj.setBlockToAir(o.vectO.x, o.vectO.y, o.vectO.z); - BuildCraftBuilders.markerBlock.dropBlockAsItem(worldObj, o.vectO.x, o.vectO.y, o.vectO.z, BuildCraftBuilders.markerBlock.blockID, 0); + BuildCraftBuilders.markerBlock.dropBlockAsItem(worldObj, o.vectO.x, o.vectO.y, o.vectO.z, 0, 0); } @Override diff --git a/common/buildcraft/builders/TilePathMarker.java b/common/buildcraft/builders/TilePathMarker.java index 996fbf8c..8ba7ad6b 100644 --- a/common/buildcraft/builders/TilePathMarker.java +++ b/common/buildcraft/builders/TilePathMarker.java @@ -1,5 +1,14 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.builders; +import buildcraft.BuildCraftBuilders; import buildcraft.api.core.Position; import buildcraft.core.BlockIndex; import buildcraft.core.EntityLaser; @@ -7,10 +16,12 @@ import buildcraft.core.EntityPowerLaser; import buildcraft.core.network.PacketUpdate; import buildcraft.core.network.NetworkData; import buildcraft.core.proxy.CoreProxy; + import java.io.IOException; import java.util.Iterator; import java.util.LinkedList; import java.util.TreeSet; + import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; @@ -52,8 +63,9 @@ public class TilePathMarker extends TileMarker { public void createLaserAndConnect(TilePathMarker pathMarker) { - if (CoreProxy.proxy.isRenderWorld(worldObj)) + if (worldObj.isRemote) { return; + } EntityPowerLaser laser = new EntityPowerLaser(worldObj, new Position(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5), new Position(pathMarker.xCoord + 0.5, pathMarker.yCoord + 0.5, pathMarker.zCoord + 0.5)); @@ -72,7 +84,7 @@ public class TilePathMarker extends TileMarker { double nearestDistance = 0, distance; // The initialization of nearestDistance is only to make the compiler shut up for (TilePathMarker t : availableMarkers) { - if (t == this || t == this.links[0] || t == this.links[1] || t.worldObj.provider.dimensionId != this.worldObj.provider.dimensionId) { + if (t == this || t == this.links[0] || t == this.links[1] || t.getWorldObj().provider.dimensionId != this.getWorldObj().provider.dimensionId) { continue; } @@ -94,8 +106,9 @@ public class TilePathMarker extends TileMarker { @Override public void tryConnection() { - if (CoreProxy.proxy.isRenderWorld(worldObj) || isFullyConnected()) + if (worldObj.isRemote || isFullyConnected()) { return; + } tryingToConnect = !tryingToConnect; // Allow the user to stop the path marker from searching for new path markers to connect sendNetworkUpdate(); @@ -105,8 +118,9 @@ public class TilePathMarker extends TileMarker { public void updateEntity() { super.updateEntity(); - if (CoreProxy.proxy.isRenderWorld(worldObj)) + if (worldObj.isRemote) { return; + } if (tryingToConnect) { TilePathMarker nearestPathMarker = findNearestAvailablePathMarker(); @@ -168,12 +182,12 @@ public class TilePathMarker extends TileMarker { public void initialize() { super.initialize(); - if (CoreProxy.proxy.isSimulating(worldObj) && !isFullyConnected()) { + if (!worldObj.isRemote && !isFullyConnected()) { availableMarkers.add(this); } if (loadLink0) { - TileEntity e0 = worldObj.getBlockTileEntity(x0, y0, z0); + TileEntity e0 = worldObj.getTileEntity(x0, y0, z0); if (links[0] != e0 && links[1] != e0 && e0 instanceof TilePathMarker) { createLaserAndConnect((TilePathMarker) e0); @@ -183,7 +197,7 @@ public class TilePathMarker extends TileMarker { } if (loadLink1) { - TileEntity e1 = worldObj.getBlockTileEntity(x1, y1, z1); + TileEntity e1 = worldObj.getTileEntity(x1, y1, z1); if (links[0] != e1 && links[1] != e1 && e1 instanceof TilePathMarker) { createLaserAndConnect((TilePathMarker) e1); @@ -204,7 +218,7 @@ public class TilePathMarker extends TileMarker { links[1] = null; } - if (!isFullyConnected() && !availableMarkers.contains(this) && CoreProxy.proxy.isSimulating(worldObj)) { + if (!isFullyConnected() && !availableMarkers.contains(this) && !worldObj.isRemote) { availableMarkers.add(this); } } @@ -259,7 +273,7 @@ public class TilePathMarker extends TileMarker { public static void clearAvailableMarkersList(World w) { for (Iterator it = availableMarkers.iterator(); it.hasNext();) { TilePathMarker t = it.next(); - if (t.worldObj.provider.dimensionId != w.provider.dimensionId) { + if (t.getWorldObj().provider.dimensionId != w.provider.dimensionId) { it.remove(); } } diff --git a/common/buildcraft/builders/blueprints/BlockSchematic.java b/common/buildcraft/builders/blueprints/BlockSchematic.java index 9febe85b..e79b9782 100644 --- a/common/buildcraft/builders/blueprints/BlockSchematic.java +++ b/common/buildcraft/builders/blueprints/BlockSchematic.java @@ -1,13 +1,17 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.builders.blueprints; import buildcraft.api.builder.BlockHandler; import net.minecraft.block.Block; import net.minecraft.nbt.NBTTagCompound; -/** - * - * @author CovertJaguar - */ public final class BlockSchematic extends Schematic { public static BlockSchematic create(NBTTagCompound nbt) { @@ -26,7 +30,7 @@ public final class BlockSchematic extends Schematic { } private BlockSchematic(Block block) { - super(block.blockID); + super(Block.blockRegistry.getIDForObject(block)); } private BlockSchematic(String nbt) { @@ -36,13 +40,14 @@ public final class BlockSchematic extends Schematic { @Override public BlockHandler getHandler() { - return BlockHandler.get(Block.blocksList [id]); + return BlockHandler.get((Block) Block.blockRegistry.getObjectById(id)); } @Override public void writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); + nbt.setString("schematicType", "block"); - nbt.setString("blockName", Block.blocksList [id].getUnlocalizedName()); + nbt.setString("blockName", ((Block) Block.blockRegistry.getObjectById(id)).getUnlocalizedName()); } } diff --git a/common/buildcraft/builders/blueprints/Blueprint.java b/common/buildcraft/builders/blueprints/Blueprint.java index 8d1898ec..d2cf1199 100644 --- a/common/buildcraft/builders/blueprints/Blueprint.java +++ b/common/buildcraft/builders/blueprints/Blueprint.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011-2012 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.builders.blueprints; @@ -11,6 +12,7 @@ import buildcraft.api.builder.BlockHandler; import buildcraft.core.inventory.StackHelper; import buildcraft.core.network.NetworkData; import buildcraft.core.utils.BCLog; +import buildcraft.core.utils.Utils; import buildcraft.factory.TileQuarry; import java.util.ArrayList; @@ -23,14 +25,11 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.world.World; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; /** * This class is used to represent the data of the blueprint as it exists in the * world. - * - * @author CovertJaguar - * @author Player */ public class Blueprint { @@ -97,9 +96,10 @@ public class Blueprint { anchorOrientation = ForgeDirection.getOrientation(nbt.getByte("anchorOrientation")); - NBTTagList blockList = nbt.getTagList("blocks"); + NBTTagList blockList = nbt.getTagList("blocks",Utils.NBTTag_Types.NBTTagCompound.ordinal()); + for (int i = 0; i < blockList.tagCount(); i++) { - NBTTagCompound blockNBT = (NBTTagCompound) blockList.tagAt(i); + NBTTagCompound blockNBT = (NBTTagCompound) blockList.getCompoundTagAt(i); Schematic schematic = Schematic.createSchematicFromNBT(blockNBT); schematics[schematic.x][schematic.y][schematic.z] = schematic; } @@ -156,7 +156,7 @@ public class Blueprint { setSchematic(x, y, z, schematic); } } catch (Throwable error) { - BCLog.logger.severe(String.format("Error while trying to save block [%s:%d] to blueprint, skipping.", block.getUnlocalizedName(), block.blockID)); + BCLog.logger.severe(String.format("Error while trying to save block [%s] to blueprint, skipping.", block.getUnlocalizedName())); error.printStackTrace(); BCLog.logger.throwing(getClass().getCanonicalName(), "setBlock", error); } @@ -173,7 +173,7 @@ public class Blueprint { setSchematic(x, y, z, schematic); } } catch (Throwable error) { - BCLog.logger.severe(String.format("Error while trying to save item [%s:%d] to blueprint, skipping.", item.getItem().getUnlocalizedName(), item.itemID)); + BCLog.logger.severe(String.format("Error while trying to save item [%s] to blueprint, skipping.", item.getItem().getUnlocalizedName())); BCLog.logger.throwing(getClass().getCanonicalName(), "setBlock", error); } } @@ -186,11 +186,11 @@ public class Blueprint { * * @see TileQuarry */ - public void setSchematic(World world, int x, int y, int z, int id, int meta) { - Block block = Block.blocksList[id]; + public void setSchematic(World world, int x, int y, int z, Block block, int meta) { if (block == null) { return; } + BlockSchematic schematic = BlockSchematic.create(block); schematic.data.setByte("blockMeta", (byte) meta); setSchematic(x, y, z, schematic); diff --git a/common/buildcraft/builders/blueprints/BlueprintBuilder.java b/common/buildcraft/builders/blueprints/BlueprintBuilder.java index eb01c079..0795eec4 100644 --- a/common/buildcraft/builders/blueprints/BlueprintBuilder.java +++ b/common/buildcraft/builders/blueprints/BlueprintBuilder.java @@ -15,12 +15,8 @@ import java.util.Collections; import java.util.List; import net.minecraft.world.World; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; -/** - * - * @author CovertJaguar - */ public class BlueprintBuilder implements IAreaProvider { public final Blueprint blueprint; diff --git a/common/buildcraft/builders/blueprints/BlueprintDatabase.java b/common/buildcraft/builders/blueprints/BlueprintDatabase.java index dca278f1..447a0bd5 100644 --- a/common/buildcraft/builders/blueprints/BlueprintDatabase.java +++ b/common/buildcraft/builders/blueprints/BlueprintDatabase.java @@ -1,5 +1,5 @@ /** - * Copyright (c) SpaceToad, 2011-2012 + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com * * BuildCraft is distributed under the terms of the Minecraft Mod Public @@ -8,6 +8,10 @@ */ package buildcraft.builders.blueprints; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.ByteBufAllocator; +import io.netty.buffer.Unpooled; + import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; import java.io.File; @@ -27,15 +31,11 @@ import java.util.logging.Logger; import java.util.zip.GZIPOutputStream; import buildcraft.BuildCraftBuilders; +import buildcraft.core.utils.Utils; import net.minecraft.nbt.CompressedStreamTools; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; -/** - * - * @author Player - * @author CovertJaguar - */ public class BlueprintDatabase { private final int bufferSize = 8192; private final String fileExt = ".bpt"; @@ -131,17 +131,13 @@ public class BlueprintDatabase { private BlueprintId save(Blueprint blueprint) { NBTTagCompound nbt = new NBTTagCompound(); blueprint.writeToNBT(nbt); + + ByteBuf buf = Unpooled.buffer(); - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - DataOutputStream os = new DataOutputStream(bos); + Utils.writeNBT(buf, nbt); - try { - NBTBase.writeNamedTag(nbt, os); - } catch (IOException e) { - throw new RuntimeException(e); - } - - byte[] data = bos.toByteArray(); + byte[] data = new byte [buf.readableBytes()]; + buf.readBytes(data); blueprint.generateId(data); diff --git a/common/buildcraft/builders/blueprints/ItemSchematic.java b/common/buildcraft/builders/blueprints/ItemSchematic.java old mode 100644 new mode 100755 index b1cfe53b..a17bbd25 --- a/common/buildcraft/builders/blueprints/ItemSchematic.java +++ b/common/buildcraft/builders/blueprints/ItemSchematic.java @@ -1,13 +1,17 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.builders.blueprints; import buildcraft.api.builder.BlockHandler; import net.minecraft.item.Item; import net.minecraft.nbt.NBTTagCompound; -/** - * - * @author CovertJaguar - */ public final class ItemSchematic extends Schematic { public static ItemSchematic create(NBTTagCompound nbt) { @@ -27,7 +31,7 @@ public final class ItemSchematic extends Schematic { } private ItemSchematic(Item item) { - super(item.itemID); + super(Item.getIdFromItem(item)); this.item = item; } diff --git a/common/buildcraft/builders/blueprints/MaskHandler.java b/common/buildcraft/builders/blueprints/MaskHandler.java index 18fa0fb9..0e2d27c0 100755 --- a/common/buildcraft/builders/blueprints/MaskHandler.java +++ b/common/buildcraft/builders/blueprints/MaskHandler.java @@ -1,5 +1,6 @@ package buildcraft.builders.blueprints; +import net.minecraft.init.Blocks; import net.minecraft.world.World; import buildcraft.api.builder.BlockHandler; import buildcraft.builders.blueprints.BlueprintBuilder.SchematicBuilder; @@ -23,9 +24,9 @@ public class MaskHandler extends BlockHandler { MaskSchematic mask = (MaskSchematic) builder.schematic; if (mask.isPlain) { - return world.getBlockId(builder.getX(), builder.getY(), builder.getZ()) != 0; + return world.getBlock(builder.getX(), builder.getY(), builder.getZ()) != Blocks.air; } else { - return world.getBlockId(builder.getX(), builder.getY(), builder.getZ()) == 0; + return world.getBlock(builder.getX(), builder.getY(), builder.getZ()) == Blocks.air; } } diff --git a/common/buildcraft/builders/blueprints/Schematic.java b/common/buildcraft/builders/blueprints/Schematic.java index f489cad1..f64b969b 100644 --- a/common/buildcraft/builders/blueprints/Schematic.java +++ b/common/buildcraft/builders/blueprints/Schematic.java @@ -1,5 +1,5 @@ -/* - * Copyright (c) SpaceToad, 2011-2012 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com * * BuildCraft is distributed under the terms of the Minecraft Mod Public @@ -12,10 +12,6 @@ import buildcraft.api.builder.BlockHandler; import buildcraft.core.network.NetworkData; import net.minecraft.nbt.NBTTagCompound; -/** - * - * @author CovertJaguar - */ public abstract class Schematic { @NetworkData @@ -50,7 +46,7 @@ public abstract class Schematic { nbt.setInteger("x", x); nbt.setInteger("y", y); nbt.setInteger("z", z); - nbt.setCompoundTag("data", data); + nbt.setTag("data", data); } public void readFromNBT(NBTTagCompound nbt) { diff --git a/common/buildcraft/builders/filler/FillerRegistry.java b/common/buildcraft/builders/filler/FillerRegistry.java index abb7141c..9f4c2785 100644 --- a/common/buildcraft/builders/filler/FillerRegistry.java +++ b/common/buildcraft/builders/filler/FillerRegistry.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.builders.filler; diff --git a/common/buildcraft/builders/filler/pattern/FillerPattern.java b/common/buildcraft/builders/filler/pattern/FillerPattern.java index dc67e333..dee29d7f 100644 --- a/common/buildcraft/builders/filler/pattern/FillerPattern.java +++ b/common/buildcraft/builders/filler/pattern/FillerPattern.java @@ -22,18 +22,18 @@ import java.util.Map; import java.util.TreeMap; import net.minecraft.block.Block; -import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Icon; +import net.minecraft.util.IIcon; import net.minecraft.world.World; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; public abstract class FillerPattern implements IFillerPattern { public static final Map patterns = new TreeMap(); private final String tag; - private Icon icon; + private IIcon icon; public FillerPattern(String tag) { this.tag = tag; @@ -63,12 +63,12 @@ public abstract class FillerPattern implements IFillerPattern { return "buildcraft:" + tag; } - public void registerIcon(IconRegister iconRegister) { + public void registerIcon(IIconRegister iconRegister) { icon = iconRegister.registerIcon("buildcraft:fillerPatterns/" + tag); } @Override - public Icon getIcon() { + public IIcon getIcon() { return icon; } @@ -204,9 +204,12 @@ public abstract class FillerPattern implements IFillerPattern { } private static void breakBlock(World world, int x, int y, int z) { - Block block = Block.blocksList[world.getBlockId(x, y, z)]; - if (block != null) - world.playSoundEffect(x + 0.5F, y + 0.5F, z + 0.5F, block.stepSound.getPlaceSound(), (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F); + Block block = world.getBlock(x, y, z); + if (block != null) { + // TODO: fix sound + //world.playSoundEffect(x + 0.5F, y + 0.5F, z + 0.5F, block.stepSound.getPlaceSound(), (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F); + } + if (BuildCraftBuilders.fillerDestroy) { world.setBlockToAir(x, y, z); } else if (BlockUtil.isToughBlock(world, x, y, z)) { diff --git a/common/buildcraft/builders/filler/pattern/PatternBox.java b/common/buildcraft/builders/filler/pattern/PatternBox.java index 44849df8..0527b3fa 100644 --- a/common/buildcraft/builders/filler/pattern/PatternBox.java +++ b/common/buildcraft/builders/filler/pattern/PatternBox.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.builders.filler.pattern; @@ -27,22 +28,22 @@ public class PatternBox extends FillerPattern { int yMax = (int) box.pMax().y; int zMax = (int) box.pMax().z; - if (fill(xMin, yMin, zMin, xMax, yMin, zMax, stackToPlace, tile.worldObj)) + if (fill(xMin, yMin, zMin, xMax, yMin, zMax, stackToPlace, tile.getWorldObj())) return false; - if (fill(xMin, yMin, zMin, xMin, yMax, zMax, stackToPlace, tile.worldObj)) + if (fill(xMin, yMin, zMin, xMin, yMax, zMax, stackToPlace, tile.getWorldObj())) return false; - if (fill(xMin, yMin, zMin, xMax, yMax, zMin, stackToPlace, tile.worldObj)) + if (fill(xMin, yMin, zMin, xMax, yMax, zMin, stackToPlace, tile.getWorldObj())) return false; - if (fill(xMax, yMin, zMin, xMax, yMax, zMax, stackToPlace, tile.worldObj)) + if (fill(xMax, yMin, zMin, xMax, yMax, zMax, stackToPlace, tile.getWorldObj())) return false; - if (fill(xMin, yMin, zMax, xMax, yMax, zMax, stackToPlace, tile.worldObj)) + if (fill(xMin, yMin, zMax, xMax, yMax, zMax, stackToPlace, tile.getWorldObj())) return false; - if (fill(xMin, yMax, zMin, xMax, yMax, zMax, stackToPlace, tile.worldObj)) + if (fill(xMin, yMax, zMin, xMax, yMax, zMax, stackToPlace, tile.getWorldObj())) return false; return true; diff --git a/common/buildcraft/builders/filler/pattern/PatternClear.java b/common/buildcraft/builders/filler/pattern/PatternClear.java index 4e29cef0..7a4e6049 100644 --- a/common/buildcraft/builders/filler/pattern/PatternClear.java +++ b/common/buildcraft/builders/filler/pattern/PatternClear.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.builders.filler.pattern; @@ -15,7 +16,7 @@ import buildcraft.core.Box; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; public class PatternClear extends FillerPattern { @@ -33,7 +34,7 @@ public class PatternClear extends FillerPattern { int yMax = (int) box.pMax().y; int zMax = (int) box.pMax().z; - return !empty(xMin, yMin, zMin, xMax, yMax, zMax, tile.worldObj); + return !empty(xMin, yMin, zMin, xMax, yMax, zMax, tile.getWorldObj()); } @Override diff --git a/common/buildcraft/builders/filler/pattern/PatternCylinder.java b/common/buildcraft/builders/filler/pattern/PatternCylinder.java index 972e45b9..801748de 100644 --- a/common/buildcraft/builders/filler/pattern/PatternCylinder.java +++ b/common/buildcraft/builders/filler/pattern/PatternCylinder.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.builders.filler.pattern; @@ -39,7 +40,7 @@ public class PatternCylinder extends FillerPattern { int zRadius = (zMax-zMin)/2; if(xRadius == 0 || zRadius == 0) { - return !fill(xMin, yMin, zMin, xMax, yMax, zMax, stackToPlace, tile.worldObj); + return !fill(xMin, yMin, zMin, xMax, yMax, zMax, stackToPlace, tile.getWorldObj()); } int dx = xRadius, dz = 0; @@ -52,7 +53,7 @@ public class PatternCylinder extends FillerPattern { int stoppingZ = 0; while(stoppingX >= stoppingZ) { - if(!fillFourColumns(xCenter,zCenter,dx,dz,xFix,zFix,yMin,yMax,stackToPlace,tile.worldObj)) + if(!fillFourColumns(xCenter,zCenter,dx,dz,xFix,zFix,yMin,yMax,stackToPlace,tile.getWorldObj())) return false; ++dz; stoppingZ += twoASquare; @@ -75,7 +76,7 @@ public class PatternCylinder extends FillerPattern { stoppingZ = twoASquare*zRadius; while(stoppingX <= stoppingZ) { - if(!fillFourColumns(xCenter,zCenter,dx,dz,xFix,zFix,yMin,yMax,stackToPlace,tile.worldObj)) + if(!fillFourColumns(xCenter,zCenter,dx,dz,xFix,zFix,yMin,yMax,stackToPlace,tile.getWorldObj())) return false; ++dx; stoppingX += twoBSquare; diff --git a/common/buildcraft/builders/filler/pattern/PatternFill.java b/common/buildcraft/builders/filler/pattern/PatternFill.java index a1ba4b30..901e4ce1 100644 --- a/common/buildcraft/builders/filler/pattern/PatternFill.java +++ b/common/buildcraft/builders/filler/pattern/PatternFill.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.builders.filler.pattern; @@ -15,7 +16,7 @@ import buildcraft.core.Box; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; public class PatternFill extends FillerPattern { @@ -35,7 +36,7 @@ public class PatternFill extends FillerPattern { int yMax = (int) box.pMax().y; int zMax = (int) box.pMax().z; - return !fill(xMin, yMin, zMin, xMax, yMax, zMax, stackToPlace, tile.worldObj); + return !fill(xMin, yMin, zMin, xMax, yMax, zMax, stackToPlace, tile.getWorldObj()); } @Override diff --git a/common/buildcraft/builders/filler/pattern/PatternFlatten.java b/common/buildcraft/builders/filler/pattern/PatternFlatten.java index fe087c50..b688bbbd 100644 --- a/common/buildcraft/builders/filler/pattern/PatternFlatten.java +++ b/common/buildcraft/builders/filler/pattern/PatternFlatten.java @@ -16,7 +16,7 @@ import buildcraft.core.Box; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; public class PatternFlatten extends FillerPattern { @@ -34,10 +34,10 @@ public class PatternFlatten extends FillerPattern { int yMax = (int) box.pMax().y; int zMax = (int) box.pMax().z; - if (flatten(xMin, 1, zMin, xMax, yMin - 1, zMax, tile.worldObj, stackToPlace)) { + if (flatten(xMin, 1, zMin, xMax, yMin - 1, zMax, tile.getWorldObj(), stackToPlace)) { return false; } - return !empty(xMin, yMin, zMin, xMax, yMax, zMax, tile.worldObj); + return !empty(xMin, yMin, zMin, xMax, yMax, zMax, tile.getWorldObj()); } @Override diff --git a/common/buildcraft/builders/filler/pattern/PatternHorizon.java b/common/buildcraft/builders/filler/pattern/PatternHorizon.java index a034e517..60a479f0 100644 --- a/common/buildcraft/builders/filler/pattern/PatternHorizon.java +++ b/common/buildcraft/builders/filler/pattern/PatternHorizon.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.builders.filler.pattern; @@ -26,9 +27,9 @@ public class PatternHorizon extends FillerPattern { int xMax = (int) box.pMax().x; int zMax = (int) box.pMax().z; - if (stackToPlace != null && flatten(xMin, 1, zMin, xMax, yMin - 1, zMax, tile.worldObj, stackToPlace)) { + if (stackToPlace != null && flatten(xMin, 1, zMin, xMax, yMin - 1, zMax, tile.getWorldObj(), stackToPlace)) { return false; } - return !empty(xMin, yMin, zMin, xMax, tile.worldObj.getActualHeight(), zMax, tile.worldObj); + return !empty(xMin, yMin, zMin, xMax, tile.getWorldObj().getActualHeight(), zMax, tile.getWorldObj()); } } diff --git a/common/buildcraft/builders/filler/pattern/PatternPyramid.java b/common/buildcraft/builders/filler/pattern/PatternPyramid.java index 0e08f05f..72074725 100644 --- a/common/buildcraft/builders/filler/pattern/PatternPyramid.java +++ b/common/buildcraft/builders/filler/pattern/PatternPyramid.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.builders.filler.pattern; @@ -15,7 +16,7 @@ import buildcraft.core.Box; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; public class PatternPyramid extends FillerPattern { @@ -54,7 +55,7 @@ public class PatternPyramid extends FillerPattern { } while (step <= xSize / 2 && step <= zSize / 2 && height >= yMin && height <= yMax) { - if (fill(xMin + step, height, zMin + step, xMax - step, height, zMax - step, stackToPlace, tile.worldObj)) + if (fill(xMin + step, height, zMin + step, xMax - step, height, zMax - step, stackToPlace, tile.getWorldObj())) return false; step++; diff --git a/common/buildcraft/builders/filler/pattern/PatternStairs.java b/common/buildcraft/builders/filler/pattern/PatternStairs.java index 2a620176..b219f272 100644 --- a/common/buildcraft/builders/filler/pattern/PatternStairs.java +++ b/common/buildcraft/builders/filler/pattern/PatternStairs.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.builders.filler.pattern; @@ -121,7 +122,7 @@ public class PatternStairs extends FillerPattern { if (kind == 0) { while (x2 - x1 + 1 > 0 && z2 - z1 + 1 > 0 && x2 - x1 < sizeX && z2 - z1 < sizeZ && height >= yMin && height <= yMax) { - if (fill(x1, height, z1, x2, height, z2, stackToPlace, tile.worldObj)) + if (fill(x1, height, z1, x2, height, z2, stackToPlace, tile.getWorldObj())) return false; if (heightStep == 1) { @@ -176,7 +177,7 @@ public class PatternStairs extends FillerPattern { } - if (fill(x1, height, z1, x2, height, z2, stackToPlace, tile.worldObj)) + if (fill(x1, height, z1, x2, height, z2, stackToPlace, tile.getWorldObj())) return false; dimX += stepDiagX; diff --git a/common/buildcraft/builders/gui/ContainerBlueprintLibrary.java b/common/buildcraft/builders/gui/ContainerBlueprintLibrary.java index dad0ed13..60232c5e 100644 --- a/common/buildcraft/builders/gui/ContainerBlueprintLibrary.java +++ b/common/buildcraft/builders/gui/ContainerBlueprintLibrary.java @@ -1,12 +1,11 @@ /** - * Copyright (c) SpaceToad, 2011 + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.builders.gui; import buildcraft.builders.TileBlueprintLibrary; diff --git a/common/buildcraft/builders/gui/ContainerBuilder.java b/common/buildcraft/builders/gui/ContainerBuilder.java index 9f749f19..675735c5 100644 --- a/common/buildcraft/builders/gui/ContainerBuilder.java +++ b/common/buildcraft/builders/gui/ContainerBuilder.java @@ -1,12 +1,11 @@ -/** - * Copyright (c) SpaceToad, 2011 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * - * BuildCraft is distributed under the terms of the Minecraft Mod Public + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.builders.gui; import buildcraft.builders.TileBuilder; diff --git a/common/buildcraft/builders/gui/ContainerFiller.java b/common/buildcraft/builders/gui/ContainerFiller.java index 90f614ea..b264cdc1 100644 --- a/common/buildcraft/builders/gui/ContainerFiller.java +++ b/common/buildcraft/builders/gui/ContainerFiller.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.builders.gui; diff --git a/common/buildcraft/builders/gui/ContainerTemplate.java b/common/buildcraft/builders/gui/ContainerTemplate.java index 9d813283..15eb2a6b 100644 --- a/common/buildcraft/builders/gui/ContainerTemplate.java +++ b/common/buildcraft/builders/gui/ContainerTemplate.java @@ -1,12 +1,11 @@ -/** - * Copyright (c) SpaceToad, 2011 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * - * BuildCraft is distributed under the terms of the Minecraft Mod Public + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.builders.gui; import buildcraft.builders.TileArchitect; diff --git a/common/buildcraft/builders/gui/GuiBlueprintLibrary.java b/common/buildcraft/builders/gui/GuiBlueprintLibrary.java index 3affac9a..db17d2f8 100644 --- a/common/buildcraft/builders/gui/GuiBlueprintLibrary.java +++ b/common/buildcraft/builders/gui/GuiBlueprintLibrary.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.builders.gui; @@ -37,9 +38,10 @@ public class GuiBlueprintLibrary extends GuiBuildCraft { this.library = library; container = (ContainerBlueprintLibrary) inventorySlots; - index = BuildCraftBuilders.getPlayerIndex(player.username); + index = BuildCraftBuilders.getPlayerIndex(player.getDisplayName()); library.updateCurrentNames(); } + private GuiButton nextPageButton; private GuiButton prevPageButton; private GuiButton lockButton; @@ -76,7 +78,7 @@ public class GuiBlueprintLibrary extends GuiBuildCraft { // fontRenderer.drawString(library.owner + "'s Library", 6, 6, // 0x404040); String title = StringUtils.localize("tile.libraryBlock"); - fontRenderer.drawString(title, getCenteredOffset(title), 6, 0x404040); + fontRendererObj.drawString(title, getCenteredOffset(title), 6, 0x404040); int c = 0; for (String bpt : library.currentBlueprint) { @@ -94,7 +96,7 @@ public class GuiBlueprintLibrary extends GuiBuildCraft { drawGradientRect(l1, i2 + 9 * c, l1 + 88, i2 + 9 * (c + 1), 0x80ffffff, 0x80ffffff); }*/ - fontRenderer.drawString(name, 9, 25 + 9 * c, 0x404040); + fontRendererObj.drawString(name, 9, 25 + 9 * c, 0x404040); c++; } } @@ -136,6 +138,7 @@ public class GuiBlueprintLibrary extends GuiBuildCraft { } else if (deleteButton != null && button == deleteButton) { packet.actionId = TileBlueprintLibrary.COMMAND_DELETE; } + CoreProxy.proxy.sendToServer(packet.getPacket());*/ } diff --git a/common/buildcraft/builders/gui/GuiBuilder.java b/common/buildcraft/builders/gui/GuiBuilder.java index 8f36ac6b..074c8688 100644 --- a/common/buildcraft/builders/gui/GuiBuilder.java +++ b/common/buildcraft/builders/gui/GuiBuilder.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.builders.gui; @@ -50,14 +51,11 @@ public class GuiBuilder extends GuiAdvancedInterface { super.drawGuiContainerForegroundLayer(par1, par2); String title = StringUtils.localize("tile.builderBlock"); - fontRenderer.drawString(title, getCenteredOffset(title), 12, 0x404040); - fontRenderer.drawString(StringUtils.localize("gui.building.resources"), 8, 60, 0x404040); - fontRenderer.drawString(StringUtils.localize("gui.inventory"), 8, ySize - 97, 0x404040); - -// if (builder.isBuildingBlueprint()) { - fontRenderer.drawString(StringUtils.localize("gui.needed"), 185, 7, 0x404040); -// } - + fontRendererObj.drawString(title, getCenteredOffset(title), 12, 0x404040); + fontRendererObj.drawString(StringUtils.localize("gui.building.resources"), 8, 60, 0x404040); + fontRendererObj.drawString(StringUtils.localize("gui.inventory"), 8, ySize - 97, 0x404040); + fontRendererObj.drawString(StringUtils.localize("gui.needed"), 185, 7, 0x404040); + drawForegroundSelection(par1, par2); } diff --git a/common/buildcraft/builders/gui/GuiFiller.java b/common/buildcraft/builders/gui/GuiFiller.java index 1a26330a..9752ecac 100644 --- a/common/buildcraft/builders/gui/GuiFiller.java +++ b/common/buildcraft/builders/gui/GuiFiller.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.builders.gui; @@ -61,9 +62,9 @@ public class GuiFiller extends GuiBuildCraft { @Override protected void drawGuiContainerForegroundLayer(int par1, int par2) { String title = StringUtils.localize("tile.fillerBlock"); - fontRenderer.drawString(title, getCenteredOffset(title), 6, 0x404040); - fontRenderer.drawString(StringUtils.localize("gui.filling.resources"), 8, 74, 0x404040); - fontRenderer.drawString(StringUtils.localize("gui.inventory"), 8, 142, 0x404040); - GuiTools.drawCenteredString(fontRenderer, filler.currentPattern.getDisplayName(), 56); + fontRendererObj.drawString(title, getCenteredOffset(title), 6, 0x404040); + fontRendererObj.drawString(StringUtils.localize("gui.filling.resources"), 8, 74, 0x404040); + fontRendererObj.drawString(StringUtils.localize("gui.inventory"), 8, 142, 0x404040); + GuiTools.drawCenteredString(fontRendererObj, filler.currentPattern.getDisplayName(), 56); } } diff --git a/common/buildcraft/builders/gui/GuiTemplate.java b/common/buildcraft/builders/gui/GuiTemplate.java index 5ba60ec4..9d841280 100644 --- a/common/buildcraft/builders/gui/GuiTemplate.java +++ b/common/buildcraft/builders/gui/GuiTemplate.java @@ -1,12 +1,14 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.builders.gui; +import buildcraft.BuildCraftBuilders; import buildcraft.builders.TileArchitect; import buildcraft.core.DefaultProps; import buildcraft.core.gui.GuiBuildCraft; @@ -43,13 +45,13 @@ public class GuiTemplate extends GuiBuildCraft { @Override protected void drawGuiContainerForegroundLayer(int par1, int par2) { String title = StringUtils.localize("tile.architectBlock"); - fontRenderer.drawString(title, getCenteredOffset(title), 6, 0x404040); - fontRenderer.drawString(StringUtils.localize("gui.inventory"), 8, ySize - 152, 0x404040); + fontRendererObj.drawString(title, getCenteredOffset(title), 6, 0x404040); + fontRendererObj.drawString(StringUtils.localize("gui.inventory"), 8, ySize - 152, 0x404040); if (editMode && ((new Date()).getTime() / 100) % 8 >= 4) { - fontRenderer.drawString(template.name + "|", 51, 62, 0x404040); + fontRendererObj.drawString(template.name + "|", 51, 62, 0x404040); } else { - fontRenderer.drawString(template.name, 51, 62, 0x404040); + fontRendererObj.drawString(template.name, 51, 62, 0x404040); } } diff --git a/common/buildcraft/builders/network/PacketHandlerBuilders.java b/common/buildcraft/builders/network/PacketHandlerBuilders.java index a71483b7..1b492258 100644 --- a/common/buildcraft/builders/network/PacketHandlerBuilders.java +++ b/common/buildcraft/builders/network/PacketHandlerBuilders.java @@ -1,32 +1,49 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.builders.network; +import buildcraft.BuildCraftBuilders; import buildcraft.builders.TileArchitect; import buildcraft.builders.TileBlueprintLibrary; +import buildcraft.core.network.BuildCraftChannelHandler; +import buildcraft.core.network.BuildCraftPacket; import buildcraft.core.network.PacketIds; import buildcraft.core.network.PacketUpdate; -import cpw.mods.fml.common.network.IPacketHandler; -import cpw.mods.fml.common.network.Player; +import buildcraft.core.proxy.CoreProxy; +import buildcraft.core.utils.Utils; +import cpw.mods.fml.common.network.NetworkRegistry; +import io.netty.buffer.ByteBuf; +import io.netty.channel.ChannelHandlerContext; + import java.io.ByteArrayInputStream; import java.io.DataInputStream; + import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.network.INetworkManager; -import net.minecraft.network.packet.Packet250CustomPayload; +import net.minecraft.network.INetHandler; import net.minecraft.tileentity.TileEntity; -public class PacketHandlerBuilders implements IPacketHandler { +public class PacketHandlerBuilders extends BuildCraftChannelHandler { @Override - public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player) { + public void decodeInto(ChannelHandlerContext ctx, ByteBuf data, BuildCraftPacket packet) { + super.decodeInto(ctx, data, packet); - DataInputStream data = new DataInputStream(new ByteArrayInputStream(packet.data)); try { - int packetID = data.read(); + INetHandler netHandler = ctx.channel().attr(NetworkRegistry.NET_HANDLER).get(); + EntityPlayer player = Utils.getPlayerFromNetHandler(netHandler); + + int packetID = packet.getID(); + switch (packetID) { // FIXME: Replace that by a RPC case PacketIds.ARCHITECT_NAME: - PacketUpdate packetA = new PacketUpdate(); - packetA.readData(data); - onArchitectName((EntityPlayer) player, packetA); + onArchitectName(player, (PacketUpdate) packet); break; } } catch (Exception ex) { diff --git a/common/buildcraft/builders/network/PacketLibraryAction.java b/common/buildcraft/builders/network/PacketLibraryAction.java new file mode 100644 index 00000000..1e91971e --- /dev/null +++ b/common/buildcraft/builders/network/PacketLibraryAction.java @@ -0,0 +1,40 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ +package buildcraft.builders.network; + +import buildcraft.core.network.PacketCoordinates; +import io.netty.buffer.ByteBuf; + +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; + +public class PacketLibraryAction extends PacketCoordinates { + + public int actionId; + + public PacketLibraryAction() { + } + + public PacketLibraryAction(int packetId, int x, int y, int z) { + super(packetId, x, y, z); + } + + @Override + public void writeData(ByteBuf data) { + data.writeInt(actionId); + super.writeData(data); + } + + @Override + public void readData(ByteBuf data) { + actionId = data.readInt(); + super.readData(data); + } +} diff --git a/common/buildcraft/builders/triggers/ActionFiller.java b/common/buildcraft/builders/triggers/ActionFiller.java index 05be1a8f..0c991df1 100644 --- a/common/buildcraft/builders/triggers/ActionFiller.java +++ b/common/buildcraft/builders/triggers/ActionFiller.java @@ -1,15 +1,16 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.builders.triggers; import buildcraft.api.filler.IFillerPattern; import buildcraft.core.triggers.*; -import net.minecraft.util.Icon; +import net.minecraft.util.IIcon; public class ActionFiller extends BCAction { @@ -26,7 +27,7 @@ public class ActionFiller extends BCAction { } @Override - public Icon getIcon() { + public IIcon getIcon() { return pattern.getIcon(); } diff --git a/common/buildcraft/builders/triggers/BuildersActionProvider.java b/common/buildcraft/builders/triggers/BuildersActionProvider.java index 3602034a..d4bfc1fc 100644 --- a/common/buildcraft/builders/triggers/BuildersActionProvider.java +++ b/common/buildcraft/builders/triggers/BuildersActionProvider.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.builders.triggers; import buildcraft.api.filler.FillerManager; @@ -8,10 +16,6 @@ import java.util.LinkedList; import net.minecraft.block.Block; import net.minecraft.tileentity.TileEntity; -/** - * - * @author CovertJaguar - */ public class BuildersActionProvider implements IActionProvider { @Override diff --git a/common/buildcraft/builders/urbanism/BlockUrbanist.java b/common/buildcraft/builders/urbanism/BlockUrbanist.java index c58020d4..82c54045 100755 --- a/common/buildcraft/builders/urbanism/BlockUrbanist.java +++ b/common/buildcraft/builders/urbanism/BlockUrbanist.java @@ -1,24 +1,27 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.builders.urbanism; -import buildcraft.BuildCraftBuilders; -import buildcraft.core.BlockBuildCraft; -import buildcraft.core.CreativeTabBuildCraft; -import buildcraft.core.GuiIds; -import buildcraft.core.proxy.CoreProxy; -import java.util.Random; - import net.minecraft.block.material.Material; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; +import buildcraft.BuildCraftBuilders; +import buildcraft.core.BlockBuildCraft; +import buildcraft.core.CreativeTabBuildCraft; +import buildcraft.core.GuiIds; public class BlockUrbanist extends BlockBuildCraft { - public static final Random rand = new Random(); - @Override public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer entityplayer, int par6, float par7, float par8, float par9) { - if (!CoreProxy.proxy.isRenderWorld(world)) { + if (!world.isRemote) { entityplayer.openGui(BuildCraftBuilders.instance, GuiIds.URBANIST, world, i, j, k); } @@ -27,18 +30,17 @@ public class BlockUrbanist extends BlockBuildCraft { } - public BlockUrbanist(int id) { - super(id, Material.rock); + public BlockUrbanist() { + super(Material.rock); setBlockUnbreakable(); setResistance(6000000.0F); - setStepSound(soundStoneFootstep); disableStats(); setTickRandomly(true); setCreativeTab(CreativeTabBuildCraft.MACHINES.get()); } @Override - public TileEntity createNewTileEntity(World var1) { + public TileEntity createNewTileEntity(World var1, int var2) { return new TileUrbanist(); } } diff --git a/common/buildcraft/builders/urbanism/EntityRobotUrbanism.java b/common/buildcraft/builders/urbanism/EntityRobotUrbanism.java index c3e9d893..1483503f 100755 --- a/common/buildcraft/builders/urbanism/EntityRobotUrbanism.java +++ b/common/buildcraft/builders/urbanism/EntityRobotUrbanism.java @@ -1,8 +1,15 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.builders.urbanism; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; -import buildcraft.core.proxy.CoreProxy; import buildcraft.core.robots.EntityRobot; public class EntityRobotUrbanism extends EntityRobot { @@ -20,7 +27,7 @@ public class EntityRobotUrbanism extends EntityRobot { public void setTask (UrbanistTask task) { this.task = task; - if (CoreProxy.proxy.isSimulating(worldObj)) { + if (!worldObj.isRemote) { task.setup(this); } } @@ -29,7 +36,7 @@ public class EntityRobotUrbanism extends EntityRobot { public void onUpdate() { super.onUpdate(); - if (CoreProxy.proxy.isSimulating(worldObj)) { + if (!worldObj.isRemote) { if (task != null) { task.work(this); @@ -44,7 +51,4 @@ public class EntityRobotUrbanism extends EntityRobot { public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) { this.setDead(); } - - - } diff --git a/common/buildcraft/builders/urbanism/EntityUrbanist.java b/common/buildcraft/builders/urbanism/EntityUrbanist.java index 8f428add..79c21548 100755 --- a/common/buildcraft/builders/urbanism/EntityUrbanist.java +++ b/common/buildcraft/builders/urbanism/EntityUrbanist.java @@ -1,10 +1,13 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.builders.urbanism; -import org.lwjgl.input.Keyboard; -import org.lwjgl.input.Mouse; - -import buildcraft.api.core.Position; -import buildcraft.core.EntityEnergyLaser; import net.minecraft.client.Minecraft; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; @@ -12,6 +15,12 @@ import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.Vec3; import net.minecraft.world.World; +import org.lwjgl.input.Keyboard; +import org.lwjgl.input.Mouse; + +import buildcraft.api.core.Position; +import buildcraft.core.EntityEnergyLaser; + public class EntityUrbanist extends EntityLivingBase { /** @@ -43,34 +52,34 @@ public class EntityUrbanist extends EntityLivingBase { motionY = 0; motionZ = 0; - if (!Keyboard.isKeyDown(Minecraft.getMinecraft().gameSettings.keyBindSneak.keyCode)) { - if (Keyboard.isKeyDown(Minecraft.getMinecraft().gameSettings.keyBindLeft.keyCode)) { + if (!Keyboard.isKeyDown(Minecraft.getMinecraft().gameSettings.keyBindSneak.getKeyCode())) { + if (Keyboard.isKeyDown(Minecraft.getMinecraft().gameSettings.keyBindLeft.getKeyCode())) { motionX = side.xCoord * 0.5; motionZ = side.zCoord * 0.5; - } else if (Keyboard.isKeyDown(Minecraft.getMinecraft().gameSettings.keyBindRight.keyCode)) { + } else if (Keyboard.isKeyDown(Minecraft.getMinecraft().gameSettings.keyBindRight.getKeyCode())) { motionX = side.xCoord * -0.5; motionZ = side.zCoord * -0.5; } } else { - if (Keyboard.isKeyDown(Minecraft.getMinecraft().gameSettings.keyBindLeft.keyCode)) { + if (Keyboard.isKeyDown(Minecraft.getMinecraft().gameSettings.keyBindLeft.getKeyCode())) { setAngles (-10, 0); - } else if (Keyboard.isKeyDown(Minecraft.getMinecraft().gameSettings.keyBindRight.keyCode)) { + } else if (Keyboard.isKeyDown(Minecraft.getMinecraft().gameSettings.keyBindRight.getKeyCode())) { setAngles (10, 0); } } - if (!Keyboard.isKeyDown(Minecraft.getMinecraft().gameSettings.keyBindSneak.keyCode)) { - if (Keyboard.isKeyDown(Minecraft.getMinecraft().gameSettings.keyBindForward.keyCode)) { + if (!Keyboard.isKeyDown(Minecraft.getMinecraft().gameSettings.keyBindSneak.getKeyCode())) { + if (Keyboard.isKeyDown(Minecraft.getMinecraft().gameSettings.keyBindForward.getKeyCode())) { motionX = forward.xCoord * 0.5; motionZ = forward.zCoord * 0.5; - } else if (Keyboard.isKeyDown(Minecraft.getMinecraft().gameSettings.keyBindBack.keyCode)) { + } else if (Keyboard.isKeyDown(Minecraft.getMinecraft().gameSettings.keyBindBack.getKeyCode())) { motionX = forward.xCoord * -0.5; motionZ = forward.zCoord * -0.5; } } else { - if (Keyboard.isKeyDown(Minecraft.getMinecraft().gameSettings.keyBindForward.keyCode)) { + if (Keyboard.isKeyDown(Minecraft.getMinecraft().gameSettings.keyBindForward.getKeyCode())) { setAngles(0, 10); - } else if (Keyboard.isKeyDown(Minecraft.getMinecraft().gameSettings.keyBindBack.keyCode)) { + } else if (Keyboard.isKeyDown(Minecraft.getMinecraft().gameSettings.keyBindBack.getKeyCode())) { setAngles(0, -10); } } @@ -90,11 +99,6 @@ public class EntityUrbanist extends EntityLivingBase { return null; } - @Override - public ItemStack getCurrentItemOrArmor(int i) { - return null; - } - @Override public void setCurrentItemOrArmor(int i, ItemStack itemstack) { @@ -150,7 +154,7 @@ public class EntityUrbanist extends EntityLivingBase { Vec3 vec32 = pos.addVector(look.xCoord * distance, look.yCoord * distance, look.zCoord * distance); - MovingObjectPosition result = this.worldObj.clip(pos, vec32); + MovingObjectPosition result = this.worldObj.rayTraceBlocks(pos, vec32); if (debugPointer) { if (laser == null) { @@ -184,4 +188,9 @@ public class EntityUrbanist extends EntityLivingBase { return result; } + @Override + public ItemStack getEquipmentInSlot(int var1) { + return null; + } + } diff --git a/common/buildcraft/builders/urbanism/GuiUrbanist.java b/common/buildcraft/builders/urbanism/GuiUrbanist.java index c8f95405..40691c9d 100755 --- a/common/buildcraft/builders/urbanism/GuiUrbanist.java +++ b/common/buildcraft/builders/urbanism/GuiUrbanist.java @@ -1,24 +1,25 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.builders.urbanism; import java.util.LinkedList; -import buildcraft.core.DefaultProps; -import buildcraft.core.gui.AdvancedSlot; -import buildcraft.core.gui.GuiAdvancedInterface; import net.minecraft.inventory.IInventory; -import net.minecraft.util.Icon; +import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; +import buildcraft.core.DefaultProps; +import buildcraft.core.gui.AdvancedSlot; +import buildcraft.core.gui.GuiAdvancedInterface; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -43,7 +44,7 @@ public class GuiUrbanist extends GuiAdvancedInterface { @SideOnly(Side.CLIENT) @Override - public Icon getIcon() { + public IIcon getIcon() { return tool.getIcon(); } diff --git a/common/buildcraft/builders/urbanism/TileUrbanist.java b/common/buildcraft/builders/urbanism/TileUrbanist.java index 1f44aac3..8f431bdf 100755 --- a/common/buildcraft/builders/urbanism/TileUrbanist.java +++ b/common/buildcraft/builders/urbanism/TileUrbanist.java @@ -1,24 +1,32 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.builders.urbanism; import java.util.LinkedList; import java.util.List; +import net.minecraft.client.Minecraft; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; import buildcraft.builders.blueprints.BlueprintBuilder; import buildcraft.builders.blueprints.BlueprintBuilder.SchematicBuilder; import buildcraft.builders.filler.pattern.FillerPattern; import buildcraft.core.Box; import buildcraft.core.EntityFrame; +import buildcraft.core.EntityFrame.Kind; import buildcraft.core.IBuilderInventory; import buildcraft.core.TileBuildCraft; -import buildcraft.core.EntityFrame.Kind; import buildcraft.core.network.RPC; import buildcraft.core.network.RPCHandler; import buildcraft.core.network.RPCSide; -import net.minecraft.block.Block; -import net.minecraft.client.Minecraft; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; public class TileUrbanist extends TileBuildCraft implements IBuilderInventory { @@ -87,7 +95,7 @@ public class TileUrbanist extends TileBuildCraft implements IBuilderInventory { @RPC (RPCSide.SERVER) public void setBlock (int x, int y, int z) { - worldObj.setBlock(x, y, z, Block.brick.blockID); + worldObj.setBlock(x, y, z, Blocks.brick_block); } @RPC (RPCSide.SERVER) @@ -232,12 +240,6 @@ public class TileUrbanist extends TileBuildCraft implements IBuilderInventory { } - @Override - public String getInvName() { - // TODO Auto-generated method stub - return "Urbanist"; - } - @Override public int getInventoryStackLimit() { // TODO Auto-generated method stub @@ -249,18 +251,6 @@ public class TileUrbanist extends TileBuildCraft implements IBuilderInventory { return true; } - @Override - public void openChest() { - // TODO Auto-generated method stub - - } - - @Override - public void closeChest() { - // TODO Auto-generated method stub - - } - @Override public boolean isItemValidForSlot(int i, ItemStack itemstack) { // TODO Auto-generated method stub @@ -273,4 +263,28 @@ public class TileUrbanist extends TileBuildCraft implements IBuilderInventory { return false; } + @Override + public String getInventoryName() { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean hasCustomInventoryName() { + // TODO Auto-generated method stub + return false; + } + + @Override + public void openInventory() { + // TODO Auto-generated method stub + + } + + @Override + public void closeInventory() { + // TODO Auto-generated method stub + + } + } diff --git a/common/buildcraft/builders/urbanism/UrbanistTask.java b/common/buildcraft/builders/urbanism/UrbanistTask.java index 6dd8f1b1..90534060 100755 --- a/common/buildcraft/builders/urbanism/UrbanistTask.java +++ b/common/buildcraft/builders/urbanism/UrbanistTask.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.builders.urbanism; public class UrbanistTask { diff --git a/common/buildcraft/builders/urbanism/UrbanistTaskBuildSchematic.java b/common/buildcraft/builders/urbanism/UrbanistTaskBuildSchematic.java index 1949d637..334e28ae 100755 --- a/common/buildcraft/builders/urbanism/UrbanistTaskBuildSchematic.java +++ b/common/buildcraft/builders/urbanism/UrbanistTaskBuildSchematic.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.builders.urbanism; import buildcraft.builders.blueprints.BlueprintBuilder.SchematicBuilder; @@ -16,10 +24,12 @@ public class UrbanistTaskBuildSchematic extends UrbanistTask { this.task = task; } + @Override public void setup(EntityRobotUrbanism robot) { //robot.setDestinationAround(builder.getX(), builder.getY(), builder.getZ()); } + @Override public void work(EntityRobotUrbanism robot) { if (!inBuild && robot.getDistance(builder.getX(), builder.getY(), builder.getZ()) <= 10) { inBuild = true; @@ -32,6 +42,7 @@ public class UrbanistTaskBuildSchematic extends UrbanistTask { } } + @Override public boolean done() { return builder.isComplete(); } diff --git a/common/buildcraft/builders/urbanism/UrbanistTaskErase.java b/common/buildcraft/builders/urbanism/UrbanistTaskErase.java index d2d143bc..520bc9bb 100755 --- a/common/buildcraft/builders/urbanism/UrbanistTaskErase.java +++ b/common/buildcraft/builders/urbanism/UrbanistTaskErase.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.builders.urbanism; public class UrbanistTaskErase extends UrbanistTask { @@ -14,10 +22,12 @@ public class UrbanistTaskErase extends UrbanistTask { this.z = z; } + @Override public void setup(EntityRobotUrbanism robot) { //robot.setDestinationAround(x, y, z); } + @Override public void work(EntityRobotUrbanism robot) { if (!inBreak && robot.getDistance(x, y, z) <= 10) { inBreak = true; @@ -33,6 +43,7 @@ public class UrbanistTaskErase extends UrbanistTask { } } + @Override public boolean done() { return isDone; } diff --git a/common/buildcraft/builders/urbanism/UrbanistTool.java b/common/buildcraft/builders/urbanism/UrbanistTool.java index 0d92ae56..1892a01d 100755 --- a/common/buildcraft/builders/urbanism/UrbanistTool.java +++ b/common/buildcraft/builders/urbanism/UrbanistTool.java @@ -1,13 +1,21 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.builders.urbanism; import java.util.LinkedList; -import buildcraft.core.gui.AdvancedSlot; -import net.minecraft.util.Icon; +import net.minecraft.util.IIcon; import net.minecraft.util.MovingObjectPosition; +import buildcraft.core.gui.AdvancedSlot; class UrbanistTool { - public Icon getIcon() { + public IIcon getIcon() { return null; } diff --git a/common/buildcraft/builders/urbanism/UrbanistToolArea.java b/common/buildcraft/builders/urbanism/UrbanistToolArea.java index af3cc164..aee19d6a 100755 --- a/common/buildcraft/builders/urbanism/UrbanistToolArea.java +++ b/common/buildcraft/builders/urbanism/UrbanistToolArea.java @@ -1,14 +1,22 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.builders.urbanism; +import net.minecraft.client.Minecraft; +import net.minecraft.util.IIcon; +import net.minecraft.util.MovingObjectPosition; + import org.lwjgl.input.Mouse; -import net.minecraft.client.Minecraft; -import net.minecraft.util.Icon; -import net.minecraft.util.MovingObjectPosition; - class UrbanistToolArea extends UrbanistTool { @Override - public Icon getIcon() { + public IIcon getIcon() { return UrbanistToolsIconProvider.INSTANCE.getIcon(UrbanistToolsIconProvider.Tool_Area); } diff --git a/common/buildcraft/builders/urbanism/UrbanistToolBlock.java b/common/buildcraft/builders/urbanism/UrbanistToolBlock.java index 393cc301..aca5b6b1 100755 --- a/common/buildcraft/builders/urbanism/UrbanistToolBlock.java +++ b/common/buildcraft/builders/urbanism/UrbanistToolBlock.java @@ -1,9 +1,17 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.builders.urbanism; -import buildcraft.core.DefaultProps; import net.minecraft.client.Minecraft; -import net.minecraft.util.Icon; +import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; +import buildcraft.core.DefaultProps; class UrbanistToolBlock extends UrbanistTool { @@ -12,7 +20,7 @@ class UrbanistToolBlock extends UrbanistTool { private static final int GUI_TEXTURE_HEIGHT = 210; @Override - public Icon getIcon() { + public IIcon getIcon() { return UrbanistToolsIconProvider.INSTANCE.getIcon(UrbanistToolsIconProvider.Tool_Block_Place); } diff --git a/common/buildcraft/builders/urbanism/UrbanistToolBlueprint.java b/common/buildcraft/builders/urbanism/UrbanistToolBlueprint.java index 13ac2d3d..92c8973d 100755 --- a/common/buildcraft/builders/urbanism/UrbanistToolBlueprint.java +++ b/common/buildcraft/builders/urbanism/UrbanistToolBlueprint.java @@ -1,10 +1,18 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.builders.urbanism; -import net.minecraft.util.Icon; +import net.minecraft.util.IIcon; class UrbanistToolBlueprint extends UrbanistTool { @Override - public Icon getIcon() { + public IIcon getIcon() { return UrbanistToolsIconProvider.INSTANCE.getIcon(UrbanistToolsIconProvider.Tool_Blueprint); } diff --git a/common/buildcraft/builders/urbanism/UrbanistToolErase.java b/common/buildcraft/builders/urbanism/UrbanistToolErase.java index dacbd4b7..1d188fce 100755 --- a/common/buildcraft/builders/urbanism/UrbanistToolErase.java +++ b/common/buildcraft/builders/urbanism/UrbanistToolErase.java @@ -1,12 +1,20 @@ +/** + * Copyright (c) 2011-2014, SpaceToaimport javax.swing.Icon; + +import net.minecraft.util.MovingObjectPosition; +istributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.builders.urbanism; -import net.minecraft.util.Icon; +import net.minecraft.util.IIcon; import net.minecraft.util.MovingObjectPosition; class UrbanistToolErase extends UrbanistTool { @Override - public Icon getIcon() { + public IIcon getIcon() { return UrbanistToolsIconProvider.INSTANCE.getIcon(UrbanistToolsIconProvider.Tool_Block_Erase); } @@ -19,5 +27,4 @@ class UrbanistToolErase extends UrbanistTool { public void worldClicked (GuiUrbanist gui, MovingObjectPosition pos) { gui.urbanist.rpcEraseBlock(pos.blockX, pos.blockY, pos.blockZ); } - } \ No newline at end of file diff --git a/common/buildcraft/builders/urbanism/UrbanistToolFiller.java b/common/buildcraft/builders/urbanism/UrbanistToolFiller.java index deb09cb4..fa04095e 100755 --- a/common/buildcraft/builders/urbanism/UrbanistToolFiller.java +++ b/common/buildcraft/builders/urbanism/UrbanistToolFiller.java @@ -1,20 +1,28 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.builders.urbanism; import java.util.ArrayList; import java.util.LinkedList; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; import buildcraft.api.filler.IFillerPattern; import buildcraft.builders.filler.pattern.FillerPattern; import buildcraft.core.Box; import buildcraft.core.DefaultProps; import buildcraft.core.gui.AdvancedSlot; import buildcraft.core.gui.GuiAdvancedInterface; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.texture.TextureMap; -import net.minecraft.util.Icon; -import net.minecraft.util.ResourceLocation; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; class UrbanistToolFiller extends UrbanistToolArea { @@ -38,13 +46,14 @@ class UrbanistToolFiller extends UrbanistToolArea { this.index = index; } + @Override public ResourceLocation getTexture() { return TextureMap.locationBlocksTexture; } @SideOnly(Side.CLIENT) @Override - public Icon getIcon() { + public IIcon getIcon() { if (index < patterns.size()) { return getPattern().getIcon(); } else { @@ -79,7 +88,7 @@ class UrbanistToolFiller extends UrbanistToolArea { } @Override - public Icon getIcon() { + public IIcon getIcon() { return UrbanistToolsIconProvider.INSTANCE.getIcon(UrbanistToolsIconProvider.Tool_Filler); } diff --git a/common/buildcraft/builders/urbanism/UrbanistToolPath.java b/common/buildcraft/builders/urbanism/UrbanistToolPath.java index 0741aef1..7d1d81e5 100755 --- a/common/buildcraft/builders/urbanism/UrbanistToolPath.java +++ b/common/buildcraft/builders/urbanism/UrbanistToolPath.java @@ -1,10 +1,18 @@ +/** + * Copyright (c) 2011-2014, SpaceToaimport javax.swing.Icon; +p://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.builders.urbanism; -import net.minecraft.util.Icon; +import net.minecraft.util.IIcon; class UrbanistToolPath extends UrbanistTool { @Override - public Icon getIcon() { + public IIcon getIcon() { return UrbanistToolsIconProvider.INSTANCE.getIcon(UrbanistToolsIconProvider.Tool_Path); } diff --git a/common/buildcraft/builders/urbanism/UrbanistToolsIconProvider.java b/common/buildcraft/builders/urbanism/UrbanistToolsIconProvider.java index 4dbbf602..a0cf9b62 100755 --- a/common/buildcraft/builders/urbanism/UrbanistToolsIconProvider.java +++ b/common/buildcraft/builders/urbanism/UrbanistToolsIconProvider.java @@ -1,10 +1,18 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.builders.urbanism; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.util.IIcon; import buildcraft.api.core.IIconProvider; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.client.renderer.texture.IconRegister; -import net.minecraft.util.Icon; public class UrbanistToolsIconProvider implements IIconProvider { @@ -18,20 +26,20 @@ public class UrbanistToolsIconProvider implements IIconProvider { public static final int MAX = 6; @SideOnly(Side.CLIENT) - private final Icon[] icons = new Icon[MAX]; + private final IIcon[] icons = new IIcon[MAX]; private UrbanistToolsIconProvider() { } @Override @SideOnly(Side.CLIENT) - public Icon getIcon(int iconIndex) { + public IIcon getIcon(int iconIndex) { return icons[iconIndex]; } @Override @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister iconRegister) { + public void registerIcons(IIconRegister iconRegister) { icons[UrbanistToolsIconProvider.Tool_Block_Place] = iconRegister.registerIcon("buildcraft:icons/urbanist_block"); icons[UrbanistToolsIconProvider.Tool_Block_Erase] = iconRegister.registerIcon("buildcraft:icons/urbanist_erase"); icons[UrbanistToolsIconProvider.Tool_Area] = iconRegister.registerIcon("buildcraft:icons/urbanist_area"); diff --git a/common/buildcraft/core/BlockBuildCraft.java b/common/buildcraft/core/BlockBuildCraft.java index 7540131a..b4957d29 100644 --- a/common/buildcraft/core/BlockBuildCraft.java +++ b/common/buildcraft/core/BlockBuildCraft.java @@ -1,7 +1,18 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core; import buildcraft.core.utils.Utils; + import java.util.Random; + +import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.entity.EntityLivingBase; @@ -15,8 +26,8 @@ public abstract class BlockBuildCraft extends BlockContainer { protected static boolean keepInventory = false; protected final Random rand = new Random(); - protected BlockBuildCraft(int id, Material material) { - super(id, material); + protected BlockBuildCraft(Material material) { + super(material); setCreativeTab(CreativeTabBuildCraft.MACHINES.get()); setHardness(5F); } @@ -24,21 +35,21 @@ public abstract class BlockBuildCraft extends BlockContainer { @Override public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) { super.onBlockPlacedBy(world, x, y, z, entity, stack); - TileEntity tile = world.getBlockTileEntity(x, y, z); + TileEntity tile = world.getTileEntity(x, y, z); if (tile instanceof TileBuildCraft) { ((TileBuildCraft) tile).onBlockPlacedBy(entity, stack); } } @Override - public void breakBlock(World world, int x, int y, int z, int par5, int par6) { + public void breakBlock(World world, int x, int y, int z, Block block, int par6) { Utils.preDestroyBlock(world, x, y, z); - super.breakBlock(world, x, y, z, par5, par6); + super.breakBlock(world, x, y, z, block, par6); } @Override public int getLightValue(IBlockAccess world, int x, int y, int z) { - TileEntity tile = world.getBlockTileEntity(x, y, z); + TileEntity tile = world.getTileEntity(x, y, z); if (tile instanceof IMachine && ((IMachine) tile).isActive()) return super.getLightValue(world, x, y, z) + 8; return super.getLightValue(world, x, y, z); diff --git a/common/buildcraft/core/BlockIndex.java b/common/buildcraft/core/BlockIndex.java index 551fa6fd..508f9543 100644 --- a/common/buildcraft/core/BlockIndex.java +++ b/common/buildcraft/core/BlockIndex.java @@ -1,14 +1,14 @@ /** - * Copyright (c) SpaceToad, 2011 + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.core; +import net.minecraft.block.Block; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; @@ -67,8 +67,8 @@ public class BlockIndex implements Comparable { c.setInteger("k", z); } - public int getBlockId(World world) { - return world.getBlockId(x, y, z); + public Block getBlock(World world) { + return world.getBlock(x, y, z); } @Override diff --git a/common/buildcraft/core/BlockScanner.java b/common/buildcraft/core/BlockScanner.java index b1b9db72..3267a507 100755 --- a/common/buildcraft/core/BlockScanner.java +++ b/common/buildcraft/core/BlockScanner.java @@ -10,7 +10,6 @@ package buildcraft.core; import java.util.Iterator; -import net.minecraft.block.Block; import net.minecraft.world.World; public class BlockScanner implements Iterable { @@ -54,8 +53,8 @@ public class BlockScanner implements Iterable { BlockWrapper w = new BlockWrapper(); w.index = new BlockIndex(x, y, z); - w.block = Block.blocksList [world.getBlockId(x, y, z)]; - w.tile = world.getBlockTileEntity(x, y, z); + w.block = world.getBlock (x, y, z); + w.tile = world.getTileEntity(x, y, z); return w; } diff --git a/common/buildcraft/core/BlockSpring.java b/common/buildcraft/core/BlockSpring.java index 6859e820..32f8779a 100644 --- a/common/buildcraft/core/BlockSpring.java +++ b/common/buildcraft/core/BlockSpring.java @@ -1,13 +1,25 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; + import java.util.List; import java.util.Random; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; -import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; @@ -17,7 +29,7 @@ public class BlockSpring extends Block { public enum EnumSpring { - WATER(5, -1, Block.waterStill), + WATER(5, -1, Blocks.water), OIL(6000, 8, null); // Set in BuildCraftEnergy public static final EnumSpring[] VALUES = values(); public final int tickRate, chance; @@ -38,18 +50,21 @@ public class BlockSpring extends Block { } } - public BlockSpring(int id) { - super(id, Material.rock); + public BlockSpring() { + super(Material.rock); setBlockUnbreakable(); setResistance(6000000.0F); - setStepSound(soundStoneFootstep); + + // TODO: set proper sound + //setStepSound(soundStoneFootstep); + disableStats(); setTickRandomly(true); setCreativeTab(CreativeTabBuildCraft.MACHINES.get()); } @Override - public void getSubBlocks(int id, CreativeTabs tab, List list) { + public void getSubBlocks(Item item, CreativeTabs tab, List list) { for (EnumSpring type : EnumSpring.VALUES) { list.add(new ItemStack(this, 1, type.ordinal())); } @@ -73,13 +88,13 @@ public class BlockSpring extends Block { public void onBlockAdded(World world, int x, int y, int z) { super.onBlockAdded(world, x, y, z); int meta = world.getBlockMetadata(x, y, z); - world.scheduleBlockUpdate(x, y, z, blockID, EnumSpring.fromMeta(meta).tickRate); + world.scheduleBlockUpdate(x, y, z, this, EnumSpring.fromMeta(meta).tickRate); } private void assertSpring(World world, int x, int y, int z) { int meta = world.getBlockMetadata(x, y, z); EnumSpring spring = EnumSpring.fromMeta(meta); - world.scheduleBlockUpdate(x, y, z, blockID, spring.tickRate); + world.scheduleBlockUpdate(x, y, z, this, spring.tickRate); if (!spring.canGen || spring.liquidBlock == null) { return; } @@ -89,18 +104,18 @@ public class BlockSpring extends Block { if (spring.chance != -1 && rand.nextInt(spring.chance) != 0) { return; } - world.setBlock(x, y + 1, z, spring.liquidBlock.blockID); + world.setBlock(x, y + 1, z, spring.liquidBlock); } // Prevents updates on chunk generation @Override - public boolean func_82506_l() { + public boolean func_149698_L () { return false; } @Override @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister par1IconRegister) { + public void registerBlockIcons(IIconRegister par1IconRegister) { blockIcon = par1IconRegister.registerIcon("bedrock"); } } diff --git a/common/buildcraft/core/Box.java b/common/buildcraft/core/Box.java index d808b6ff..61f3a14f 100644 --- a/common/buildcraft/core/Box.java +++ b/common/buildcraft/core/Box.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.core; @@ -14,11 +15,14 @@ import buildcraft.api.core.Position; import buildcraft.core.network.NetworkData; import buildcraft.core.proxy.CoreProxy; import buildcraft.core.utils.Utils; +import io.netty.buffer.ByteBuf; + import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.util.ArrayList; import java.util.List; + import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; @@ -242,7 +246,7 @@ public class Box implements IBox { } } - public void writeToStream(DataOutputStream stream) throws IOException { + public void writeToStream(ByteBuf stream) { stream.writeBoolean(initialized); stream.writeInt(xMin); @@ -254,7 +258,7 @@ public class Box implements IBox { stream.writeInt(zMax); } - public void readFromStream(DataInputStream stream) throws IOException { + public void readFromStream(ByteBuf stream) { initialized = stream.readBoolean(); xMin = stream.readInt(); diff --git a/common/buildcraft/core/BuildCraftConfiguration.java b/common/buildcraft/core/BuildCraftConfiguration.java index 9f925e9f..7d78fa9e 100644 --- a/common/buildcraft/core/BuildCraftConfiguration.java +++ b/common/buildcraft/core/BuildCraftConfiguration.java @@ -1,17 +1,16 @@ /** - * Copyright (c) SpaceToad, 2011 + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.core; import java.io.File; -import net.minecraftforge.common.Configuration; -import net.minecraftforge.common.Property; +import net.minecraftforge.common.config.Configuration; +import net.minecraftforge.common.config.Property; public class BuildCraftConfiguration extends Configuration { diff --git a/common/buildcraft/core/CommandBuildCraft.java b/common/buildcraft/core/CommandBuildCraft.java index 6aa5b796..8961baab 100644 --- a/common/buildcraft/core/CommandBuildCraft.java +++ b/common/buildcraft/core/CommandBuildCraft.java @@ -1,12 +1,22 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core; import buildcraft.core.proxy.CoreProxy; + import java.util.List; + import net.minecraft.command.CommandBase; import net.minecraft.command.ICommand; import net.minecraft.command.ICommandSender; import net.minecraft.command.WrongUsageException; -import net.minecraft.util.ChatMessageComponent; +import net.minecraft.util.ChatComponentText; public class CommandBuildCraft extends CommandBase { @@ -46,9 +56,9 @@ public class CommandBuildCraft extends CommandBase { commandVersion(sender, arguments); return; } else if (arguments[0].matches("help")) { - sender.sendChatToPlayer(ChatMessageComponent.createFromText("Format: '" + this.getCommandName() + " '")); - sender.sendChatToPlayer(ChatMessageComponent.createFromText("Available commands:")); - sender.sendChatToPlayer(ChatMessageComponent.createFromText("- version : Version information.")); + sender.addChatMessage(new ChatComponentText("Format: '" + this.getCommandName() + " '")); + sender.addChatMessage(new ChatComponentText("Available commands:")); + sender.addChatMessage(new ChatComponentText("- version : Version information.")); return; } @@ -58,11 +68,11 @@ public class CommandBuildCraft extends CommandBase { private void commandVersion(ICommandSender sender, String[] arguments) { String colour = Version.isOutdated() ? "\u00A7c" : "\u00A7a"; - sender.sendChatToPlayer(ChatMessageComponent.createFromText(String.format(colour + "BuildCraft %s for Minecraft %s (Latest: %s).", Version.getVersion(), + sender.addChatMessage(new ChatComponentText(String.format(colour + "BuildCraft %s for Minecraft %s (Latest: %s).", Version.getVersion(), CoreProxy.proxy.getMinecraftVersion(), Version.getRecommendedVersion()))); if (Version.isOutdated()) { for (String updateLine : Version.getChangelog()) { - sender.sendChatToPlayer(ChatMessageComponent.createFromText("\u00A79" + updateLine)); + sender.addChatMessage(new ChatComponentText("\u00A79" + updateLine)); } } } diff --git a/common/buildcraft/core/CoreConstants.java b/common/buildcraft/core/CoreConstants.java index eb9ab89d..be161fe3 100644 --- a/common/buildcraft/core/CoreConstants.java +++ b/common/buildcraft/core/CoreConstants.java @@ -1,17 +1,13 @@ -/* - * Copyright (c) SpaceToad, 2011-2012 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * + * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.core; -/** - * - * @author CovertJaguar - */ public class CoreConstants { public static final float PIPE_MIN_POS = 0.25F; diff --git a/common/buildcraft/core/CoreIconProvider.java b/common/buildcraft/core/CoreIconProvider.java index 7b288956..6e3f2d65 100644 --- a/common/buildcraft/core/CoreIconProvider.java +++ b/common/buildcraft/core/CoreIconProvider.java @@ -1,10 +1,18 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core; import buildcraft.api.core.IIconProvider; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.client.renderer.texture.IconRegister; -import net.minecraft.util.Icon; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.util.IIcon; public class CoreIconProvider implements IIconProvider { @@ -12,18 +20,18 @@ public class CoreIconProvider implements IIconProvider { public static int MAX = 1; - private Icon[] _icons; + private IIcon[] _icons; @Override @SideOnly(Side.CLIENT) - public Icon getIcon(int iconIndex) { + public IIcon getIcon(int iconIndex) { return _icons[iconIndex]; } @Override @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister iconRegister) { - _icons = new Icon[MAX]; + public void registerIcons(IIconRegister iconRegister) { + _icons = new IIcon[MAX]; _icons[ENERGY] = iconRegister.registerIcon("buildcraft:icons/energy"); diff --git a/common/buildcraft/core/CreativeTabBuildCraft.java b/common/buildcraft/core/CreativeTabBuildCraft.java index da3c6b07..6b49b115 100644 --- a/common/buildcraft/core/CreativeTabBuildCraft.java +++ b/common/buildcraft/core/CreativeTabBuildCraft.java @@ -3,9 +3,13 @@ package buildcraft.core; import buildcraft.BuildCraftCore; import buildcraft.core.utils.Localization; import buildcraft.transport.ItemFacade; + import java.util.Locale; + import net.minecraft.block.Block; import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; public enum CreativeTabBuildCraft { @@ -33,7 +37,7 @@ public enum CreativeTabBuildCraft { private ItemStack getItem() { switch (this) { case FACADES: - return ItemFacade.getStack(Block.stoneBrick, 0); + return ItemFacade.getStack(Blocks.brick_block, 0); default: return new ItemStack(BuildCraftCore.diamondGearItem); } @@ -55,5 +59,10 @@ public enum CreativeTabBuildCraft { public String getTranslatedTabLabel() { return translate(); } + + @Override + public Item getTabIconItem() { + return getItem().getItem(); + } } } diff --git a/common/buildcraft/core/DefaultAreaProvider.java b/common/buildcraft/core/DefaultAreaProvider.java index e28844c8..8f01d0ae 100644 --- a/common/buildcraft/core/DefaultAreaProvider.java +++ b/common/buildcraft/core/DefaultAreaProvider.java @@ -1,12 +1,11 @@ /** - * Copyright (c) SpaceToad, 2011 + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.core; import buildcraft.api.core.IAreaProvider; diff --git a/common/buildcraft/core/DefaultProps.java b/common/buildcraft/core/DefaultProps.java index 80405780..98f00474 100644 --- a/common/buildcraft/core/DefaultProps.java +++ b/common/buildcraft/core/DefaultProps.java @@ -1,12 +1,11 @@ /** - * Copyright (c) SpaceToad, 2011 + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.core; public class DefaultProps { @@ -130,8 +129,6 @@ public class DefaultProps { public static int FUEL_ID = 1531; public static int REDPLASMA_ID = 1532; - public static int URBANIST_ID = 1533; - public static boolean CURRENT_CONTINUOUS = false; public static double PIPES_DURABILITY = 0.25D; public static boolean FILLER_DESTROY = false; @@ -139,6 +136,6 @@ public class DefaultProps { public static final int FILLER_LIFESPAN_TOUGH = 20; public static final int FILLER_LIFESPAN_NORMAL = 6000; - public static int BIOME_OIL_OCEAN = 160; - public static int BIOME_OIL_DESERT = 161; + public static int BIOME_OIL_OCEAN = 215; + public static int BIOME_OIL_DESERT = 216; } diff --git a/common/buildcraft/core/EntityBlock.java b/common/buildcraft/core/EntityBlock.java index 6c833306..c8070a02 100644 --- a/common/buildcraft/core/EntityBlock.java +++ b/common/buildcraft/core/EntityBlock.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.core; @@ -11,13 +12,13 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.entity.Entity; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.Icon; +import net.minecraft.util.IIcon; import net.minecraft.world.World; public class EntityBlock extends Entity { @SideOnly(Side.CLIENT) - public Icon texture; + public IIcon texture; public float shadowSize = 0; public float rotationX = 0; public float rotationY = 0; diff --git a/common/buildcraft/core/EntityEnergyLaser.java b/common/buildcraft/core/EntityEnergyLaser.java index eb324c93..aa6a5390 100644 --- a/common/buildcraft/core/EntityEnergyLaser.java +++ b/common/buildcraft/core/EntityEnergyLaser.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.core; diff --git a/common/buildcraft/core/EntityFrame.java b/common/buildcraft/core/EntityFrame.java index 1820fef7..1ae2c925 100755 --- a/common/buildcraft/core/EntityFrame.java +++ b/common/buildcraft/core/EntityFrame.java @@ -9,14 +9,13 @@ package buildcraft.core; import java.util.LinkedList; -import buildcraft.core.proxy.CoreProxy; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.entity.Entity; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.Icon; +import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class EntityFrame extends Entity { @@ -29,7 +28,7 @@ public class EntityFrame extends Entity { } @SideOnly(Side.CLIENT) - public Icon texture; + public IIcon texture; public Kind currentKind = Kind.RED_LASER; @@ -136,12 +135,12 @@ public class EntityFrame extends Entity { @Override public void onUpdate() { - if (CoreProxy.proxy.isSimulating(worldObj) && needsUpdate) { + if (!worldObj.isRemote && needsUpdate) { updateDataServer(); needsUpdate = false; } - if (CoreProxy.proxy.isRenderWorld(worldObj)) { + if (worldObj.isRemote) { updateDataClient(); } } diff --git a/common/buildcraft/core/EntityLaser.java b/common/buildcraft/core/EntityLaser.java index 93e154db..9c9adb94 100644 --- a/common/buildcraft/core/EntityLaser.java +++ b/common/buildcraft/core/EntityLaser.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.core; @@ -66,12 +67,12 @@ public abstract class EntityLaser extends Entity { if (data.head == null || data.tail == null) return; - if (CoreProxy.proxy.isSimulating(worldObj) && needsUpdate) { + if (!worldObj.isRemote && needsUpdate) { updateDataServer(); needsUpdate = false; } - if (CoreProxy.proxy.isRenderWorld(worldObj)) { + if (worldObj.isRemote) { updateDataClient(); } diff --git a/common/buildcraft/core/EntityPowerLaser.java b/common/buildcraft/core/EntityPowerLaser.java index edf3f424..57b6fa3a 100644 --- a/common/buildcraft/core/EntityPowerLaser.java +++ b/common/buildcraft/core/EntityPowerLaser.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core; import buildcraft.api.core.Position; diff --git a/common/buildcraft/core/GuiIds.java b/common/buildcraft/core/GuiIds.java index df387f8a..83ff6fc0 100644 --- a/common/buildcraft/core/GuiIds.java +++ b/common/buildcraft/core/GuiIds.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core; public class GuiIds { diff --git a/common/buildcraft/core/IBptContributor.java b/common/buildcraft/core/IBptContributor.java index 2e008e4b..e4522e15 100644 --- a/common/buildcraft/core/IBptContributor.java +++ b/common/buildcraft/core/IBptContributor.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core; import buildcraft.api.blueprints.BptSlotInfo; diff --git a/common/buildcraft/core/IBuilderInventory.java b/common/buildcraft/core/IBuilderInventory.java index 2b77922c..861c653e 100644 --- a/common/buildcraft/core/IBuilderInventory.java +++ b/common/buildcraft/core/IBuilderInventory.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core; import net.minecraft.inventory.IInventory; diff --git a/common/buildcraft/core/IDropControlInventory.java b/common/buildcraft/core/IDropControlInventory.java index f13c339f..3c248814 100644 --- a/common/buildcraft/core/IDropControlInventory.java +++ b/common/buildcraft/core/IDropControlInventory.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core; public interface IDropControlInventory { diff --git a/common/buildcraft/core/IFramePipeConnection.java b/common/buildcraft/core/IFramePipeConnection.java index 7dc850f8..e2301e3a 100644 --- a/common/buildcraft/core/IFramePipeConnection.java +++ b/common/buildcraft/core/IFramePipeConnection.java @@ -1,12 +1,11 @@ -/** - * Copyright (c) SpaceToad, 2011 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * - * BuildCraft is distributed under the terms of the Minecraft Mod Public + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.core; import net.minecraft.world.IBlockAccess; diff --git a/common/buildcraft/core/IItemPipe.java b/common/buildcraft/core/IItemPipe.java index ca8b2b45..f1778a07 100644 --- a/common/buildcraft/core/IItemPipe.java +++ b/common/buildcraft/core/IItemPipe.java @@ -1,12 +1,11 @@ /** - * Copyright (c) SpaceToad, 2011 + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.core; /** diff --git a/common/buildcraft/core/IMachine.java b/common/buildcraft/core/IMachine.java index 3ced98a9..4fb094d0 100644 --- a/common/buildcraft/core/IMachine.java +++ b/common/buildcraft/core/IMachine.java @@ -1,12 +1,11 @@ /** - * Copyright (c) SpaceToad, 2011 + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.core; import buildcraft.api.gates.IAction; diff --git a/common/buildcraft/core/ITileBufferHolder.java b/common/buildcraft/core/ITileBufferHolder.java index 39aea034..c070f522 100644 --- a/common/buildcraft/core/ITileBufferHolder.java +++ b/common/buildcraft/core/ITileBufferHolder.java @@ -1,24 +1,24 @@ /** - * Copyright (c) SpaceToad, 2011 + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.core; +import net.minecraft.block.Block; import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; public interface ITileBufferHolder { public void blockRemoved(ForgeDirection from); - public void blockCreated(ForgeDirection from, int blockID, TileEntity tile); + public void blockCreated(ForgeDirection from, Block block, TileEntity tile); - public int getBlockId(ForgeDirection to); + public Block getBlock(ForgeDirection to); public TileEntity getTile(ForgeDirection to); diff --git a/common/buildcraft/core/InterModComms.java b/common/buildcraft/core/InterModComms.java index 854b0bd4..cba54075 100644 --- a/common/buildcraft/core/InterModComms.java +++ b/common/buildcraft/core/InterModComms.java @@ -1,15 +1,17 @@ /** - * BuildCraft is open-source. It is distributed under the terms of the - * BuildCraft Open Source License. It grants rights to read, modify, compile or - * run the code. It does *NOT* grant the right to redistribute this software or - * its modifications in any form, binary or source, except if expressively - * granted by the copyright holder. + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.core; import java.util.logging.Level; import java.util.logging.Logger; +import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import net.minecraft.world.biome.BiomeGenBase; import buildcraft.energy.worldgen.OilPopulate; @@ -47,10 +49,12 @@ public class InterModComms { } else { Integer blId = Ints.tryParse(array[0]); Integer metaId = Ints.tryParse(array[1]); + if (blId == null || metaId == null) { Logger.getLogger("Buildcraft").log(Level.INFO, String.format("Received an invalid add-facade request %s from mod %s", m.getStringValue(), m.getSender())); } else { - ItemFacade.addFacade(new ItemStack(blId, 1, metaId)); + Block block = (Block) Block.blockRegistry.getObjectById(blId); + ItemFacade.addFacade(new ItemStack(block, 1, metaId)); } } } else if (m.isItemStackMessage()) { @@ -65,8 +69,8 @@ public class InterModComms { try { String biomeID = m.getStringValue().trim(); int id = Integer.valueOf(biomeID); - if (id >= BiomeGenBase.biomeList.length) { - throw new IllegalArgumentException("Biome ID must be less than " + BiomeGenBase.biomeList.length); + if (id >= BiomeGenBase.getBiomeGenArray().length) { + throw new IllegalArgumentException("Biome ID must be less than " + BiomeGenBase.getBiomeGenArray().length); } OilPopulate.INSTANCE.surfaceDepositBiomes.add(id); } catch (Exception ex) { @@ -79,8 +83,8 @@ public class InterModComms { try { String biomeID = m.getStringValue().trim(); int id = Integer.valueOf(biomeID); - if (id >= BiomeGenBase.biomeList.length) { - throw new IllegalArgumentException("Biome ID must be less than " + BiomeGenBase.biomeList.length); + if (id >= BiomeGenBase.getBiomeGenArray().length) { + throw new IllegalArgumentException("Biome ID must be less than " + BiomeGenBase.getBiomeGenArray().length); } OilPopulate.INSTANCE.excludedBiomes.add(id); } catch (Exception ex) { diff --git a/common/buildcraft/core/ItemBlockBuildCraft.java b/common/buildcraft/core/ItemBlockBuildCraft.java index 31f5df78..f30bc0fe 100644 --- a/common/buildcraft/core/ItemBlockBuildCraft.java +++ b/common/buildcraft/core/ItemBlockBuildCraft.java @@ -1,13 +1,22 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core; import buildcraft.core.utils.StringUtils; +import net.minecraft.block.Block; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; public class ItemBlockBuildCraft extends ItemBlock { - public ItemBlockBuildCraft(int id) { - super(id); + public ItemBlockBuildCraft(Block b) { + super(b); } @Override @@ -16,7 +25,7 @@ public class ItemBlockBuildCraft extends ItemBlock { } @Override - public String getItemDisplayName(ItemStack itemstack) { + public String getItemStackDisplayName(ItemStack itemstack) { return StringUtils.localize(getUnlocalizedName(itemstack)); } } diff --git a/common/buildcraft/core/ItemBuildCraft.java b/common/buildcraft/core/ItemBuildCraft.java index e0f8a609..d3d6998f 100644 --- a/common/buildcraft/core/ItemBuildCraft.java +++ b/common/buildcraft/core/ItemBuildCraft.java @@ -11,7 +11,8 @@ package buildcraft.core; import buildcraft.core.utils.StringUtils; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; @@ -21,13 +22,13 @@ public class ItemBuildCraft extends Item { private String iconName; private boolean passSneakClick = false; - public ItemBuildCraft(int i) { - super(i); + public ItemBuildCraft() { + super(); setCreativeTab(CreativeTabBuildCraft.MACHINES.get()); } @Override - public String getItemDisplayName(ItemStack itemstack) { + public String getItemStackDisplayName(ItemStack itemstack) { return StringUtils.localize(getUnlocalizedName(itemstack)); } @@ -39,7 +40,7 @@ public class ItemBuildCraft extends Item { @Override @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister par1IconRegister) { + public void registerIcons(IIconRegister par1IconRegister) { this.itemIcon = par1IconRegister.registerIcon("buildcraft:" + iconName); } @@ -49,7 +50,7 @@ public class ItemBuildCraft extends Item { } @Override - public boolean shouldPassSneakingClickToBlock(World par2World, int par4, int par5, int par6) { + public boolean doesSneakBypassUse(World world, int x, int y, int z, EntityPlayer player) { return passSneakClick; } } diff --git a/common/buildcraft/core/ItemRobot.java b/common/buildcraft/core/ItemRobot.java index c092b0a3..5424edc9 100755 --- a/common/buildcraft/core/ItemRobot.java +++ b/common/buildcraft/core/ItemRobot.java @@ -8,15 +8,15 @@ */ package buildcraft.core; -import buildcraft.core.robots.EntityRobot; import net.minecraft.world.World; +import buildcraft.core.robots.EntityRobot; public class ItemRobot extends ItemBuildCraft { Class robotClass; - public ItemRobot(int par1, Class robotClass) { - super(par1); + public ItemRobot(Class robotClass) { + super(); this.robotClass = robotClass; } diff --git a/common/buildcraft/core/ItemSpring.java b/common/buildcraft/core/ItemSpring.java index 53317134..deb2580d 100644 --- a/common/buildcraft/core/ItemSpring.java +++ b/common/buildcraft/core/ItemSpring.java @@ -1,21 +1,23 @@ -/** - * Copyright (c) SpaceToad, 2011 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * - * BuildCraft is distributed under the terms of the Minecraft Mod Public + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.core; import java.util.Locale; + +import net.minecraft.block.Block; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; public class ItemSpring extends ItemBlockBuildCraft { - public ItemSpring(int i) { - super(i); + public ItemSpring(Block block) { + super(block); setMaxDamage(0); setHasSubtypes(true); } diff --git a/common/buildcraft/core/ItemWrench.java b/common/buildcraft/core/ItemWrench.java index ae105191..5922b1b5 100644 --- a/common/buildcraft/core/ItemWrench.java +++ b/common/buildcraft/core/ItemWrench.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core; import buildcraft.api.tools.IToolWrench; @@ -10,14 +18,14 @@ import net.minecraft.block.BlockLever; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.world.World; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; public class ItemWrench extends ItemBuildCraft implements IToolWrench { private final Set> shiftRotations = new HashSet>(); - public ItemWrench(int i) { - super(i); + public ItemWrench() { + super(); setFull3D(); setMaxStackSize(1); shiftRotations.add(BlockLever.class); @@ -35,8 +43,7 @@ public class ItemWrench extends ItemBuildCraft implements IToolWrench { @Override public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) { - int blockId = world.getBlockId(x, y, z); - Block block = Block.blocksList[blockId]; + Block block = world.getBlock(x, y, z); if(block == null) return false; @@ -62,7 +69,7 @@ public class ItemWrench extends ItemBuildCraft implements IToolWrench { } @Override - public boolean shouldPassSneakingClickToBlock(World par2World, int par4, int par5, int par6) { + public boolean doesSneakBypassUse(World world, int x, int y, int z, EntityPlayer player) { return true; } } diff --git a/common/buildcraft/core/SpringPopulate.java b/common/buildcraft/core/SpringPopulate.java index b536409b..e8e0b560 100644 --- a/common/buildcraft/core/SpringPopulate.java +++ b/common/buildcraft/core/SpringPopulate.java @@ -1,24 +1,28 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.core; import buildcraft.BuildCraftCore; + import java.util.Random; + +import cpw.mods.fml.common.eventhandler.SubscribeEvent; import net.minecraft.block.Block; +import net.minecraft.init.Blocks; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; -import net.minecraftforge.event.ForgeSubscribe; import net.minecraftforge.event.terraingen.PopulateChunkEvent; import net.minecraftforge.event.terraingen.TerrainGen; public class SpringPopulate { - @ForgeSubscribe + @SubscribeEvent public void populate(PopulateChunkEvent.Post event) { boolean doGen = TerrainGen.populate(event.chunkProvider, event.world, event.rand, event.chunkX, event.chunkX, event.hasVillageGenerated, PopulateChunkEvent.Populate.EventType.CUSTOM); @@ -49,15 +53,15 @@ public class SpringPopulate { int posZ = z + random.nextInt(16); for(int i = 0; i < 5; i++) { - int candidate = world.getBlockId(posX, i, posZ); - if(candidate != Block.bedrock.blockID) + Block candidate = world.getBlock(posX, i, posZ); + if(candidate != Blocks.bedrock) continue; - world.setBlock(posX, i + 1, posZ, BuildCraftCore.springBlock.blockID); + world.setBlock(posX, i + 1, posZ, BuildCraftCore.springBlock); for(int j = i + 2; j < world.getActualHeight() - 10; j++) { if(!boreToSurface(world, posX, j, posZ)) { if(world.isAirBlock(posX, j, posZ)) - world.setBlock(posX, j, posZ, Block.waterStill.blockID); + world.setBlock(posX, j, posZ, Blocks.water); break; } } @@ -69,14 +73,14 @@ public class SpringPopulate { if(world.isAirBlock(x, y, z)) return false; - int existing = world.getBlockId(x, y, z); - if(existing != Block.stone.blockID - && existing != Block.dirt.blockID - && existing != Block.gravel.blockID - && existing != Block.grass.blockID) + Block existing = world.getBlock(x, y, z); + if(existing != Blocks.stone + && existing != Blocks.dirt + && existing != Blocks.gravel + && existing != Blocks.grass) return false; - world.setBlock(x, y, z, Block.waterStill.blockID); + world.setBlock(x, y, z, Blocks.water); return true; } } diff --git a/common/buildcraft/core/TickHandlerCoreClient.java b/common/buildcraft/core/TickHandlerCoreClient.java index 30dfc977..30b04759 100644 --- a/common/buildcraft/core/TickHandlerCoreClient.java +++ b/common/buildcraft/core/TickHandlerCoreClient.java @@ -1,51 +1,56 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core; import buildcraft.core.proxy.CoreProxy; -import cpw.mods.fml.common.ITickHandler; -import cpw.mods.fml.common.TickType; -import java.util.EnumSet; -import net.minecraft.entity.player.EntityPlayer; -public class TickHandlerCoreClient implements ITickHandler { +import java.util.EnumSet; + +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.TickEvent; +import cpw.mods.fml.common.gameevent.TickEvent.PlayerTickEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.ChatComponentText; + +public class TickHandlerCoreClient { private boolean nagged; - @Override - public void tickStart(EnumSet type, Object... tickData) { - } + @SideOnly(Side.CLIENT) + @SubscribeEvent + public void tickEnd(PlayerTickEvent evt) { - @Override - public void tickEnd(EnumSet type, Object... tickData) { - - if (nagged) + if (nagged) { return; + } - EntityPlayer player = (EntityPlayer) tickData[0]; + EntityPlayer player = evt.player; // if(!Config.disableVersionCheck) { if (Version.needsUpdateNoticeAndMarkAsSeen()) { - player.addChatMessage(String.format("\u00A7cNew version of BuildCraft available: %s for Minecraft %s", Version.getRecommendedVersion(), - CoreProxy.proxy.getMinecraftVersion())); + player.addChatMessage(new ChatComponentText( + String.format( + "\u00A7cNew version of BuildCraft available: %s for Minecraft %s", + Version.getRecommendedVersion(), + CoreProxy.proxy.getMinecraftVersion()))); for (String updateLine : Version.getChangelog()) { - player.addChatMessage("\u00A79" + updateLine); + player.addChatMessage(new ChatComponentText("\u00A79" + updateLine)); } - player.addChatMessage("\u00A7cThis message only displays once. Type '/buildcraft version' if you want to see it again."); + player.addChatMessage(new ChatComponentText( + "\u00A7cThis message only displays once. Type '/buildcraft version' if you want to see it again.")); } // } nagged = true; } - - @Override - public EnumSet ticks() { - return EnumSet.of(TickType.PLAYER); - } - - @Override - public String getLabel() { - return "BuildCraft - Player update tick"; - } - } diff --git a/common/buildcraft/core/TileBuffer.java b/common/buildcraft/core/TileBuffer.java index bfc82c49..a5f90d0f 100644 --- a/common/buildcraft/core/TileBuffer.java +++ b/common/buildcraft/core/TileBuffer.java @@ -8,16 +8,17 @@ */ package buildcraft.core; -import buildcraft.api.core.SafeTimeTracker; import net.minecraft.block.Block; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; +import buildcraft.api.core.SafeTimeTracker; public final class TileBuffer { - private int blockID = 0; + private Block block = null; private TileEntity tile; + private final SafeTimeTracker tracker = new SafeTimeTracker(20, 5); private final World world; final int x, y, z; @@ -35,40 +36,40 @@ public final class TileBuffer { public final void refresh() { tile = null; - blockID = 0; + block = null; if (!loadUnloaded && !world.blockExists(x, y, z)) { return; } - blockID = world.getBlockId(this.x, this.y, this.z); - - Block block = Block.blocksList[blockID]; + block = world.getBlock(this.x, this.y, this.z); if (block != null && block.hasTileEntity(world.getBlockMetadata(this.x, this.y, this.z))) { - tile = world.getBlockTileEntity(this.x, this.y, this.z); + tile = world.getTileEntity(this.x, this.y, this.z); } } - public void set(int blockID, TileEntity tile) { - this.blockID = blockID; + public void set(Block block, TileEntity tile) { + this.block = block; this.tile = tile; tracker.markTime(world); } - public int getBlockID() { + + public Block getBlock() { if (tile != null && !tile.isInvalid()) { - return blockID; + return block; } if (tracker.markTimeIfDelay(world)) { refresh(); - if (tile != null && !tile.isInvalid()) - return blockID; + if (tile != null && !tile.isInvalid()) { + return block; + } } - return 0; + return null; } public TileEntity getTile() { diff --git a/common/buildcraft/core/TileBuildCraft.java b/common/buildcraft/core/TileBuildCraft.java index 43b7af47..ff5b6ed3 100644 --- a/common/buildcraft/core/TileBuildCraft.java +++ b/common/buildcraft/core/TileBuildCraft.java @@ -1,13 +1,17 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.core; +import buildcraft.BuildCraftCore; +import buildcraft.BuildCraftMod; import buildcraft.api.power.IPowerReceptor; +import buildcraft.core.network.BuildCraftPacket; import buildcraft.core.network.ISynchronizedTile; import buildcraft.core.network.PacketPayload; import buildcraft.core.network.PacketPayloadStream; @@ -17,15 +21,23 @@ import buildcraft.core.network.TilePacketWrapper; import buildcraft.core.proxy.CoreProxy; import buildcraft.core.utils.Utils; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.EmptyByteBuf; +import io.netty.buffer.Unpooled; +import io.netty.buffer.UnpooledHeapByteBuf; + import java.io.IOException; import java.util.HashMap; import java.util.Map; +import cpw.mods.fml.common.network.internal.FMLProxyPacket; + import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.network.packet.Packet; +import net.minecraft.network.Packet; +import net.minecraft.network.PacketBuffer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; @@ -83,21 +95,22 @@ public abstract class TileBuildCraft extends TileEntity implements ISynchronized public void onBlockPlacedBy(EntityLivingBase entity, ItemStack stack) { if (entity instanceof EntityPlayer) - owner = ((EntityPlayer) entity).username; + owner = ((EntityPlayer) entity).getDisplayName(); } public void destroy() { } public void sendNetworkUpdate() { - if (CoreProxy.proxy.isSimulating(worldObj)) { - CoreProxy.proxy.sendToPlayers(getUpdatePacket(), worldObj, xCoord, yCoord, zCoord, DefaultProps.NETWORK_UPDATE_RANGE); + if (!worldObj.isRemote) { + BuildCraftCore.instance.sendToPlayers(getUpdatePacket(), worldObj, + xCoord, yCoord, zCoord, DefaultProps.NETWORK_UPDATE_RANGE); } } @Override public Packet getDescriptionPacket() { - return new PacketTileUpdate(this).getPacket(); + return Utils.toPacket(getUpdatePacket(), 0); } @Override @@ -106,20 +119,22 @@ public abstract class TileBuildCraft extends TileEntity implements ISynchronized } @Override - public Packet getUpdatePacket() { - return new PacketTileUpdate(this).getPacket(); + public BuildCraftPacket getUpdatePacket() { + return new PacketTileUpdate(this); } @Override public void handleDescriptionPacket(PacketUpdate packet) throws IOException { - if (packet.payload instanceof PacketPayloadStream) + if (packet.payload instanceof PacketPayloadStream) { descriptionPacket.fromPayload(this, (PacketPayloadStream) packet.payload); + } } @Override public void handleUpdatePacket(PacketUpdate packet) throws IOException { - if (packet.payload instanceof PacketPayloadStream) - updatePacket.fromPayload(this, (PacketPayloadStream) packet.payload); + if (packet.payload instanceof PacketPayloadStream) { + updatePacket.fromPayload(this, (PacketPayloadStream) packet.payload); + } } @Override @@ -139,11 +154,6 @@ public abstract class TileBuildCraft extends TileEntity implements ISynchronized owner = nbt.getString("owner"); } - public boolean isInvNameLocalized() { - // TODO Auto-generated method stub - return false; - } - public World getWorld() { return worldObj; } diff --git a/common/buildcraft/core/Version.java b/common/buildcraft/core/Version.java index 4cecd0e6..fd616df0 100644 --- a/common/buildcraft/core/Version.java +++ b/common/buildcraft/core/Version.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core; import buildcraft.BuildCraftCore; @@ -8,7 +16,7 @@ import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; import java.util.ArrayList; -import net.minecraftforge.common.Property; +import net.minecraftforge.common.config.Property; public class Version implements Runnable { diff --git a/common/buildcraft/core/blueprints/BptActionBuild.java b/common/buildcraft/core/blueprints/BptActionBuild.java index b8ece4a6..38af87fc 100644 --- a/common/buildcraft/core/blueprints/BptActionBuild.java +++ b/common/buildcraft/core/blueprints/BptActionBuild.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.blueprints; import buildcraft.api.blueprints.BptSlotInfo; diff --git a/common/buildcraft/core/blueprints/BptBase.java b/common/buildcraft/core/blueprints/BptBase.java index 819419d8..fca26d0d 100644 --- a/common/buildcraft/core/blueprints/BptBase.java +++ b/common/buildcraft/core/blueprints/BptBase.java @@ -1,12 +1,11 @@ /** - * Copyright (c) SpaceToad, 2011-2012 + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.core.blueprints; import buildcraft.BuildCraftCore; @@ -14,6 +13,7 @@ import buildcraft.core.Box; import buildcraft.core.Version; import buildcraft.core.proxy.CoreProxy; import buildcraft.core.utils.BCLog; + import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; @@ -25,6 +25,8 @@ import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.UnsupportedEncodingException; +import net.minecraft.block.Block; + public abstract class BptBase { BptSlot contents[][][]; @@ -57,7 +59,7 @@ public abstract class BptBase { anchorZ = 0; } - public void setBlockId(int x, int y, int z, int blockId) { + public void setBlock(int x, int y, int z, Block block) { if (contents[x][y][z] == null) { contents[x][y][z] = new BptSlot(); contents[x][y][z].x = x; @@ -65,7 +67,7 @@ public abstract class BptBase { contents[x][y][z].z = z; } - contents[x][y][z].blockId = blockId; + contents[x][y][z].block = block; } public void rotateLeft(BptContext context) { @@ -192,7 +194,7 @@ public abstract class BptBase { continue; } - if (contents[x][y][z].blockId != bpt.contents[x][y][z].blockId) + if (contents[x][y][z].block != bpt.contents[x][y][z].block) return false; } } diff --git a/common/buildcraft/core/blueprints/BptBlueprint.java b/common/buildcraft/core/blueprints/BptBlueprint.java index 16cb545c..45fa8aee 100644 --- a/common/buildcraft/core/blueprints/BptBlueprint.java +++ b/common/buildcraft/core/blueprints/BptBlueprint.java @@ -1,12 +1,11 @@ /** - * Copyright (c) SpaceToad, 2011-2012 + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.core.blueprints; import buildcraft.api.blueprints.BlockSignature; @@ -33,35 +32,35 @@ import net.minecraft.tileentity.TileEntity; public class BptBlueprint extends BptBase { - private int[] idMapping = new int[Item.itemsList.length]; + //private int[] idMapping = new int[Item.itemsList.length]; TreeSet idsToMap = new TreeSet(); public BptBlueprint() { - for (int i = 0; i < idMapping.length; ++i) { - idMapping[i] = i; - } + //for (int i = 0; i < idMapping.length; ++i) { + // idMapping[i] = i; + //} } public BptBlueprint(int sizeX, int sizeY, int sizeZ) { super(sizeX, sizeY, sizeZ); - for (int i = 0; i < idMapping.length; ++i) { - idMapping[i] = i; - } + //for (int i = 0; i < idMapping.length; ++i) { + // idMapping[i] = i; + //} } public void readFromWorld(IBptContext context, TileEntity anchorTile, int x, int y, int z) { - BptSlot slot = new BptSlot(); + /*BptSlot slot = new BptSlot(); slot.x = (int) (x - context.surroundingBox().pMin().x); slot.y = (int) (y - context.surroundingBox().pMin().y); slot.z = (int) (z - context.surroundingBox().pMin().z); - slot.blockId = anchorTile.worldObj.getBlockId(x, y, z); - slot.meta = anchorTile.worldObj.getBlockMetadata(x, y, z); + slot.blockId = anchorTile.getWorldObj().getBlockId(x, y, z); + slot.meta = anchorTile.getWorldObj().getBlockMetadata(x, y, z); if (Block.blocksList[slot.blockId] instanceof BlockContainer) { - TileEntity tile = anchorTile.worldObj.getBlockTileEntity(x, y, z); + TileEntity tile = anchorTile.getWorldObj().getTileEntity(x, y, z); if (tile != null && tile instanceof IBptContributor) { IBptContributor contributor = (IBptContributor) tile; @@ -78,12 +77,12 @@ public class BptBlueprint extends BptBase { t.printStackTrace(); BCLog.logger.throwing("BptBlueprint", "readFromWorld", t); - } + }*/ } @Override public void saveAttributes(BufferedWriter writer) throws IOException { - writer.write("sizeX:" + sizeX); + /*writer.write("sizeX:" + sizeX); writer.newLine(); writer.write("sizeY:" + sizeY); writer.newLine(); @@ -188,12 +187,12 @@ public class BptBlueprint extends BptBase { } writer.write(":requirements"); - writer.newLine(); + writer.newLine();*/ } @Override public void loadAttribute(BufferedReader reader, String attr, String val) throws IOException, BptError { - if ("3.1.0".equals(version)) + /*if ("3.1.0".equals(version)) throw new BptError("Blueprint format 3.1.0 is not supported anymore, can't load " + file); // blockMap is still tested for being able to load pre 3.1.2 bpts @@ -321,7 +320,7 @@ public class BptBlueprint extends BptBase { } } } - } + }*/ } @Override @@ -333,15 +332,17 @@ public class BptBlueprint extends BptBase { } public ItemStack mapItemStack(ItemStack bptItemStack) { - ItemStack newStack = bptItemStack.copy(); + //ItemStack newStack = bptItemStack.copy(); - newStack.itemID = idMapping[newStack.itemID]; + //newStack.itemID = idMapping[newStack.itemID]; - return newStack; + //return newStack; + return null; } public int mapWorldId(int bptWorldId) { - return idMapping[bptWorldId]; + //return idMapping[bptWorldId]; + return 0; } public void storeId(int worldId) { @@ -364,12 +365,12 @@ public class BptBlueprint extends BptBase { } @Override - public void setBlockId(int x, int y, int z, int blockId) { - super.setBlockId(x, y, z, blockId); + public void setBlock(int x, int y, int z, Block block) { + super.setBlock(x, y, z, block); } @Override protected void copyTo(BptBase bpt) { - ((BptBlueprint) bpt).idMapping = idMapping.clone(); + //((BptBlueprint) bpt).idMapping = idMapping.clone(); } } diff --git a/common/buildcraft/core/blueprints/BptBuilderBase.java b/common/buildcraft/core/blueprints/BptBuilderBase.java index b0662f13..7ac56eeb 100644 --- a/common/buildcraft/core/blueprints/BptBuilderBase.java +++ b/common/buildcraft/core/blueprints/BptBuilderBase.java @@ -1,12 +1,11 @@ /** - * Copyright (c) SpaceToad, 2011-2012 + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.core.blueprints; import buildcraft.api.core.IAreaProvider; diff --git a/common/buildcraft/core/blueprints/BptBuilderBlueprint.java b/common/buildcraft/core/blueprints/BptBuilderBlueprint.java index 7ba5c0e3..0a0a5516 100644 --- a/common/buildcraft/core/blueprints/BptBuilderBlueprint.java +++ b/common/buildcraft/core/blueprints/BptBuilderBlueprint.java @@ -1,28 +1,29 @@ /** - * Copyright (c) SpaceToad, 2011-2012 + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.core.blueprints; import buildcraft.core.IBuilderInventory; import buildcraft.core.blueprints.BptSlot.Mode; import buildcraft.core.utils.BCLog; import buildcraft.core.utils.BlockUtil; + import java.util.Comparator; import java.util.LinkedList; import java.util.ListIterator; import java.util.TreeMap; import java.util.TreeSet; + import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.world.EnumGameType; import net.minecraft.world.World; +import net.minecraft.world.WorldSettings.GameType; public class BptBuilderBlueprint extends BptBuilderBase { @@ -40,10 +41,10 @@ public class BptBuilderBlueprint extends BptBuilderBase { return -1; else if (o1.stackSize < o2.stackSize) return 1; - else if (o1.itemID > o2.itemID) - return -1; - else if (o1.itemID < o2.itemID) - return 1; + //else if (o1.itemID > o2.itemID) + // return -1; + //else if (o1.itemID < o2.itemID) + // return 1; else if (o1.getItemDamage() > o2.getItemDamage()) return -1; else if (o1.getItemDamage() < o2.getItemDamage()) @@ -70,7 +71,7 @@ public class BptBuilderBlueprint extends BptBuilderBase { } else { slot = new BptSlot(); slot.meta = 0; - slot.blockId = 0; + slot.block = null; } slot.x = xCoord; @@ -99,7 +100,7 @@ public class BptBuilderBlueprint extends BptBuilderBase { } else { slot = new BptSlot(); slot.meta = 0; - slot.blockId = 0; + slot.block = null; } slot.x = xCoord; @@ -108,13 +109,13 @@ public class BptBuilderBlueprint extends BptBuilderBase { slot.mode = Mode.Build; - if (slot.blockId != 0 && Block.blocksList[slot.blockId].isOpaqueCube()) { + if (slot.block != null && slot.block.isOpaqueCube()) { primaryList.add(slot); } else { secondaryList.add(slot); } - if (slot.blockId != 0) { + if (slot.block != null) { postProcessingList.add(slot.clone()); } } @@ -140,30 +141,33 @@ public class BptBuilderBlueprint extends BptBuilderBase { BptSlot slot = internalGetNextBlock(world, inv, clearList); checkDone(); - if (slot != null) + if (slot != null) { return slot; - else + } else { return null; + } } if (primaryList.size() != 0) { BptSlot slot = internalGetNextBlock(world, inv, primaryList); checkDone(); - if (slot != null) + if (slot != null) { return slot; - else + } else { return null; + } } if (secondaryList.size() != 0) { BptSlot slot = internalGetNextBlock(world, inv, secondaryList); checkDone(); - if (slot != null) + if (slot != null) { return slot; - else + } else { return null; + } } checkDone(); @@ -196,7 +200,7 @@ public class BptBuilderBlueprint extends BptBuilderBase { result = slot; break; } - } else if (world.getWorldInfo().getGameType() == EnumGameType.CREATIVE) { + } else if (world.getWorldInfo().getGameType() == GameType.CREATIVE) { // In creative, we don't use blocks given in the builder result = slot; @@ -209,7 +213,7 @@ public class BptBuilderBlueprint extends BptBuilderBase { break; } else { failSlots.add(slot); - } + } } list.addAll(failSlots); @@ -218,8 +222,9 @@ public class BptBuilderBlueprint extends BptBuilderBase { } public boolean checkRequirements(IBuilderInventory inv, BptSlot slot) { - if (slot.blockId == 0) + if (slot.block == null) { return true; + } LinkedList tmpReq = new LinkedList(); LinkedList tmpInv = new LinkedList(); @@ -246,7 +251,7 @@ public class BptBuilderBlueprint extends BptBuilderBase { } } - for (ItemStack reqStk : tmpReq) { + /*for (ItemStack reqStk : tmpReq) { for (ItemStack invStk : tmpInv) { if (invStk != null && reqStk.itemID == invStk.itemID && invStk.stackSize > 0) { @@ -271,14 +276,15 @@ public class BptBuilderBlueprint extends BptBuilderBase { if (reqStk.stackSize != 0) return false; - } + }*/ return true; } public void useRequirements(IBuilderInventory inv, BptSlot slot) { - if (slot.blockId == 0) + if (slot.block == null) { return; + } LinkedList tmpReq = new LinkedList(); @@ -308,7 +314,7 @@ public class BptBuilderBlueprint extends BptBuilderBase { ItemStack invStk = inv.getStackInSlot(i); - if (invStk != null && reqStk.itemID == invStk.itemID && invStk.stackSize > 0) { + /*if (invStk != null && reqStk.itemID == invStk.itemID && invStk.stackSize > 0) { if (!invStk.isItemStackDamageable() && (reqStk.getItemDamage() != invStk.getItemDamage())) { continue; @@ -331,7 +337,7 @@ public class BptBuilderBlueprint extends BptBuilderBase { if (reqStk.stackSize == 0) { break; } - } + }*/ } if (reqStk.stackSize != 0) @@ -347,7 +353,7 @@ public class BptBuilderBlueprint extends BptBuilderBase { public void recomputeNeededItems() { neededItems.clear(); - TreeMap computeStacks = new TreeMap(new Comparator() { + /*TreeMap computeStacks = new TreeMap(new Comparator() { @Override public int compare(ItemStack o1, ItemStack o2) { @@ -362,7 +368,7 @@ public class BptBuilderBlueprint extends BptBuilderBase { return 0; } - }); + });*/ for (BptSlot slot : primaryList) { @@ -376,7 +382,7 @@ public class BptBuilderBlueprint extends BptBuilderBase { BCLog.logger.throwing("BptBuilderBlueprint", "recomputeIfNeeded", t); } - for (ItemStack stack : stacks) { + /*for (ItemStack stack : stacks) { if (stack == null || stack.itemID == 0) { continue; } @@ -390,13 +396,13 @@ public class BptBuilderBlueprint extends BptBuilderBase { computeStacks.put(stack, num); } - } + }*/ } for (BptSlot slot : secondaryList) { LinkedList stacks = slot.getRequirements(context); - for (ItemStack stack : stacks) { + /*for (ItemStack stack : stacks) { if (stack == null || stack.itemID <= 0 || stack.itemID >= Item.itemsList.length || stack.stackSize == 0 || stack.getItem() == null) { continue; } @@ -410,15 +416,16 @@ public class BptBuilderBlueprint extends BptBuilderBase { computeStacks.put(stack, num); } - } + }*/ } - for (ItemStack stack : computeStacks.keySet()) + /*for (ItemStack stack : computeStacks.keySet()) if (stack.isItemStackDamageable()) { neededItems.add(new ItemStack(stack.getItem())); } else { neededItems.add(new ItemStack(stack.itemID, computeStacks.get(stack), stack.getItemDamage())); } + */ } @Override diff --git a/common/buildcraft/core/blueprints/BptBuilderTemplate.java b/common/buildcraft/core/blueprints/BptBuilderTemplate.java index c1ba8cde..25cbfaa7 100644 --- a/common/buildcraft/core/blueprints/BptBuilderTemplate.java +++ b/common/buildcraft/core/blueprints/BptBuilderTemplate.java @@ -1,12 +1,11 @@ /** - * Copyright (c) SpaceToad, 2011-2012 + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.core.blueprints; import buildcraft.core.IBuilderInventory; @@ -32,10 +31,10 @@ public class BptBuilderTemplate extends BptBuilderBase { BptSlot slot = bluePrint.contents[i][j][k]; - if (slot == null || slot.blockId == 0) { + if (slot == null || slot.block == null) { slot = new BptSlot(); slot.meta = 0; - slot.blockId = 0; + slot.block = null; slot.x = xCoord; slot.y = yCoord; slot.z = zCoord; @@ -62,7 +61,7 @@ public class BptBuilderTemplate extends BptBuilderBase { } else { slot = new BptSlot(); slot.meta = 0; - slot.blockId = 0; + slot.block = null; } slot.x = xCoord; @@ -71,7 +70,7 @@ public class BptBuilderTemplate extends BptBuilderBase { slot.mode = Mode.Build; - if (slot.blockId != 0) { + if (slot.block != null) { buildList.add(slot); } } @@ -121,7 +120,7 @@ public class BptBuilderTemplate extends BptBuilderBase { BptSlot slot = list.getFirst(); // Note from CJ: I have no idea what this code is supposed to do, so I'm not touching it. - if (slot.blockId == world.getBlockId(slot.x, slot.y, slot.z)) { + /*if (slot.blockId == world.getBlockId(slot.x, slot.y, slot.z)) { list.removeFirst(); } else if (slot.mode == Mode.ClearIfInvalid) { result = slot; @@ -145,7 +144,7 @@ public class BptBuilderTemplate extends BptBuilderBase { } break; - } + }*/ } return result; diff --git a/common/buildcraft/core/blueprints/BptContext.java b/common/buildcraft/core/blueprints/BptContext.java index ff74dfdd..e1408c4c 100644 --- a/common/buildcraft/core/blueprints/BptContext.java +++ b/common/buildcraft/core/blueprints/BptContext.java @@ -1,12 +1,11 @@ /** - * Copyright (c) SpaceToad, 2011 + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.core.blueprints; import buildcraft.api.blueprints.IBptContext; diff --git a/common/buildcraft/core/blueprints/BptDataStream.java b/common/buildcraft/core/blueprints/BptDataStream.java index 05046def..6ab431a7 100644 --- a/common/buildcraft/core/blueprints/BptDataStream.java +++ b/common/buildcraft/core/blueprints/BptDataStream.java @@ -1,12 +1,11 @@ /** - * Copyright (c) SpaceToad, 2011-2012 + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.core.blueprints; import java.io.DataInput; diff --git a/common/buildcraft/core/blueprints/BptError.java b/common/buildcraft/core/blueprints/BptError.java index 7a4fa0a5..7d187f15 100644 --- a/common/buildcraft/core/blueprints/BptError.java +++ b/common/buildcraft/core/blueprints/BptError.java @@ -1,12 +1,11 @@ /** - * Copyright (c) SpaceToad, 2011-2012 + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.core.blueprints; import buildcraft.core.utils.BCLog; diff --git a/common/buildcraft/core/blueprints/BptItem.java b/common/buildcraft/core/blueprints/BptItem.java index 59329dc9..64215151 100644 --- a/common/buildcraft/core/blueprints/BptItem.java +++ b/common/buildcraft/core/blueprints/BptItem.java @@ -1,12 +1,11 @@ /** - * Copyright (c) SpaceToad, 2011-2012 + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.core.blueprints; import buildcraft.api.blueprints.BptSlotInfo; diff --git a/common/buildcraft/core/blueprints/BptPlayerIndex.java b/common/buildcraft/core/blueprints/BptPlayerIndex.java index 4dc666a2..da191fa4 100644 --- a/common/buildcraft/core/blueprints/BptPlayerIndex.java +++ b/common/buildcraft/core/blueprints/BptPlayerIndex.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.blueprints; import buildcraft.core.proxy.CoreProxy; diff --git a/common/buildcraft/core/blueprints/BptRootIndex.java b/common/buildcraft/core/blueprints/BptRootIndex.java index 926082c3..1a46ff74 100644 --- a/common/buildcraft/core/blueprints/BptRootIndex.java +++ b/common/buildcraft/core/blueprints/BptRootIndex.java @@ -1,12 +1,11 @@ /** - * Copyright (c) SpaceToad, 2011 + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.core.blueprints; import buildcraft.core.proxy.CoreProxy; diff --git a/common/buildcraft/core/blueprints/BptSlot.java b/common/buildcraft/core/blueprints/BptSlot.java index f34f1a8a..48508989 100644 --- a/common/buildcraft/core/blueprints/BptSlot.java +++ b/common/buildcraft/core/blueprints/BptSlot.java @@ -1,9 +1,20 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.blueprints; import buildcraft.api.blueprints.BlueprintManager; import buildcraft.api.blueprints.BptSlotInfo; import buildcraft.api.blueprints.IBptContext; + import java.util.LinkedList; + +import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -17,40 +28,53 @@ public class BptSlot extends BptSlotInfo { public ItemStack stackToUse; public boolean isValid(IBptContext context) { - return BlueprintManager.blockBptProps[blockId].isValid(this, context); + // the following line is just to resurect quarry building + if (block == null && context.world().getBlock(x, y, z) == Blocks.air) { + return true; + } else { + return block == context.world().getBlock(x, y, z); + } + + //return BlueprintManager.blockBptProps[blockId].isValid(this, context); } public void rotateLeft(IBptContext context) { - BlueprintManager.blockBptProps[blockId].rotateLeft(this, context); + //BlueprintManager.blockBptProps[blockId].rotateLeft(this, context); } public boolean ignoreBuilding() { - return BlueprintManager.blockBptProps[blockId].ignoreBuilding(this); + //return BlueprintManager.blockBptProps[blockId].ignoreBuilding(this); + return false; } public void initializeFromWorld(IBptContext context, int xs, int ys, int zs) { - BlueprintManager.blockBptProps[blockId].initializeFromWorld(this, context, xs, ys, zs); + //BlueprintManager.blockBptProps[blockId].initializeFromWorld(this, context, xs, ys, zs); } public void postProcessing(IBptContext context) { - BlueprintManager.blockBptProps[blockId].postProcessing(this, context); + //BlueprintManager.blockBptProps[blockId].postProcessing(this, context); } public LinkedList getRequirements(IBptContext context) { LinkedList res = new LinkedList(); - BlueprintManager.blockBptProps[blockId].addRequirements(this, context, res); + //BlueprintManager.blockBptProps[blockId].addRequirements(this, context, res); return res; } public final void buildBlock(IBptContext context) { - BlueprintManager.blockBptProps[blockId].buildBlock(this, context); + // the following line is just to resurect quarry building + context.world().setBlock (x, y, z, block); + context.world().setBlockMetadataWithNotify(x, y, z, meta, 0); + + //BlueprintManager.blockBptProps[blockId].buildBlock(this, context); } // returns what was used public ItemStack useItem(IBptContext context, ItemStack req, ItemStack stack) { - return BlueprintManager.blockBptProps[blockId].useItem(this, context, req, stack); + //return BlueprintManager.blockBptProps[blockId].useItem(this, context, req, stack); + return null; } @SuppressWarnings("unchecked") @@ -61,7 +85,7 @@ public class BptSlot extends BptSlotInfo { obj.x = x; obj.y = y; obj.z = z; - obj.blockId = blockId; + obj.block = block; obj.meta = meta; obj.cpt = (NBTTagCompound) cpt.copy(); obj.storedRequirements = (LinkedList) storedRequirements.clone(); diff --git a/common/buildcraft/core/blueprints/BptTemplate.java b/common/buildcraft/core/blueprints/BptTemplate.java index c4b54ee8..5ed4e6b2 100644 --- a/common/buildcraft/core/blueprints/BptTemplate.java +++ b/common/buildcraft/core/blueprints/BptTemplate.java @@ -1,12 +1,11 @@ /** - * Copyright (c) SpaceToad, 2011-2012 + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.core.blueprints; import java.io.BufferedReader; @@ -28,7 +27,7 @@ public class BptTemplate extends BptBase { boolean first = true; - for (int x = 0; x < sizeX; ++x) { + /*for (int x = 0; x < sizeX; ++x) { for (int y = 0; y < sizeY; ++y) { for (int z = 0; z < sizeZ; ++z) { if (first) { @@ -40,7 +39,7 @@ public class BptTemplate extends BptBase { writer.write(contents[x][y][z].blockId + ""); } } - } + }*/ } @Override @@ -51,7 +50,7 @@ public class BptTemplate extends BptBase { String[] mask = val.split(","); int maskIndex = 0; - for (int x = 0; x < sizeX; ++x) { + /*for (int x = 0; x < sizeX; ++x) { for (int y = 0; y < sizeY; ++y) { for (int z = 0; z < sizeZ; ++z) { contents[x][y][z] = new BptSlot(); @@ -63,7 +62,7 @@ public class BptTemplate extends BptBase { maskIndex++; } } - } + }*/ } } diff --git a/common/buildcraft/core/fluids/BCFluid.java b/common/buildcraft/core/fluids/BCFluid.java index 8df7bbd8..4d3983ec 100644 --- a/common/buildcraft/core/fluids/BCFluid.java +++ b/common/buildcraft/core/fluids/BCFluid.java @@ -1,7 +1,7 @@ -/* - * Copyright (c) SpaceToad, 2011-2012 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * + * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt @@ -11,10 +11,6 @@ package buildcraft.core.fluids; import buildcraft.core.utils.StringUtils; import net.minecraftforge.fluids.Fluid; -/** - * - * @author CovertJaguar - */ public class BCFluid extends Fluid { public BCFluid(String name) { diff --git a/common/buildcraft/core/fluids/FluidUtils.java b/common/buildcraft/core/fluids/FluidUtils.java index 6f600b54..1081f3d2 100644 --- a/common/buildcraft/core/fluids/FluidUtils.java +++ b/common/buildcraft/core/fluids/FluidUtils.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.fluids; import buildcraft.core.TileBuffer; @@ -5,9 +13,10 @@ import buildcraft.core.inventory.InvUtils; import buildcraft.core.utils.Utils; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidRegistry; @@ -15,10 +24,6 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidHandler; import net.minecraftforge.fluids.IFluidTank; -/** - * - * @author CovertJaguar - */ public class FluidUtils { public static boolean handleRightClick(IFluidHandler tank, ForgeDirection side, EntityPlayer player, boolean fill, boolean drain) { @@ -36,7 +41,7 @@ public class FluidUtils { if (used > 0) { if (!player.capabilities.isCreativeMode) { player.inventory.setInventorySlotContents(player.inventory.currentItem, InvUtils.consumeItem(current)); - player.inventory.onInventoryChanged(); + player.inventory.markDirty(); } return true; } @@ -54,11 +59,11 @@ public class FluidUtils { if (!player.inventory.addItemStackToInventory(filled)) return false; player.inventory.setInventorySlotContents(player.inventory.currentItem, InvUtils.consumeItem(current)); - player.inventory.onInventoryChanged(); + player.inventory.markDirty(); } else { player.inventory.setInventorySlotContents(player.inventory.currentItem, InvUtils.consumeItem(current)); player.inventory.setInventorySlotContents(player.inventory.currentItem, filled); - player.inventory.onInventoryChanged(); + player.inventory.markDirty(); } tank.drain(side, liquid.amount, true); @@ -70,12 +75,12 @@ public class FluidUtils { return false; } - public static int getFluidBlockId(Fluid fluid, boolean moving) { + public static Block getFluidBlock(Fluid fluid, boolean moving) { if (fluid == FluidRegistry.WATER) - return moving ? Block.waterMoving.blockID : Block.waterStill.blockID; + return moving ? Blocks.flowing_water : Blocks.water; if (fluid == FluidRegistry.LAVA) - return moving ? Block.lavaMoving.blockID : Block.lavaStill.blockID; - return fluid.getBlockID(); + return moving ? Blocks.flowing_lava : Blocks.lava; + return fluid.getBlock(); } public static void pushFluidToConsumers(IFluidTank tank, int flowCap, TileBuffer[] tileBuffer) { diff --git a/common/buildcraft/core/fluids/RestrictedTank.java b/common/buildcraft/core/fluids/RestrictedTank.java index 40f92e11..8980f76c 100644 --- a/common/buildcraft/core/fluids/RestrictedTank.java +++ b/common/buildcraft/core/fluids/RestrictedTank.java @@ -1,7 +1,7 @@ -/* - * Copyright (c) SpaceToad, 2011-2012 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * + * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt @@ -12,10 +12,6 @@ import net.minecraft.tileentity.TileEntity; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; -/** - * - * @author CovertJaguar - */ public class RestrictedTank extends Tank { private final Fluid[] acceptedFluids; diff --git a/common/buildcraft/core/fluids/SingleUseTank.java b/common/buildcraft/core/fluids/SingleUseTank.java index 2b18ba63..4c4a3339 100644 --- a/common/buildcraft/core/fluids/SingleUseTank.java +++ b/common/buildcraft/core/fluids/SingleUseTank.java @@ -1,7 +1,7 @@ -/* - * Copyright (c) SpaceToad, 2011-2012 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * + * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt @@ -14,10 +14,6 @@ import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; -/** - * - * @author CovertJaguar - */ public class SingleUseTank extends Tank { private Fluid acceptedFluid; diff --git a/common/buildcraft/core/fluids/Tank.java b/common/buildcraft/core/fluids/Tank.java index e13e5014..bee7a45a 100644 --- a/common/buildcraft/core/fluids/Tank.java +++ b/common/buildcraft/core/fluids/Tank.java @@ -1,7 +1,7 @@ -/* - * Copyright (c) SpaceToad, 2011-2012 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * + * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt @@ -16,10 +16,6 @@ import net.minecraft.tileentity.TileEntity; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidTank; -/** - * - * @author CovertJaguar - */ public class Tank extends FluidTank { private final String name; @@ -48,7 +44,7 @@ public class Tank extends FluidTank { NBTTagCompound tankData = new NBTTagCompound(); super.writeToNBT(tankData); writeTankToNBT(tankData); - nbt.setCompoundTag(name, tankData); + nbt.setTag(name, tankData); return nbt; } diff --git a/common/buildcraft/core/fluids/TankManager.java b/common/buildcraft/core/fluids/TankManager.java index 39d4abbf..e18e4165 100644 --- a/common/buildcraft/core/fluids/TankManager.java +++ b/common/buildcraft/core/fluids/TankManager.java @@ -1,7 +1,7 @@ -/* - * Copyright (c) SpaceToad, 2011-2012 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * + * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt @@ -9,25 +9,25 @@ package buildcraft.core.fluids; import com.google.common.collect.ForwardingList; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import io.netty.buffer.ByteBuf; + import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; + import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidHandler; -/** - * - * @author CovertJaguar - */ public class TankManager extends ForwardingList implements IFluidHandler, List { private List tanks = new ArrayList(); @@ -109,7 +109,7 @@ public class TankManager extends ForwardingList implements IF } } - public void writeData(DataOutputStream data) throws IOException { + public void writeData(ByteBuf data) { for (Tank tank : tanks) { FluidStack fluidStack = tank.getFluid(); if (fluidStack != null && fluidStack.getFluid() != null) { @@ -123,7 +123,7 @@ public class TankManager extends ForwardingList implements IF } @SideOnly(Side.CLIENT) - public void readData(DataInputStream data) throws IOException { + public void readData(ByteBuf data) { for (Tank tank : tanks) { int fluidId = data.readShort(); if (fluidId > 0) { diff --git a/common/buildcraft/core/gui/AdvancedSlot.java b/common/buildcraft/core/gui/AdvancedSlot.java index 159822cf..b0cf9fe8 100755 --- a/common/buildcraft/core/gui/AdvancedSlot.java +++ b/common/buildcraft/core/gui/AdvancedSlot.java @@ -3,7 +3,7 @@ package buildcraft.core.gui; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.item.ItemStack; -import net.minecraft.util.Icon; +import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; public abstract class AdvancedSlot { @@ -19,12 +19,12 @@ public abstract class AdvancedSlot { public String getDescription() { if (getItemStack() != null) - return getItemStack().getItem().getItemDisplayName(getItemStack()); + return getItemStack().getItem().getItemStackDisplayName(getItemStack()); else return ""; } - public Icon getIcon() { + public IIcon getIcon() { return null; } diff --git a/common/buildcraft/core/gui/BuildCraftContainer.java b/common/buildcraft/core/gui/BuildCraftContainer.java index 838486a4..35ed0416 100644 --- a/common/buildcraft/core/gui/BuildCraftContainer.java +++ b/common/buildcraft/core/gui/BuildCraftContainer.java @@ -1,23 +1,29 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.core.gui; +import buildcraft.BuildCraftCore; import buildcraft.core.gui.slots.IPhantomSlot; import buildcraft.core.gui.slots.SlotBase; import buildcraft.core.gui.widgets.Widget; import buildcraft.core.inventory.StackHelper; import buildcraft.core.network.PacketGuiWidget; -import cpw.mods.fml.common.network.PacketDispatcher; -import cpw.mods.fml.common.network.Player; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.ByteBufInputStream; + import java.io.DataInputStream; import java.io.IOException; +import java.io.InputStream; import java.util.ArrayList; import java.util.List; + +import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; @@ -49,11 +55,18 @@ public abstract class BuildCraftContainer extends Container { public void sendWidgetDataToClient(Widget widget, ICrafting player, byte[] data) { PacketGuiWidget pkt = new PacketGuiWidget(windowId, widgets.indexOf(widget), data); - PacketDispatcher.sendPacketToPlayer(pkt.getPacket(), (Player) player); + BuildCraftCore.instance.sendToPlayer((EntityPlayer) player, pkt); } - public void handleWidgetClientData(int widgetId, DataInputStream data) throws IOException { - widgets.get(widgetId).handleClientPacketData(data); + public void handleWidgetClientData(int widgetId, ByteBuf data) { + InputStream input = new ByteBufInputStream (data); + DataInputStream stream = new DataInputStream(input); + + try { + widgets.get(widgetId).handleClientPacketData(stream); + } catch (IOException e) { + e.printStackTrace(); + } } @Override diff --git a/common/buildcraft/core/gui/GuiAdvancedInterface.java b/common/buildcraft/core/gui/GuiAdvancedInterface.java index 16854d55..24986cdc 100644 --- a/common/buildcraft/core/gui/GuiAdvancedInterface.java +++ b/common/buildcraft/core/gui/GuiAdvancedInterface.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.gui; import net.minecraft.client.renderer.OpenGlHelper; @@ -5,17 +13,16 @@ import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.entity.RenderItem; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; -import net.minecraft.util.Icon; +import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fluids.Fluid; import org.lwjgl.opengl.GL11; -import buildcraft.core.render.RenderUtils; import buildcraft.core.render.FluidRenderer; +import buildcraft.core.render.RenderUtils; public abstract class GuiAdvancedInterface extends GuiBuildCraft { - public class ItemSlot extends AdvancedSlot { public ItemStack stack; @@ -135,7 +142,7 @@ public abstract class GuiAdvancedInterface extends GuiBuildCraft { } @Override - public Icon getIcon() { + public IIcon getIcon() { return FluidRenderer.getFluidTexture(fluid, false); } @@ -146,7 +153,7 @@ public abstract class GuiAdvancedInterface extends GuiBuildCraft { } public static RenderItem getItemRenderer () { - return itemRenderer; + return itemRender; } public int getXSize () { diff --git a/common/buildcraft/core/gui/GuiBuildCraft.java b/common/buildcraft/core/gui/GuiBuildCraft.java index 0cc2d27b..f0b7290c 100644 --- a/common/buildcraft/core/gui/GuiBuildCraft.java +++ b/common/buildcraft/core/gui/GuiBuildCraft.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.gui; import buildcraft.core.DefaultProps; @@ -18,7 +26,7 @@ import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Icon; +import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; @@ -46,7 +54,7 @@ public abstract class GuiBuildCraft extends GuiContainer { } public FontRenderer getFontRenderer() { - return fontRenderer; + return fontRendererObj; } protected void initLedgers(IInventory inventory) { @@ -129,7 +137,7 @@ public abstract class GuiBuildCraft extends GuiContainer { } protected int getCenteredOffset(String string, int xWidth) { - return (xWidth - fontRenderer.getStringWidth(string)) / 2; + return (xWidth - fontRendererObj.getStringWidth(string)) / 2; } /** @@ -214,7 +222,7 @@ public abstract class GuiBuildCraft extends GuiContainer { int y; for (ToolTipLine tip : toolTips) { - y = this.fontRenderer.getStringWidth(tip.text); + y = this.fontRendererObj.getStringWidth(tip.text); if (y > lenght) { lenght = y; @@ -230,7 +238,7 @@ public abstract class GuiBuildCraft extends GuiContainer { } this.zLevel = 300.0F; - itemRenderer.zLevel = 300.0F; + itemRender.zLevel = 300.0F; int var15 = -267386864; this.drawGradientRect(x - 3, y - 4, x + lenght + 3, y - 3, var15, var15); this.drawGradientRect(x - 3, y + var14 + 3, x + lenght + 3, y + var14 + 4, var15, var15); @@ -253,13 +261,13 @@ public abstract class GuiBuildCraft extends GuiContainer { line = "\u00a7" + Integer.toHexString(tip.color) + line; } - this.fontRenderer.drawStringWithShadow(line, x, y, -1); + this.fontRendererObj.drawStringWithShadow(line, x, y, -1); y += 10 + tip.getSpacing(); } this.zLevel = 0.0F; - itemRenderer.zLevel = 0.0F; + itemRender.zLevel = 0.0F; } } @@ -331,9 +339,9 @@ public abstract class GuiBuildCraft extends GuiContainer { int startY = mouseY - ((gui.height - gui.ySize) / 2) - 12; String tooltip = ledger.getTooltip(); - int textWidth = fontRenderer.getStringWidth(tooltip); + int textWidth = fontRendererObj.getStringWidth(tooltip); drawGradientRect(startX - 3, startY - 3, startX + textWidth + 3, startY + 8 + 3, 0xc0000000, 0xc0000000); - fontRenderer.drawStringWithShadow(tooltip, startX, startY, -1); + fontRendererObj.drawStringWithShadow(tooltip, startX, startY, -1); } } @@ -456,7 +464,7 @@ public abstract class GuiBuildCraft extends GuiContainer { GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0F); } - protected void drawIcon(Icon icon, int x, int y) { + protected void drawIcon(IIcon icon, int x, int y) { GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0F); drawTexturedModelRectFromIcon(x, y, icon, 16, 16); diff --git a/common/buildcraft/core/gui/GuiTools.java b/common/buildcraft/core/gui/GuiTools.java index 570000d8..36e543ee 100644 --- a/common/buildcraft/core/gui/GuiTools.java +++ b/common/buildcraft/core/gui/GuiTools.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.gui; import buildcraft.core.gui.buttons.GuiBetterButton; diff --git a/common/buildcraft/core/gui/buttons/ButtonTextureSet.java b/common/buildcraft/core/gui/buttons/ButtonTextureSet.java index 65aad053..82a5c9d6 100644 --- a/common/buildcraft/core/gui/buttons/ButtonTextureSet.java +++ b/common/buildcraft/core/gui/buttons/ButtonTextureSet.java @@ -1,9 +1,13 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.gui.buttons; -/** - * - * @author CovertJaguar - */ public class ButtonTextureSet implements IButtonTextureSet { private final int x, y, height, width; diff --git a/common/buildcraft/core/gui/buttons/GuiBetterButton.java b/common/buildcraft/core/gui/buttons/GuiBetterButton.java index 790243db..d32838b4 100644 --- a/common/buildcraft/core/gui/buttons/GuiBetterButton.java +++ b/common/buildcraft/core/gui/buttons/GuiBetterButton.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.gui.buttons; import buildcraft.core.DefaultProps; @@ -11,10 +19,6 @@ import net.minecraft.client.gui.GuiButton; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; -/** - * - * @author CovertJaguar - */ @SideOnly(Side.CLIENT) public class GuiBetterButton extends GuiButton implements IToolTipProvider { @@ -63,9 +67,10 @@ public class GuiBetterButton extends GuiButton implements IToolTipProvider { @Override public void drawButton(Minecraft minecraft, int mouseX, int mouseY) { - if (!drawButton) { + if (!visible) { return; } + FontRenderer fontrenderer = minecraft.fontRenderer; bindButtonTextures(minecraft); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); @@ -92,7 +97,7 @@ public class GuiBetterButton extends GuiButton implements IToolTipProvider { @Override public boolean isToolTipVisible() { - return drawButton; + return visible; } @Override diff --git a/common/buildcraft/core/gui/buttons/GuiButtonSmall.java b/common/buildcraft/core/gui/buttons/GuiButtonSmall.java index abeb26cf..a54c0b6a 100644 --- a/common/buildcraft/core/gui/buttons/GuiButtonSmall.java +++ b/common/buildcraft/core/gui/buttons/GuiButtonSmall.java @@ -1,12 +1,16 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.gui.buttons; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -/** - * - * @author CovertJaguar - */ @SideOnly(Side.CLIENT) public class GuiButtonSmall extends GuiBetterButton { diff --git a/common/buildcraft/core/gui/buttons/GuiMultiButton.java b/common/buildcraft/core/gui/buttons/GuiMultiButton.java index 3bc4ea36..12e029eb 100644 --- a/common/buildcraft/core/gui/buttons/GuiMultiButton.java +++ b/common/buildcraft/core/gui/buttons/GuiMultiButton.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.gui.buttons; import net.minecraft.client.Minecraft; @@ -9,10 +17,6 @@ import buildcraft.core.gui.tooltips.ToolTip; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -/** - * - * @author CovertJaguar - */ @SideOnly(Side.CLIENT) public class GuiMultiButton extends GuiBetterButton { @@ -30,9 +34,10 @@ public class GuiMultiButton extends GuiBetterButton { @Override public void drawButton(Minecraft minecraft, int x, int y) { - if (!drawButton) { + if (!visible) { return; } + FontRenderer fontrenderer = minecraft.fontRenderer; bindButtonTextures(minecraft); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); diff --git a/common/buildcraft/core/gui/buttons/GuiToggleButton.java b/common/buildcraft/core/gui/buttons/GuiToggleButton.java index 5ac298c3..c155ed8b 100644 --- a/common/buildcraft/core/gui/buttons/GuiToggleButton.java +++ b/common/buildcraft/core/gui/buttons/GuiToggleButton.java @@ -1,9 +1,13 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.gui.buttons; -/** - * - * @author CovertJaguar - */ public class GuiToggleButton extends GuiBetterButton { public boolean active; diff --git a/common/buildcraft/core/gui/buttons/GuiToggleButtonSmall.java b/common/buildcraft/core/gui/buttons/GuiToggleButtonSmall.java index 38f2b220..4ffe0111 100644 --- a/common/buildcraft/core/gui/buttons/GuiToggleButtonSmall.java +++ b/common/buildcraft/core/gui/buttons/GuiToggleButtonSmall.java @@ -1,12 +1,16 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.gui.buttons; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -/** - * - * @author CovertJaguar - */ @SideOnly(Side.CLIENT) public class GuiToggleButtonSmall extends GuiToggleButton { diff --git a/common/buildcraft/core/gui/buttons/IButtonTextureSet.java b/common/buildcraft/core/gui/buttons/IButtonTextureSet.java index 6fbb4e76..2e9b23bf 100644 --- a/common/buildcraft/core/gui/buttons/IButtonTextureSet.java +++ b/common/buildcraft/core/gui/buttons/IButtonTextureSet.java @@ -1,9 +1,13 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.gui.buttons; -/** - * - * @author CovertJaguar - */ public interface IButtonTextureSet { public int getX(); diff --git a/common/buildcraft/core/gui/buttons/IMultiButtonState.java b/common/buildcraft/core/gui/buttons/IMultiButtonState.java index 33deca20..36b2f123 100644 --- a/common/buildcraft/core/gui/buttons/IMultiButtonState.java +++ b/common/buildcraft/core/gui/buttons/IMultiButtonState.java @@ -1,11 +1,15 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.gui.buttons; import buildcraft.core.gui.tooltips.ToolTip; -/** - * - * @author CovertJaguar - */ public interface IMultiButtonState { public String getLabel(); diff --git a/common/buildcraft/core/gui/buttons/LockButtonState.java b/common/buildcraft/core/gui/buttons/LockButtonState.java index db86bed9..7b6a6f48 100644 --- a/common/buildcraft/core/gui/buttons/LockButtonState.java +++ b/common/buildcraft/core/gui/buttons/LockButtonState.java @@ -1,11 +1,15 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.gui.buttons; import buildcraft.core.gui.tooltips.ToolTip; -/** - * - * @author CovertJaguar - */ public enum LockButtonState implements IMultiButtonState { UNLOCKED(new ButtonTextureSet(224, 0, 16, 16)), LOCKED(new ButtonTextureSet(240, 0, 16, 16)); diff --git a/common/buildcraft/core/gui/buttons/MultiButtonController.java b/common/buildcraft/core/gui/buttons/MultiButtonController.java index 0de811aa..1f087b4d 100644 --- a/common/buildcraft/core/gui/buttons/MultiButtonController.java +++ b/common/buildcraft/core/gui/buttons/MultiButtonController.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.gui.buttons; import net.minecraft.nbt.NBTTagByte; @@ -6,8 +14,6 @@ import net.minecraft.nbt.NBTTagString; /** * T should be an Enum of button states - * - * @author CovertJaguar */ public class MultiButtonController { diff --git a/common/buildcraft/core/gui/buttons/StandardButtonTextureSets.java b/common/buildcraft/core/gui/buttons/StandardButtonTextureSets.java index 5155cd29..4654d4db 100644 --- a/common/buildcraft/core/gui/buttons/StandardButtonTextureSets.java +++ b/common/buildcraft/core/gui/buttons/StandardButtonTextureSets.java @@ -1,9 +1,13 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.gui.buttons; -/** - * - * @author CovertJaguar - */ public enum StandardButtonTextureSets implements IButtonTextureSet { LARGE_BUTTON(0, 0, 20, 200), diff --git a/common/buildcraft/core/gui/slots/IPhantomSlot.java b/common/buildcraft/core/gui/slots/IPhantomSlot.java index 20be7af3..16184cf9 100644 --- a/common/buildcraft/core/gui/slots/IPhantomSlot.java +++ b/common/buildcraft/core/gui/slots/IPhantomSlot.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.gui.slots; /* diff --git a/common/buildcraft/core/gui/slots/SlotBase.java b/common/buildcraft/core/gui/slots/SlotBase.java index 63cedc8c..f94aa385 100644 --- a/common/buildcraft/core/gui/slots/SlotBase.java +++ b/common/buildcraft/core/gui/slots/SlotBase.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.core.gui.slots; @@ -12,10 +13,6 @@ import buildcraft.core.gui.tooltips.ToolTip; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; -/** - * - * @author CovertJaguar - */ public class SlotBase extends Slot implements IToolTipProvider { private ToolTip toolTips; diff --git a/common/buildcraft/core/gui/slots/SlotLimited.java b/common/buildcraft/core/gui/slots/SlotLimited.java index ef07a1f8..57feedd9 100644 --- a/common/buildcraft/core/gui/slots/SlotLimited.java +++ b/common/buildcraft/core/gui/slots/SlotLimited.java @@ -1,11 +1,15 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.gui.slots; import net.minecraft.inventory.IInventory; -/** - * - * @author CovertJaguar - */ public class SlotLimited extends SlotBase { private final int limit; diff --git a/common/buildcraft/core/gui/slots/SlotOutput.java b/common/buildcraft/core/gui/slots/SlotOutput.java index 590c82b7..ede106b0 100644 --- a/common/buildcraft/core/gui/slots/SlotOutput.java +++ b/common/buildcraft/core/gui/slots/SlotOutput.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.gui.slots; import net.minecraft.inventory.IInventory; diff --git a/common/buildcraft/core/gui/slots/SlotPhantom.java b/common/buildcraft/core/gui/slots/SlotPhantom.java index 7b88df2d..6341e023 100644 --- a/common/buildcraft/core/gui/slots/SlotPhantom.java +++ b/common/buildcraft/core/gui/slots/SlotPhantom.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.core.gui.slots; @@ -10,10 +11,6 @@ package buildcraft.core.gui.slots; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; -/** - * - * @author CovertJaguar - */ public class SlotPhantom extends SlotBase implements IPhantomSlot { public SlotPhantom(IInventory iinventory, int slotIndex, int posX, int posY) { diff --git a/common/buildcraft/core/gui/slots/SlotUntouchable.java b/common/buildcraft/core/gui/slots/SlotUntouchable.java index e5a015d9..97983506 100644 --- a/common/buildcraft/core/gui/slots/SlotUntouchable.java +++ b/common/buildcraft/core/gui/slots/SlotUntouchable.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.core.gui.slots; @@ -11,10 +12,6 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; -/** - * - * @author CovertJaguar - */ public class SlotUntouchable extends SlotBase implements IPhantomSlot { public SlotUntouchable(IInventory contents, int id, int x, int y) { diff --git a/common/buildcraft/core/gui/slots/SlotValidated.java b/common/buildcraft/core/gui/slots/SlotValidated.java index b3e1a89f..26224485 100644 --- a/common/buildcraft/core/gui/slots/SlotValidated.java +++ b/common/buildcraft/core/gui/slots/SlotValidated.java @@ -1,10 +1,10 @@ -/* - * Copyright (c) CovertJaguar, 2011 http://railcraft.info +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * This code is the property of CovertJaguar - * and may only be used with explicit written - * permission unless otherwise specified on the - * license page at railcraft.wikispaces.com. + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.core.gui.slots; @@ -12,10 +12,6 @@ import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -/** - * - * @author SandGrainOne - */ public class SlotValidated extends Slot { public SlotValidated(IInventory inv, int id, int x, int y) { diff --git a/common/buildcraft/core/gui/slots/SlotWorkbench.java b/common/buildcraft/core/gui/slots/SlotWorkbench.java index 5185e732..c3280a1e 100644 --- a/common/buildcraft/core/gui/slots/SlotWorkbench.java +++ b/common/buildcraft/core/gui/slots/SlotWorkbench.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.gui.slots; import net.minecraft.inventory.IInventory; diff --git a/common/buildcraft/core/gui/tooltips/IToolTipProvider.java b/common/buildcraft/core/gui/tooltips/IToolTipProvider.java index 59351e3f..ad074b9e 100644 --- a/common/buildcraft/core/gui/tooltips/IToolTipProvider.java +++ b/common/buildcraft/core/gui/tooltips/IToolTipProvider.java @@ -1,9 +1,13 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.gui.tooltips; -/** - * - * @author CovertJaguar - */ public interface IToolTipProvider { ToolTip getToolTip(); diff --git a/common/buildcraft/core/gui/tooltips/ToolTip.java b/common/buildcraft/core/gui/tooltips/ToolTip.java index 48ab984d..4afc49b7 100644 --- a/common/buildcraft/core/gui/tooltips/ToolTip.java +++ b/common/buildcraft/core/gui/tooltips/ToolTip.java @@ -1,13 +1,17 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.gui.tooltips; import com.google.common.collect.ForwardingList; import java.util.ArrayList; import java.util.List; -/** - * - * @author CovertJaguar - */ public class ToolTip extends ForwardingList { private final List delegate = new ArrayList(); diff --git a/common/buildcraft/core/gui/tooltips/ToolTipLine.java b/common/buildcraft/core/gui/tooltips/ToolTipLine.java index 15059679..e6b2e69f 100644 --- a/common/buildcraft/core/gui/tooltips/ToolTipLine.java +++ b/common/buildcraft/core/gui/tooltips/ToolTipLine.java @@ -1,9 +1,13 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.gui.tooltips; -/** - * - * @author CovertJaguar - */ public class ToolTipLine { public String text; diff --git a/common/buildcraft/core/gui/widgets/ButtonWidget.java b/common/buildcraft/core/gui/widgets/ButtonWidget.java index 0cb200fc..da9a4364 100644 --- a/common/buildcraft/core/gui/widgets/ButtonWidget.java +++ b/common/buildcraft/core/gui/widgets/ButtonWidget.java @@ -1,7 +1,7 @@ -/* - * Copyright (c) SpaceToad, 2011-2012 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * + * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt @@ -10,10 +10,6 @@ package buildcraft.core.gui.widgets; import buildcraft.core.gui.GuiBuildCraft; -/** - * - * @author CovertJaguar - */ public class ButtonWidget extends Widget { private boolean pressed; diff --git a/common/buildcraft/core/gui/widgets/FluidGaugeWidget.java b/common/buildcraft/core/gui/widgets/FluidGaugeWidget.java index acdbbbf0..1ad268ba 100644 --- a/common/buildcraft/core/gui/widgets/FluidGaugeWidget.java +++ b/common/buildcraft/core/gui/widgets/FluidGaugeWidget.java @@ -1,17 +1,20 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.gui.widgets; - import buildcraft.core.fluids.Tank; import buildcraft.core.gui.GuiBuildCraft; import buildcraft.core.gui.tooltips.ToolTip; import buildcraft.core.render.FluidRenderer; -import net.minecraft.util.Icon; +import net.minecraft.util.IIcon; import net.minecraftforge.fluids.FluidStack; -/** - * - * @author CovertJaguar - */ public class FluidGaugeWidget extends Widget { public final Tank tank; @@ -34,7 +37,7 @@ public class FluidGaugeWidget extends Widget { if (fluidStack == null || fluidStack.amount <= 0 || fluidStack.getFluid() == null) return; - Icon liquidIcon = FluidRenderer.getFluidTexture(fluidStack, false); + IIcon liquidIcon = FluidRenderer.getFluidTexture(fluidStack, false); if (liquidIcon == null) return; diff --git a/common/buildcraft/core/gui/widgets/IIndicatorController.java b/common/buildcraft/core/gui/widgets/IIndicatorController.java index efece096..ffb1cfbf 100644 --- a/common/buildcraft/core/gui/widgets/IIndicatorController.java +++ b/common/buildcraft/core/gui/widgets/IIndicatorController.java @@ -1,12 +1,15 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.gui.widgets; import buildcraft.core.gui.tooltips.ToolTip; - -/** - * - * @author CovertJaguar - */ public interface IIndicatorController { ToolTip getToolTip(); diff --git a/common/buildcraft/core/gui/widgets/IndicatorController.java b/common/buildcraft/core/gui/widgets/IndicatorController.java index 85b6c056..6c09f0f4 100644 --- a/common/buildcraft/core/gui/widgets/IndicatorController.java +++ b/common/buildcraft/core/gui/widgets/IndicatorController.java @@ -1,12 +1,16 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.gui.widgets; import buildcraft.core.gui.tooltips.ToolTip; import buildcraft.core.gui.tooltips.ToolTipLine; -/** - * - * @author CovertJaguar - */ public abstract class IndicatorController implements IIndicatorController { private final ToolTip tips = new ToolTip() { diff --git a/common/buildcraft/core/gui/widgets/IndicatorWidget.java b/common/buildcraft/core/gui/widgets/IndicatorWidget.java index 41c7b75f..0fd7992e 100644 --- a/common/buildcraft/core/gui/widgets/IndicatorWidget.java +++ b/common/buildcraft/core/gui/widgets/IndicatorWidget.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.gui.widgets; import buildcraft.core.gui.GuiBuildCraft; @@ -5,10 +13,6 @@ import buildcraft.core.gui.tooltips.ToolTip; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -/** - * - * @author CovertJaguar - */ public class IndicatorWidget extends Widget { public final IIndicatorController controller; diff --git a/common/buildcraft/core/gui/widgets/Widget.java b/common/buildcraft/core/gui/widgets/Widget.java index 3e79de41..771abb1a 100644 --- a/common/buildcraft/core/gui/widgets/Widget.java +++ b/common/buildcraft/core/gui/widgets/Widget.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.core.gui.widgets; @@ -17,10 +18,6 @@ import java.io.DataInputStream; import java.io.IOException; import net.minecraft.inventory.ICrafting; -/** - * - * @author CovertJaguar - */ public class Widget implements IToolTipProvider { public final int x; diff --git a/common/buildcraft/core/inventory/ITransactor.java b/common/buildcraft/core/inventory/ITransactor.java index 25363183..803068e0 100644 --- a/common/buildcraft/core/inventory/ITransactor.java +++ b/common/buildcraft/core/inventory/ITransactor.java @@ -1,8 +1,16 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.inventory; import buildcraft.core.inventory.filters.IStackFilter; import net.minecraft.item.ItemStack; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; public interface ITransactor { diff --git a/common/buildcraft/core/inventory/InvUtils.java b/common/buildcraft/core/inventory/InvUtils.java index 8eb604ff..7c1d465e 100644 --- a/common/buildcraft/core/inventory/InvUtils.java +++ b/common/buildcraft/core/inventory/InvUtils.java @@ -1,8 +1,17 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.inventory; import buildcraft.core.inventory.InventoryIterator.IInvSlot; import buildcraft.core.inventory.filters.ArrayStackFilter; import buildcraft.core.inventory.filters.IStackFilter; +import buildcraft.core.utils.Utils; import net.minecraft.entity.item.EntityItem; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.InventoryLargeChest; @@ -12,12 +21,8 @@ import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagString; import net.minecraft.tileentity.TileEntityChest; import net.minecraft.world.World; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; -/** - * - * @author CovertJaguar - */ public class InvUtils { public static int countItems(IInventory inv, ForgeDirection side, ItemStack... filter) { @@ -124,19 +129,19 @@ public class InvUtils { public static NBTTagCompound getItemData(ItemStack stack) { NBTTagCompound nbt = stack.getTagCompound(); if (nbt == null) { - nbt = new NBTTagCompound("tag"); + nbt = new NBTTagCompound(); stack.setTagCompound(nbt); } return nbt; } - public static void addItemToolTip(ItemStack stack, String tag, String msg) { + public static void addItemToolTip(ItemStack stack, String msg) { NBTTagCompound nbt = getItemData(stack); NBTTagCompound display = nbt.getCompoundTag("display"); - nbt.setCompoundTag("display", display); - NBTTagList lore = display.getTagList("Lore"); + nbt.setTag("display", display); + NBTTagList lore = display.getTagList("Lore", Utils.NBTTag_Types.NBTTagString.ordinal()); display.setTag("Lore", lore); - lore.appendTag(new NBTTagString(tag, msg)); + lore.appendTag(new NBTTagString(msg)); } public static void writeInvToNBT(IInventory inv, String tag, NBTTagCompound data) { @@ -154,9 +159,9 @@ public class InvUtils { } public static void readInvFromNBT(IInventory inv, String tag, NBTTagCompound data) { - NBTTagList list = data.getTagList(tag); + NBTTagList list = data.getTagList(tag, Utils.NBTTag_Types.NBTTagCompound.ordinal()); for (byte entry = 0; entry < list.tagCount(); entry++) { - NBTTagCompound itemTag = (NBTTagCompound) list.tagAt(entry); + NBTTagCompound itemTag = list.getCompoundTagAt(entry); int slot = itemTag.getByte("Slot"); if (slot >= 0 && slot < inv.getSizeInventory()) { ItemStack stack = ItemStack.loadItemStackFromNBT(itemTag); @@ -166,11 +171,11 @@ public class InvUtils { } public static void readStacksFromNBT(NBTTagCompound nbt, String name, ItemStack[] stacks) { - NBTTagList nbttaglist = nbt.getTagList(name); + NBTTagList nbttaglist = nbt.getTagList(name, Utils.NBTTag_Types.NBTTagCompound.ordinal()); for (int i = 0; i < stacks.length; ++i) { if (i < nbttaglist.tagCount()) { - NBTTagCompound nbttagcompound2 = (NBTTagCompound) nbttaglist.tagAt(i); + NBTTagCompound nbttagcompound2 = nbttaglist.getCompoundTagAt(i); stacks[i] = ItemStack.loadItemStackFromNBT(nbttagcompound2); } else { @@ -197,7 +202,7 @@ public class InvUtils { public static ItemStack consumeItem(ItemStack stack) { if (stack.stackSize == 1) { if (stack.getItem().hasContainerItem()) { - return stack.getItem().getContainerItemStack(stack); + return stack.getItem().getContainerItem(stack); } else { return null; } @@ -233,8 +238,8 @@ public class InvUtils { adjacent = chest.adjacentChestZNeg; } - if (chest.adjacentChestZPosition != null) { - adjacent = chest.adjacentChestZPosition; + if (chest.adjacentChestZPos != null) { + adjacent = chest.adjacentChestZPos; } if (adjacent != null) { diff --git a/common/buildcraft/core/inventory/InventoryConcatenator.java b/common/buildcraft/core/inventory/InventoryConcatenator.java index f2119dd9..13112208 100644 --- a/common/buildcraft/core/inventory/InventoryConcatenator.java +++ b/common/buildcraft/core/inventory/InventoryConcatenator.java @@ -1,7 +1,7 @@ -/* - * Copyright (c) SpaceToad, 2011-2012 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * + * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt @@ -16,8 +16,6 @@ import net.minecraft.item.ItemStack; /** * Allows you to deal with multiple inventories through a single interface. - * - * @author CovertJaguar */ public class InventoryConcatenator implements IInventory { @@ -65,39 +63,39 @@ public class InventoryConcatenator implements IInventory { } @Override - public String getInvName() { + public String getInventoryName() { return ""; } - @Override - public boolean isInvNameLocalized() { - return false; - } - @Override public int getInventoryStackLimit() { return 64; } - @Override - public void onInventoryChanged() { - } - @Override public boolean isUseableByPlayer(EntityPlayer entityplayer) { return true; } @Override - public void openChest() { + public void openInventory() { } @Override - public void closeChest() { + public void closeInventory() { } @Override public boolean isItemValidForSlot(int slot, ItemStack stack) { return invMap.get(slot).isItemValidForSlot(slotMap.get(slot), stack); } + + @Override + public boolean hasCustomInventoryName() { + return false; + } + + @Override + public void markDirty() { + } } diff --git a/common/buildcraft/core/inventory/InventoryCopy.java b/common/buildcraft/core/inventory/InventoryCopy.java index 8acd85b9..99d3ad7d 100644 --- a/common/buildcraft/core/inventory/InventoryCopy.java +++ b/common/buildcraft/core/inventory/InventoryCopy.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.inventory; import net.minecraft.entity.player.EntityPlayer; @@ -9,8 +17,6 @@ import net.minecraft.item.ItemStack; * * Useful for performing inventory manipulations and then examining the results * without affecting the original inventory. - * - * @author CovertJaguar */ public class InventoryCopy implements IInventory { @@ -44,14 +50,12 @@ public class InventoryCopy implements IInventory { if (contents[i].stackSize <= j) { ItemStack itemstack = contents[i]; contents[i] = null; - onInventoryChanged(); return itemstack; } ItemStack itemstack1 = contents[i].splitStack(j); if (contents[i].stackSize <= 0) { contents[i] = null; } - onInventoryChanged(); return itemstack1; } else { return null; @@ -64,12 +68,11 @@ public class InventoryCopy implements IInventory { if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) { itemstack.stackSize = getInventoryStackLimit(); } - onInventoryChanged(); } @Override - public String getInvName() { - return orignal.getInvName(); + public String getInventoryName() { + return orignal.getInventoryName(); } @Override @@ -77,21 +80,17 @@ public class InventoryCopy implements IInventory { return orignal.getInventoryStackLimit(); } - @Override - public void onInventoryChanged() { - } - @Override public boolean isUseableByPlayer(EntityPlayer entityplayer) { return true; } @Override - public void openChest() { + public void openInventory() { } @Override - public void closeChest() { + public void closeInventory() { } @Override @@ -99,11 +98,6 @@ public class InventoryCopy implements IInventory { return orignal.getStackInSlotOnClosing(slot); } - @Override - public boolean isInvNameLocalized() { - return orignal.isInvNameLocalized(); - } - @Override public boolean isItemValidForSlot(int slot, ItemStack stack) { return orignal.isItemValidForSlot(slot, stack); @@ -112,4 +106,14 @@ public class InventoryCopy implements IInventory { public ItemStack[] getItemStacks() { return contents; } + + @Override + public boolean hasCustomInventoryName() { + return false; + } + + @Override + public void markDirty() { + + } } diff --git a/common/buildcraft/core/inventory/InventoryIterator.java b/common/buildcraft/core/inventory/InventoryIterator.java index ac349368..59587a6e 100644 --- a/common/buildcraft/core/inventory/InventoryIterator.java +++ b/common/buildcraft/core/inventory/InventoryIterator.java @@ -1,13 +1,18 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.inventory; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; -/** - * @author CovertJaguar - */ public class InventoryIterator { /** diff --git a/common/buildcraft/core/inventory/InventoryIteratorSided.java b/common/buildcraft/core/inventory/InventoryIteratorSided.java index 02db8127..e04b324c 100644 --- a/common/buildcraft/core/inventory/InventoryIteratorSided.java +++ b/common/buildcraft/core/inventory/InventoryIteratorSided.java @@ -1,14 +1,19 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.inventory; import buildcraft.core.inventory.InventoryIterator.IInvSlot; import java.util.Iterator; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; -/** - * @author CovertJaguar - */ class InventoryIteratorSided implements Iterable { private final ISidedInventory inv; diff --git a/common/buildcraft/core/inventory/InventoryIteratorSimple.java b/common/buildcraft/core/inventory/InventoryIteratorSimple.java index e0b311ae..7e3b7a63 100644 --- a/common/buildcraft/core/inventory/InventoryIteratorSimple.java +++ b/common/buildcraft/core/inventory/InventoryIteratorSimple.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.inventory; import buildcraft.core.inventory.InventoryIterator.IInvSlot; @@ -5,9 +13,6 @@ import java.util.Iterator; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; -/** - * @author CovertJaguar - */ class InventoryIteratorSimple implements Iterable { private final IInventory inv; diff --git a/common/buildcraft/core/inventory/InventoryMapper.java b/common/buildcraft/core/inventory/InventoryMapper.java index f6107012..fcff04a0 100644 --- a/common/buildcraft/core/inventory/InventoryMapper.java +++ b/common/buildcraft/core/inventory/InventoryMapper.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.inventory; import net.minecraft.entity.player.EntityPlayer; @@ -8,8 +16,6 @@ import net.minecraft.item.ItemStack; * Wrapper class used to specify part of an existing inventory to be treated as * a complete inventory. Used primarily to map a side of an ISidedInventory, but * it is also helpful for complex inventories such as the Tunnel Bore. - * - * @author CovertJaguar */ public class InventoryMapper implements IInventory { @@ -63,8 +69,8 @@ public class InventoryMapper implements IInventory { } @Override - public String getInvName() { - return inv.getInvName(); + public String getInventoryName() { + return inv.getInventoryName(); } public void setStackSizeLimit(int limit) { @@ -76,24 +82,19 @@ public class InventoryMapper implements IInventory { return stackSizeLimit > 0 ? stackSizeLimit : inv.getInventoryStackLimit(); } - @Override - public void onInventoryChanged() { - inv.onInventoryChanged(); - } - @Override public boolean isUseableByPlayer(EntityPlayer entityplayer) { return inv.isUseableByPlayer(entityplayer); } @Override - public void openChest() { - inv.openChest(); + public void openInventory() { + inv.openInventory(); } @Override - public void closeChest() { - inv.closeChest(); + public void closeInventory() { + inv.closeInventory(); } @Override @@ -101,11 +102,6 @@ public class InventoryMapper implements IInventory { return inv.getStackInSlotOnClosing(start + slot); } - @Override - public boolean isInvNameLocalized() { - return inv.isInvNameLocalized(); - } - @Override public boolean isItemValidForSlot(int slot, ItemStack stack) { if (checkItems) { @@ -113,4 +109,14 @@ public class InventoryMapper implements IInventory { } return true; } + + @Override + public boolean hasCustomInventoryName() { + return inv.hasCustomInventoryName(); + } + + @Override + public void markDirty() { + inv.markDirty(); + } } diff --git a/common/buildcraft/core/inventory/InventoryWrapper.java b/common/buildcraft/core/inventory/InventoryWrapper.java index 179f6926..08d61c25 100644 --- a/common/buildcraft/core/inventory/InventoryWrapper.java +++ b/common/buildcraft/core/inventory/InventoryWrapper.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.inventory; import net.minecraft.entity.player.EntityPlayer; @@ -19,14 +27,14 @@ public abstract class InventoryWrapper implements ISidedInventory { @Override public ItemStack decrStackSize(int slotIndex, int amount) { return inventory.decrStackSize(slotIndex, amount); } @Override public ItemStack getStackInSlotOnClosing(int slotIndex) { return inventory.getStackInSlotOnClosing(slotIndex); } @Override public void setInventorySlotContents(int slotIndex, ItemStack itemstack) { inventory.setInventorySlotContents(slotIndex, itemstack); } - @Override public String getInvName() { return inventory.getInvName(); } - @Override public boolean isInvNameLocalized() { return inventory.isInvNameLocalized(); } + @Override public String getInventoryName() { return inventory.getInventoryName(); } @Override public int getInventoryStackLimit() { return inventory.getInventoryStackLimit(); } - @Override public void onInventoryChanged() { inventory.onInventoryChanged(); } + @Override public void markDirty() { inventory.markDirty(); } @Override public boolean isUseableByPlayer(EntityPlayer entityplayer) { return inventory.isUseableByPlayer(entityplayer); } - @Override public void openChest() { inventory.openChest(); } - @Override public void closeChest() { inventory.closeChest(); } + @Override public void openInventory() { inventory.openInventory(); } + @Override public void closeInventory() { inventory.closeInventory(); } @Override public boolean isItemValidForSlot(int slotIndex, ItemStack itemstack) { return inventory.isItemValidForSlot(slotIndex, itemstack); } + @Override public boolean hasCustomInventoryName() { return inventory.hasCustomInventoryName(); }; /* STATIC HELPER */ public static ISidedInventory getWrappedInventory(Object inventory) { diff --git a/common/buildcraft/core/inventory/InventoryWrapperSimple.java b/common/buildcraft/core/inventory/InventoryWrapperSimple.java index 2da6af71..84bb3f21 100644 --- a/common/buildcraft/core/inventory/InventoryWrapperSimple.java +++ b/common/buildcraft/core/inventory/InventoryWrapperSimple.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.inventory; import buildcraft.core.utils.Utils; diff --git a/common/buildcraft/core/inventory/SimpleInventory.java b/common/buildcraft/core/inventory/SimpleInventory.java index e6976970..b7e2b9d2 100644 --- a/common/buildcraft/core/inventory/SimpleInventory.java +++ b/common/buildcraft/core/inventory/SimpleInventory.java @@ -1,14 +1,18 @@ /** - * Copyright (c) Krapht, 2011 + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * "LogisticsPipes" is distributed under the terms of the Minecraft Mod Public + * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.core.inventory; import buildcraft.core.utils.INBTTagable; +import buildcraft.core.utils.Utils; + import java.util.LinkedList; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; @@ -44,7 +48,7 @@ public class SimpleInventory implements IInventory, INBTTagable { if (slotId < _contents.length && _contents[slotId] != null) { if (_contents[slotId].stackSize > count) { ItemStack result = _contents[slotId].splitStack(count); - onInventoryChanged(); + markDirty(); return result; } ItemStack stack = _contents[slotId]; @@ -64,11 +68,11 @@ public class SimpleInventory implements IInventory, INBTTagable { if (itemstack != null && itemstack.stackSize > this.getInventoryStackLimit()) { itemstack.stackSize = this.getInventoryStackLimit(); } - onInventoryChanged(); + markDirty(); } @Override - public String getInvName() { + public String getInventoryName() { return _name; } @@ -77,24 +81,17 @@ public class SimpleInventory implements IInventory, INBTTagable { return _stackLimit; } - @Override - public void onInventoryChanged() { - for (TileEntity handler : _listener) { - handler.onInventoryChanged(); - } - } - @Override public boolean isUseableByPlayer(EntityPlayer entityplayer) { return true; } @Override - public void openChest() { + public void openInventory() { } @Override - public void closeChest() { + public void closeInventory() { } @Override @@ -103,10 +100,10 @@ public class SimpleInventory implements IInventory, INBTTagable { } public void readFromNBT(NBTTagCompound data, String tag) { - NBTTagList nbttaglist = data.getTagList(tag); + NBTTagList nbttaglist = data.getTagList(tag, Utils.NBTTag_Types.NBTTagCompound.ordinal()); for (int j = 0; j < nbttaglist.tagCount(); ++j) { - NBTTagCompound slot = (NBTTagCompound) nbttaglist.tagAt(j); + NBTTagCompound slot = nbttaglist.getCompoundTagAt(j); int index; if (slot.hasKey("index")) { index = slot.getInteger("index"); @@ -157,12 +154,19 @@ public class SimpleInventory implements IInventory, INBTTagable { } @Override - public boolean isInvNameLocalized() { + public boolean isItemValidForSlot(int i, ItemStack itemstack) { + return true; + } + + @Override + public boolean hasCustomInventoryName() { return false; } @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) { - return true; + public void markDirty() { + for (TileEntity handler : _listener) { + handler.markDirty(); + } } } diff --git a/common/buildcraft/core/inventory/StackHelper.java b/common/buildcraft/core/inventory/StackHelper.java index cc7cb98b..5628078e 100644 --- a/common/buildcraft/core/inventory/StackHelper.java +++ b/common/buildcraft/core/inventory/StackHelper.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.core.inventory; @@ -89,7 +90,7 @@ public class StackHelper { int idBase = OreDictionary.getOreID(base); if (idBase >= 0) { for (ItemStack itemstack : OreDictionary.getOres(idBase)) { - if (comparison.itemID == itemstack.itemID && (itemstack.getItemDamage() == OreDictionary.WILDCARD_VALUE || comparison.getItemDamage() == itemstack.getItemDamage())) + if (comparison.getItem() == itemstack.getItem() && (itemstack.getItemDamage() == OreDictionary.WILDCARD_VALUE || comparison.getItemDamage() == itemstack.getItemDamage())) return true; } } @@ -101,7 +102,7 @@ public class StackHelper { public boolean isCraftingEquivalent(int oreID, ItemStack comparison) { if (oreID >= 0) { for (ItemStack itemstack : OreDictionary.getOres(oreID)) { - if (comparison.itemID == itemstack.itemID && (itemstack.getItemDamage() == OreDictionary.WILDCARD_VALUE || comparison.getItemDamage() == itemstack.getItemDamage())) + if (comparison.getItem() == itemstack.getItem() && (itemstack.getItemDamage() == OreDictionary.WILDCARD_VALUE || comparison.getItemDamage() == itemstack.getItemDamage())) return true; } } @@ -135,7 +136,7 @@ public class StackHelper { if (a == null || b == null) { return false; } - if (a.itemID != b.itemID) { + if (a.getItem() != b.getItem()) { return false; } if (matchDamage && a.getHasSubtypes()) { diff --git a/common/buildcraft/core/inventory/Transactor.java b/common/buildcraft/core/inventory/Transactor.java index 0321bd0d..55e71ca4 100644 --- a/common/buildcraft/core/inventory/Transactor.java +++ b/common/buildcraft/core/inventory/Transactor.java @@ -1,10 +1,18 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.inventory; import buildcraft.api.inventory.ISpecialInventory; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; public abstract class Transactor implements ITransactor { diff --git a/common/buildcraft/core/inventory/TransactorRoundRobin.java b/common/buildcraft/core/inventory/TransactorRoundRobin.java index 89c21ecd..28ef6f5e 100644 --- a/common/buildcraft/core/inventory/TransactorRoundRobin.java +++ b/common/buildcraft/core/inventory/TransactorRoundRobin.java @@ -1,9 +1,17 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.inventory; import buildcraft.core.inventory.InventoryIterator.IInvSlot; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; public class TransactorRoundRobin extends TransactorSimple { diff --git a/common/buildcraft/core/inventory/TransactorSimple.java b/common/buildcraft/core/inventory/TransactorSimple.java index 4f8a5b4d..21600424 100644 --- a/common/buildcraft/core/inventory/TransactorSimple.java +++ b/common/buildcraft/core/inventory/TransactorSimple.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.inventory; import buildcraft.core.inventory.InventoryIterator.IInvSlot; @@ -6,7 +14,7 @@ import java.util.ArrayList; import java.util.List; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; public class TransactorSimple extends Transactor { @@ -34,7 +42,7 @@ public class TransactorSimple extends Transactor { injected = tryPut(stack, filledSlots, injected, doAdd); injected = tryPut(stack, emptySlots, injected, doAdd); - inventory.onInventoryChanged(); + inventory.markDirty(); return injected; } diff --git a/common/buildcraft/core/inventory/TransactorSpecial.java b/common/buildcraft/core/inventory/TransactorSpecial.java index bd1c7f03..0fa3414c 100644 --- a/common/buildcraft/core/inventory/TransactorSpecial.java +++ b/common/buildcraft/core/inventory/TransactorSpecial.java @@ -1,9 +1,17 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.inventory; import buildcraft.api.inventory.ISpecialInventory; import buildcraft.core.inventory.filters.IStackFilter; import net.minecraft.item.ItemStack; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; public class TransactorSpecial extends Transactor { diff --git a/common/buildcraft/core/inventory/filters/ArrayStackFilter.java b/common/buildcraft/core/inventory/filters/ArrayStackFilter.java index 41fa0f76..bd22c00b 100644 --- a/common/buildcraft/core/inventory/filters/ArrayStackFilter.java +++ b/common/buildcraft/core/inventory/filters/ArrayStackFilter.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.inventory.filters; import buildcraft.core.inventory.StackHelper; @@ -5,8 +13,6 @@ import net.minecraft.item.ItemStack; /** * Returns true if the stack matches any one one of the filter stacks. - * - * @author CovertJaguar */ public class ArrayStackFilter implements IStackFilter { diff --git a/common/buildcraft/core/inventory/filters/CraftingFilter.java b/common/buildcraft/core/inventory/filters/CraftingFilter.java index b2dc1558..12ce75a5 100644 --- a/common/buildcraft/core/inventory/filters/CraftingFilter.java +++ b/common/buildcraft/core/inventory/filters/CraftingFilter.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.inventory.filters; import buildcraft.core.inventory.StackHelper; @@ -6,8 +14,6 @@ import net.minecraft.item.ItemStack; /** * Returns true if the stack matches any one one of the filter stacks. * Checks the OreDictionary and wildcards. - * - * @author CovertJaguar */ public class CraftingFilter implements IStackFilter { diff --git a/common/buildcraft/core/inventory/filters/IStackFilter.java b/common/buildcraft/core/inventory/filters/IStackFilter.java index fafc9756..f5382866 100644 --- a/common/buildcraft/core/inventory/filters/IStackFilter.java +++ b/common/buildcraft/core/inventory/filters/IStackFilter.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.inventory.filters; import net.minecraft.item.ItemStack; @@ -5,8 +13,6 @@ import net.minecraft.item.ItemStack; /** * This interface provides a convenient means of dealing with entire classes of * items without having to specify each item individually. - * - * @author CovertJaguar */ public interface IStackFilter { diff --git a/common/buildcraft/core/inventory/filters/InvertedStackFilter.java b/common/buildcraft/core/inventory/filters/InvertedStackFilter.java index de862603..e3432bd2 100644 --- a/common/buildcraft/core/inventory/filters/InvertedStackFilter.java +++ b/common/buildcraft/core/inventory/filters/InvertedStackFilter.java @@ -1,11 +1,15 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.inventory.filters; import net.minecraft.item.ItemStack; -/** - * - * @author CovertJaguar - */ public class InvertedStackFilter implements IStackFilter { private final IStackFilter filter; diff --git a/common/buildcraft/core/inventory/filters/StackFilter.java b/common/buildcraft/core/inventory/filters/StackFilter.java index ba63eab6..a293c94d 100644 --- a/common/buildcraft/core/inventory/filters/StackFilter.java +++ b/common/buildcraft/core/inventory/filters/StackFilter.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.inventory.filters; import net.minecraft.item.ItemStack; @@ -7,8 +15,6 @@ import net.minecraft.tileentity.TileEntityFurnace; * This interface is used with several of the functions in IItemTransfer to * provide a convenient means of dealing with entire classes of items without * having to specify each item individually. - * - * @author CovertJaguar */ public enum StackFilter implements IStackFilter { diff --git a/common/buildcraft/core/network/BuildCraftChannelHandler.java b/common/buildcraft/core/network/BuildCraftChannelHandler.java new file mode 100755 index 00000000..91b3f92f --- /dev/null +++ b/common/buildcraft/core/network/BuildCraftChannelHandler.java @@ -0,0 +1,51 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ +package buildcraft.core.network; + +import buildcraft.builders.network.PacketLibraryAction; +import buildcraft.transport.network.PacketFluidUpdate; +import buildcraft.transport.network.PacketGateExpansionMap; +import buildcraft.transport.network.PacketPipeTransportItemStack; +import buildcraft.transport.network.PacketPipeTransportItemStackRequest; +import buildcraft.transport.network.PacketPipeTransportTraveler; +import buildcraft.transport.network.PacketPowerUpdate; +import cpw.mods.fml.common.network.FMLIndexedMessageToMessageCodec; +import io.netty.buffer.ByteBuf; +import io.netty.channel.ChannelHandlerContext; + +public class BuildCraftChannelHandler extends FMLIndexedMessageToMessageCodec { + + public BuildCraftChannelHandler() { + addDiscriminator(0, PacketTileUpdate.class); + addDiscriminator(1, PacketTileState.class); + addDiscriminator(2, PacketCoordinates.class); + addDiscriminator(3, PacketFluidUpdate.class); + addDiscriminator(4, PacketLibraryAction.class); + addDiscriminator(5, PacketNBT.class); + addDiscriminator(6, PacketPowerUpdate.class); + addDiscriminator(7, PacketSlotChange.class); + addDiscriminator(8, PacketGateExpansionMap.class); + addDiscriminator(9, PacketGuiReturn.class); + addDiscriminator(10, PacketGuiWidget.class); + addDiscriminator(11, PacketPipeTransportItemStack.class); + addDiscriminator(12, PacketPipeTransportItemStackRequest.class); + addDiscriminator(13, PacketPipeTransportTraveler.class); + addDiscriminator(14, PacketUpdate.class); + } + + @Override + public void encodeInto(ChannelHandlerContext ctx, BuildCraftPacket packet, ByteBuf data) throws Exception { + packet.writeData(data); + } + + @Override + public void decodeInto(ChannelHandlerContext ctx, ByteBuf data, BuildCraftPacket packet) { + packet.readData(data); + } +} diff --git a/common/buildcraft/core/network/BuildCraftPacket.java b/common/buildcraft/core/network/BuildCraftPacket.java index e1712054..d684824c 100644 --- a/common/buildcraft/core/network/BuildCraftPacket.java +++ b/common/buildcraft/core/network/BuildCraftPacket.java @@ -1,39 +1,23 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.network; import buildcraft.core.DefaultProps; -import java.io.ByteArrayOutputStream; -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; -import net.minecraft.network.packet.Packet; -import net.minecraft.network.packet.Packet250CustomPayload; +import io.netty.buffer.ByteBuf; public abstract class BuildCraftPacket { protected boolean isChunkDataPacket = false; - protected String channel = DefaultProps.NET_CHANNEL_NAME; public abstract int getID(); - public Packet getPacket() { + public abstract void readData(ByteBuf data); - ByteArrayOutputStream bytes = new ByteArrayOutputStream(); - DataOutputStream data = new DataOutputStream(bytes); - try { - data.writeByte(getID()); - writeData(data); - } catch (IOException e) { - e.printStackTrace(); - } - Packet250CustomPayload packet = new Packet250CustomPayload(); - packet.channel = channel; - packet.data = bytes.toByteArray(); - packet.length = packet.data.length; - packet.isChunkDataPacket = this.isChunkDataPacket; - return packet; - } - - public abstract void readData(DataInputStream data) throws IOException; - - public abstract void writeData(DataOutputStream data) throws IOException; + public abstract void writeData(ByteBuf data); } diff --git a/common/buildcraft/core/network/ClassMapping.java b/common/buildcraft/core/network/ClassMapping.java index e8d3c96a..1a480ced 100644 --- a/common/buildcraft/core/network/ClassMapping.java +++ b/common/buildcraft/core/network/ClassMapping.java @@ -1,17 +1,17 @@ /** - * Copyright (c) SpaceToad, 2011 + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.core.network; +import io.netty.buffer.ByteBuf; + import java.io.DataInputStream; import java.io.DataOutputStream; -import java.io.IOException; import java.lang.reflect.Array; import java.lang.reflect.Field; import java.lang.reflect.Type; @@ -20,6 +20,7 @@ import java.util.LinkedList; import java.util.Map; import java.util.TreeMap; +import buildcraft.core.utils.Utils; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; @@ -186,8 +187,8 @@ public class ClassMapping { } - public void setData(Object obj, DataOutputStream data) throws IllegalArgumentException, - IllegalAccessException, IOException { + public void setData(Object obj, ByteBuf data) throws IllegalArgumentException, + IllegalAccessException { SerializationContext context = new SerializationContext(); setDataInt(obj, data, context); @@ -232,15 +233,15 @@ public class ClassMapping { * * @throws ClassNotFoundException */ - public Object updateFromData (Object obj, DataInputStream data) throws IllegalArgumentException, - IllegalAccessException, IOException, InstantiationException, ClassNotFoundException { + public Object updateFromData (Object obj, ByteBuf data) throws IllegalArgumentException, + IllegalAccessException, InstantiationException, ClassNotFoundException { SerializationContext context = new SerializationContext(); return updateFromDataInt(obj, data, context); } - public void setDataInt(Object obj, DataOutputStream data, SerializationContext context) throws IllegalArgumentException, - IllegalAccessException, IOException { + public void setDataInt(Object obj, ByteBuf data, SerializationContext context) throws IllegalArgumentException, + IllegalAccessException { if (mappedClass.isArray()) { setDataArray(obj, data, context); } else { @@ -248,8 +249,8 @@ public class ClassMapping { } } - private Object updateFromDataInt (Object obj, DataInputStream data, SerializationContext context) throws IllegalArgumentException, - IllegalAccessException, IOException, InstantiationException, ClassNotFoundException { + private Object updateFromDataInt (Object obj, ByteBuf data, SerializationContext context) throws IllegalArgumentException, + IllegalAccessException, InstantiationException, ClassNotFoundException { if (mappedClass.isArray()) { return updateFromDataArray(obj, data, context); } else { @@ -258,8 +259,8 @@ public class ClassMapping { } @SuppressWarnings("rawtypes") - private void setDataClass(Object obj, DataOutputStream data, SerializationContext context) throws IllegalArgumentException, - IllegalAccessException, IOException { + private void setDataClass(Object obj, ByteBuf data, SerializationContext context) throws IllegalArgumentException, + IllegalAccessException { for (Field f : shortFields) { data.writeShort(f.getShort(obj)); @@ -292,18 +293,18 @@ public class ClassMapping { data.writeBoolean(false); } else { data.writeBoolean(true); - data.writeUTF(s); + Utils.writeUTF(data, s); } } for (Field f : nbtFields) { - NBTBase nbt = (NBTTagCompound) f.get(obj); + NBTTagCompound nbt = (NBTTagCompound) f.get(obj); if (nbt == null) { data.writeBoolean(false); } else { data.writeBoolean(true); - NBTBase.writeNamedTag(nbt, data); + Utils.writeNBT(data, nbt); } } @@ -321,8 +322,8 @@ public class ClassMapping { } @SuppressWarnings("rawtypes") - public Object updateFromDataClass(Object obj, DataInputStream data, SerializationContext context) throws IllegalArgumentException, - IllegalAccessException, IOException, InstantiationException, ClassNotFoundException { + public Object updateFromDataClass(Object obj, ByteBuf data, SerializationContext context) throws IllegalArgumentException, + IllegalAccessException, InstantiationException, ClassNotFoundException { if (obj == null) { obj = mappedClass.newInstance(); @@ -354,7 +355,7 @@ public class ClassMapping { for (Field f : stringFields) { if (data.readBoolean()) { - f.set(obj, data.readUTF()); + f.set(obj, Utils.readUTF(data)); } else { f.set(obj, null); } @@ -362,7 +363,7 @@ public class ClassMapping { for (Field f : nbtFields) { if (data.readBoolean()) { - f.set(obj, NBTBase.readNamedTag(data)); + f.set(obj, Utils.readNBT(data)); } else { f.set(obj, null); } @@ -382,8 +383,8 @@ public class ClassMapping { return obj; } - private void setDataArray(Object obj, DataOutputStream data, SerializationContext context) throws IllegalArgumentException, - IllegalAccessException, IOException { + private void setDataArray(Object obj, ByteBuf data, SerializationContext context) throws IllegalArgumentException, + IllegalAccessException { Class cpt = mappedClass.getComponentType(); switch (cptType) { @@ -426,7 +427,7 @@ public class ClassMapping { data.writeBoolean(false); } else { data.writeBoolean(true); - data.writeUTF(arr [i]); + Utils.writeUTF(data, arr [i]); } } @@ -485,8 +486,8 @@ public class ClassMapping { } } - private Object updateFromDataArray(Object obj, DataInputStream data, SerializationContext context) throws IllegalArgumentException, - IllegalAccessException, IOException, InstantiationException, ClassNotFoundException { + private Object updateFromDataArray(Object obj, ByteBuf data, SerializationContext context) throws IllegalArgumentException, + IllegalAccessException, InstantiationException, ClassNotFoundException { Class cpt = mappedClass.getComponentType(); int size = data.readInt(); @@ -554,7 +555,7 @@ public class ClassMapping { for (int i = 0; i < arr.length; ++i) { if (data.readBoolean()) { - arr [i] = data.readUTF(); + arr [i] = Utils.readUTF(data); } else { arr [i] = null; } @@ -646,9 +647,9 @@ public class ClassMapping { } private void setDataObject(Object obj, - ClassMapping baseMapping, DataOutputStream data, + ClassMapping baseMapping, ByteBuf data, SerializationContext context) throws IllegalArgumentException, - IllegalAccessException, IOException { + IllegalAccessException { ClassMapping mapping = baseMapping; Class realClass = obj.getClass(); @@ -665,7 +666,7 @@ public class ClassMapping { mapping = get(realClass); data.writeByte(index); - data.writeUTF(realClass.getCanonicalName()); + Utils.writeUTF(data, realClass.getCanonicalName()); context.classToId.put(realClass.getCanonicalName(), context.classToId.size()); context.idToClass.add(mapping); @@ -676,9 +677,9 @@ public class ClassMapping { } private Object updateFromDataObject(Object obj, - ClassMapping baseMapping, DataInputStream data, + ClassMapping baseMapping, ByteBuf data, SerializationContext context) throws IllegalArgumentException, - IllegalAccessException, IOException, InstantiationException, + IllegalAccessException, InstantiationException, ClassNotFoundException { // The data layout for an object is the following: @@ -697,7 +698,7 @@ public class ClassMapping { if (index != 0) { if (context.idToClass.size() < index) { - String className = data.readUTF(); + String className = Utils.readUTF(data); Class cls = Class.forName(className); diff --git a/common/buildcraft/core/network/EntityIds.java b/common/buildcraft/core/network/EntityIds.java index 00b0c41d..725faf7b 100644 --- a/common/buildcraft/core/network/EntityIds.java +++ b/common/buildcraft/core/network/EntityIds.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.network; public class EntityIds { diff --git a/common/buildcraft/core/network/IClientState.java b/common/buildcraft/core/network/IClientState.java index 8ecf365a..2fee39f0 100644 --- a/common/buildcraft/core/network/IClientState.java +++ b/common/buildcraft/core/network/IClientState.java @@ -1,14 +1,21 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.network; +import io.netty.buffer.ByteBuf; + import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; /** * Implemented by classes representing serializable client state - * - * @author Krapht - * */ public interface IClientState { /** @@ -17,7 +24,7 @@ public interface IClientState { * @param data * @throws IOException */ - public void writeData(DataOutputStream data) throws IOException; + public void writeData(ByteBuf data); /** * Deserializes the state from the stream @@ -25,5 +32,5 @@ public interface IClientState { * @param data * @throws IOException */ - public void readData(DataInputStream data) throws IOException; + public void readData(ByteBuf data); } diff --git a/common/buildcraft/core/network/IGuiReturnHandler.java b/common/buildcraft/core/network/IGuiReturnHandler.java index 3be79132..68a40c7a 100644 --- a/common/buildcraft/core/network/IGuiReturnHandler.java +++ b/common/buildcraft/core/network/IGuiReturnHandler.java @@ -1,5 +1,15 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.network; +import io.netty.buffer.ByteBuf; + import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; @@ -7,14 +17,10 @@ import java.io.IOException; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.World; -/** - * - * @author CovertJaguar - */ public abstract interface IGuiReturnHandler { public World getWorld(); - public void writeGuiData(DataOutputStream data) throws IOException; + public void writeGuiData(ByteBuf data); - public void readGuiData(DataInputStream data, EntityPlayer player) throws IOException; + public void readGuiData(ByteBuf data, EntityPlayer player); } diff --git a/common/buildcraft/core/network/ISyncedTile.java b/common/buildcraft/core/network/ISyncedTile.java index 3a1fa6ac..fe5eb215 100644 --- a/common/buildcraft/core/network/ISyncedTile.java +++ b/common/buildcraft/core/network/ISyncedTile.java @@ -1,11 +1,13 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.network; -/** - * Implemented by TileEntites - * - * @author Krapht - * - */ public interface ISyncedTile { /** diff --git a/common/buildcraft/core/network/ISynchronizedTile.java b/common/buildcraft/core/network/ISynchronizedTile.java index a72e0643..a6b4e85f 100644 --- a/common/buildcraft/core/network/ISynchronizedTile.java +++ b/common/buildcraft/core/network/ISynchronizedTile.java @@ -1,14 +1,15 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.core.network; import java.io.IOException; -import net.minecraft.network.packet.Packet; +import net.minecraft.network.Packet; public interface ISynchronizedTile { @@ -18,7 +19,7 @@ public interface ISynchronizedTile { public void postPacketHandling(PacketUpdate packet); - public Packet getUpdatePacket(); + public BuildCraftPacket getUpdatePacket(); public Packet getDescriptionPacket(); diff --git a/common/buildcraft/core/network/IndexInPayload.java b/common/buildcraft/core/network/IndexInPayload.java index 4a21c3a9..432e63a1 100644 --- a/common/buildcraft/core/network/IndexInPayload.java +++ b/common/buildcraft/core/network/IndexInPayload.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.network; /** diff --git a/common/buildcraft/core/network/NetworkData.java b/common/buildcraft/core/network/NetworkData.java index 4cae8fab..d483a2cf 100644 --- a/common/buildcraft/core/network/NetworkData.java +++ b/common/buildcraft/core/network/NetworkData.java @@ -1,12 +1,11 @@ /** - * Copyright (c) SpaceToad, 2011 + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.core.network; import java.lang.annotation.Inherited; diff --git a/common/buildcraft/core/network/PacketCoordinates.java b/common/buildcraft/core/network/PacketCoordinates.java index c73a9640..5a2deed2 100644 --- a/common/buildcraft/core/network/PacketCoordinates.java +++ b/common/buildcraft/core/network/PacketCoordinates.java @@ -1,5 +1,15 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.network; +import io.netty.buffer.ByteBuf; + import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; @@ -16,34 +26,30 @@ public class PacketCoordinates extends BuildCraftPacket { } public PacketCoordinates(int id, int x, int y, int z) { - this.id = id; - this.posX = x; this.posY = y; this.posZ = z; } @Override - public void writeData(DataOutputStream data) throws IOException { - + public void writeData(ByteBuf data) { + data.writeByte(id); data.writeInt(posX); data.writeInt(posY); data.writeInt(posZ); } @Override - public void readData(DataInputStream data) throws IOException { - + public void readData(ByteBuf data) { + id = data.readByte (); posX = data.readInt(); posY = data.readInt(); posZ = data.readInt(); - } @Override public int getID() { return id; } - } diff --git a/common/buildcraft/core/network/PacketGuiReturn.java b/common/buildcraft/core/network/PacketGuiReturn.java index e559b24b..5e33de0f 100644 --- a/common/buildcraft/core/network/PacketGuiReturn.java +++ b/common/buildcraft/core/network/PacketGuiReturn.java @@ -1,20 +1,26 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.network; +import io.netty.buffer.ByteBuf; + import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; +import buildcraft.BuildCraftCore; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import net.minecraftforge.common.DimensionManager; -import cpw.mods.fml.common.network.PacketDispatcher; -/** - * - * @author CovertJaguar - */ public class PacketGuiReturn extends BuildCraftPacket { private EntityPlayer sender; private IGuiReturnHandler obj; @@ -35,8 +41,9 @@ public class PacketGuiReturn extends BuildCraftPacket { } @Override - public void writeData(DataOutputStream data) throws IOException { + public void writeData(ByteBuf data) { data.writeInt(obj.getWorld().provider.dimensionId); + if (obj instanceof TileEntity) { TileEntity tile = (TileEntity) obj; data.writeBoolean(true); @@ -46,40 +53,46 @@ public class PacketGuiReturn extends BuildCraftPacket { } else if (obj instanceof Entity) { Entity entity = (Entity) obj; data.writeBoolean(false); - data.writeInt(entity.entityId); - } else + data.writeInt(entity.getEntityId()); + } else { return; + } + obj.writeGuiData(data); - if (extraData != null) - data.write(extraData); + + if (extraData != null) { + data.writeBytes(extraData); + } } @Override - public void readData(DataInputStream data) throws IOException { + public void readData(ByteBuf data) { int dim = data.readInt(); World world = DimensionManager.getWorld(dim); boolean tileReturn = data.readBoolean(); + if (tileReturn) { int x = data.readInt(); int y = data.readInt(); int z = data.readInt(); - TileEntity t = world.getBlockTileEntity(x, y, z); + TileEntity t = world.getTileEntity(x, y, z); - if (t instanceof IGuiReturnHandler) + if (t instanceof IGuiReturnHandler) { ((IGuiReturnHandler) t).readGuiData(data, sender); - + } } else { int entityId = data.readInt(); Entity entity = world.getEntityByID(entityId); - if (entity instanceof IGuiReturnHandler) + if (entity instanceof IGuiReturnHandler) { ((IGuiReturnHandler) entity).readGuiData(data, sender); + } } } public void sendPacket() { - PacketDispatcher.sendPacketToServer(getPacket()); + BuildCraftCore.instance.sendToServer(this); } @Override diff --git a/common/buildcraft/core/network/PacketGuiWidget.java b/common/buildcraft/core/network/PacketGuiWidget.java index e8a78843..3e320463 100644 --- a/common/buildcraft/core/network/PacketGuiWidget.java +++ b/common/buildcraft/core/network/PacketGuiWidget.java @@ -1,7 +1,7 @@ -/* - * Copyright (c) SpaceToad, 2011-2012 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * + * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt @@ -10,14 +10,14 @@ package buildcraft.core.network; import buildcraft.core.gui.BuildCraftContainer; import cpw.mods.fml.client.FMLClientHandler; +import io.netty.buffer.ByteBuf; + import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; + import net.minecraft.client.entity.EntityClientPlayerMP; -/** - * - * @author CovertJaguar - */ + public class PacketGuiWidget extends BuildCraftPacket { private byte windowId, widgetId; @@ -34,21 +34,22 @@ public class PacketGuiWidget extends BuildCraftPacket { } @Override - public void writeData(DataOutputStream data) throws IOException { + public void writeData(ByteBuf data) { data.writeByte(windowId); data.writeByte(widgetId); - data.write(payload); + data.writeBytes(payload); } @Override - public void readData(DataInputStream data) throws IOException { + public void readData(ByteBuf data) { windowId = data.readByte(); widgetId = data.readByte(); EntityClientPlayerMP player = FMLClientHandler.instance().getClient().thePlayer; - if (player.openContainer instanceof BuildCraftContainer && player.openContainer.windowId == windowId) + if (player.openContainer instanceof BuildCraftContainer && player.openContainer.windowId == windowId) { ((BuildCraftContainer) player.openContainer).handleWidgetClientData(widgetId, data); + } } @Override diff --git a/common/buildcraft/core/network/PacketHandler.java b/common/buildcraft/core/network/PacketHandler.java index fd37ca76..e7585687 100644 --- a/common/buildcraft/core/network/PacketHandler.java +++ b/common/buildcraft/core/network/PacketHandler.java @@ -1,70 +1,92 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.network; +import io.netty.buffer.ByteBuf; +import io.netty.channel.ChannelHandlerContext; + import java.io.ByteArrayInputStream; import java.io.DataInputStream; import java.io.IOException; import buildcraft.transport.TileGenericPipe; +import buildcraft.core.proxy.CoreProxy; +import buildcraft.core.utils.Utils; + import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.network.INetworkManager; -import net.minecraft.network.packet.Packet250CustomPayload; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.network.INetHandler; +import net.minecraft.network.NetHandlerPlayServer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import net.minecraftforge.common.DimensionManager; -import cpw.mods.fml.common.network.IPacketHandler; -import cpw.mods.fml.common.network.Player; -public class PacketHandler implements IPacketHandler { +import cpw.mods.fml.repackage.com.nothome.delta.DebugDiffWriter; +import cpw.mods.fml.common.network.NetworkRegistry; + +public class PacketHandler extends BuildCraftChannelHandler { private void onTileUpdate(EntityPlayer player, PacketTileUpdate packet) throws IOException { - World world = player.worldObj; - - if (!packet.targetExists(world)) + World world = player.worldObj; + + if (!packet.targetExists(world)) { return; + } TileEntity entity = packet.getTarget(world); - if (!(entity instanceof ISynchronizedTile)) + + if (!(entity instanceof ISynchronizedTile)) { return; - + } + ISynchronizedTile tile = (ISynchronizedTile) entity; tile.handleUpdatePacket(packet); tile.postPacketHandling(packet); } @Override - public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player) { - DataInputStream data = new DataInputStream(new ByteArrayInputStream(packet.data)); + public void decodeInto(ChannelHandlerContext ctx, ByteBuf data, BuildCraftPacket packet) { + super.decodeInto(ctx, data, packet); + try { - int packetID = data.read(); + INetHandler netHandler = ctx.channel().attr(NetworkRegistry.NET_HANDLER).get(); + EntityPlayer player = Utils.getPlayerFromNetHandler(netHandler); + + int packetID = packet.getID(); + switch (packetID) { case PacketIds.TILE_UPDATE: { - PacketTileUpdate pkt = new PacketTileUpdate(); - pkt.readData(data); - onTileUpdate((EntityPlayer) player, pkt); + onTileUpdate(player, (PacketTileUpdate) packet); break; } case PacketIds.STATE_UPDATE: { - PacketTileState pkt = new PacketTileState(); - pkt.readData(data); - World world = ((EntityPlayer) player).worldObj; - TileEntity tile = world.getBlockTileEntity(pkt.posX, pkt.posY, pkt.posZ); + PacketTileState pkt = (PacketTileState) packet; + World world = player.worldObj; + + TileEntity tile = world.getTileEntity(pkt.posX, pkt.posY, pkt.posZ); + if (tile instanceof ISyncedTile) { pkt.applyStates(data, (ISyncedTile) tile); } + break; } case PacketIds.GUI_RETURN: { - PacketGuiReturn pkt = new PacketGuiReturn((EntityPlayer) player); - pkt.readData(data); + // action will have happened already at read time break; } case PacketIds.GUI_WIDGET: { - PacketGuiWidget pkt = new PacketGuiWidget(); - pkt.readData(data); + // action will have happened already at read time break; } @@ -90,7 +112,7 @@ public class PacketHandler implements IPacketHandler { int y = data.readInt(); int z = data.readInt(); - TileEntity tile = world.getBlockTileEntity(x, y, z); + TileEntity tile = world.getTileEntity(x, y, z); rpc.setTile (tile); rpc.readData(data); @@ -121,7 +143,7 @@ public class PacketHandler implements IPacketHandler { int y = data.readInt(); int z = data.readInt(); - TileEntity tile = world.getBlockTileEntity(x, y, z); + TileEntity tile = world.getTileEntity(x, y, z); if (tile instanceof TileGenericPipe) { rpc.setPipe (((TileGenericPipe) tile).pipe); diff --git a/common/buildcraft/core/network/PacketIds.java b/common/buildcraft/core/network/PacketIds.java index 48b80b2d..e4ada7c5 100644 --- a/common/buildcraft/core/network/PacketIds.java +++ b/common/buildcraft/core/network/PacketIds.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.network; public class PacketIds { diff --git a/common/buildcraft/core/network/PacketNBT.java b/common/buildcraft/core/network/PacketNBT.java index 0cf5a19a..a60d07d8 100644 --- a/common/buildcraft/core/network/PacketNBT.java +++ b/common/buildcraft/core/network/PacketNBT.java @@ -1,8 +1,19 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.network; +import io.netty.buffer.ByteBuf; + import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; + import net.minecraft.nbt.CompressedStreamTools; import net.minecraft.nbt.NBTTagCompound; @@ -19,24 +30,33 @@ public class PacketNBT extends PacketCoordinates { } @Override - public void writeData(DataOutputStream data) throws IOException { - + public void writeData(ByteBuf data) { super.writeData(data); - byte[] compressed = CompressedStreamTools.compress(nbttagcompound); - data.writeShort(compressed.length); - data.write(compressed); + try { + byte[] compressed = CompressedStreamTools.compress(nbttagcompound); + data.writeShort(compressed.length); + data.writeBytes(compressed); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } } @Override - public void readData(DataInputStream data) throws IOException { - + public void readData(ByteBuf data) { super.readData(data); short length = data.readShort(); byte[] compressed = new byte[length]; - data.readFully(compressed); - this.nbttagcompound = CompressedStreamTools.decompress(compressed); + data.readBytes(compressed); + + try { + this.nbttagcompound = CompressedStreamTools.decompress(compressed); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } } public NBTTagCompound getTagCompound() { diff --git a/common/buildcraft/core/network/PacketPayload.java b/common/buildcraft/core/network/PacketPayload.java index d8461ab5..99b41898 100644 --- a/common/buildcraft/core/network/PacketPayload.java +++ b/common/buildcraft/core/network/PacketPayload.java @@ -1,7 +1,17 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.network; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import io.netty.buffer.ByteBuf; + import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; @@ -15,7 +25,7 @@ public abstract class PacketPayload { return new PacketPayloadStream(); } - public abstract void writeData(DataOutputStream data) throws IOException; + public abstract void writeData(ByteBuf data); - public abstract void readData(DataInputStream data) throws IOException; + public abstract void readData(ByteBuf data); } diff --git a/common/buildcraft/core/network/PacketPayloadStream.java b/common/buildcraft/core/network/PacketPayloadStream.java index 8fec395f..900ccd48 100644 --- a/common/buildcraft/core/network/PacketPayloadStream.java +++ b/common/buildcraft/core/network/PacketPayloadStream.java @@ -1,5 +1,5 @@ -/* - * Copyright (c) SpaceToad, 2011-2012 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com * * BuildCraft is distributed under the terms of the Minecraft Mod Public @@ -8,6 +8,8 @@ */ package buildcraft.core.network; +import io.netty.buffer.ByteBuf; + import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; @@ -15,16 +17,18 @@ import java.io.IOException; /** * Alternative Packet Payload system. * - * @author CovertJaguar + * Note, you cannot use a Stream payload and the TileNetworkData annotation at + * the same time. Attempting to do will most likely result in a class cast + * exception somewhere. */ public class PacketPayloadStream extends PacketPayload { public static interface StreamWriter { - public void writeData(DataOutputStream data) throws IOException; + public void writeData(ByteBuf data); } private StreamWriter handler; - public DataInputStream stream; + public ByteBuf stream; public PacketPayloadStream() { } @@ -34,12 +38,12 @@ public class PacketPayloadStream extends PacketPayload { } @Override - public void writeData(DataOutputStream data) throws IOException { + public void writeData(ByteBuf data) { handler.writeData(data); } @Override - public void readData(DataInputStream data) throws IOException { + public void readData(ByteBuf data) { stream = data; } } diff --git a/common/buildcraft/core/network/PacketRPCPipe.java b/common/buildcraft/core/network/PacketRPCPipe.java index 8528d656..d715bd40 100755 --- a/common/buildcraft/core/network/PacketRPCPipe.java +++ b/common/buildcraft/core/network/PacketRPCPipe.java @@ -1,12 +1,8 @@ package buildcraft.core.network; -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; - -import buildcraft.transport.Pipe; +import io.netty.buffer.ByteBuf; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.tileentity.TileEntity; +import buildcraft.transport.Pipe; public class PacketRPCPipe extends BuildCraftPacket { @@ -34,7 +30,7 @@ public class PacketRPCPipe extends BuildCraftPacket { } @Override - public void readData(DataInputStream data) throws IOException { + public void readData(ByteBuf data) { RPCMessageInfo info = new RPCMessageInfo(); info.sender = sender; @@ -42,8 +38,8 @@ public class PacketRPCPipe extends BuildCraftPacket { } @Override - public void writeData(DataOutputStream data) throws IOException { - data.write(contents); + public void writeData(ByteBuf data) { + data.writeBytes(contents); } } diff --git a/common/buildcraft/core/network/PacketRPCTile.java b/common/buildcraft/core/network/PacketRPCTile.java index 403d2ced..3450e26d 100755 --- a/common/buildcraft/core/network/PacketRPCTile.java +++ b/common/buildcraft/core/network/PacketRPCTile.java @@ -1,5 +1,7 @@ package buildcraft.core.network; +import io.netty.buffer.ByteBuf; + import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; @@ -8,7 +10,6 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; public class PacketRPCTile extends BuildCraftPacket { - public TileEntity tile; byte [] contents; @@ -33,7 +34,7 @@ public class PacketRPCTile extends BuildCraftPacket { } @Override - public void readData(DataInputStream data) throws IOException { + public void readData(ByteBuf data) { RPCMessageInfo info = new RPCMessageInfo(); info.sender = sender; @@ -41,8 +42,8 @@ public class PacketRPCTile extends BuildCraftPacket { } @Override - public void writeData(DataOutputStream data) throws IOException { - data.write(contents); + public void writeData(ByteBuf data) { + data.writeBytes(contents); } } diff --git a/common/buildcraft/core/network/PacketSlotChange.java b/common/buildcraft/core/network/PacketSlotChange.java index 43aa772b..714eba68 100644 --- a/common/buildcraft/core/network/PacketSlotChange.java +++ b/common/buildcraft/core/network/PacketSlotChange.java @@ -1,8 +1,21 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.network; +import io.netty.buffer.ByteBuf; + import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; + +import buildcraft.core.utils.Utils; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompressedStreamTools; @@ -21,53 +34,18 @@ public class PacketSlotChange extends PacketCoordinates { } @Override - public void writeData(DataOutputStream data) throws IOException { - + public void writeData(ByteBuf data) { super.writeData(data); data.writeInt(slot); - if (stack != null) { - data.writeInt(stack.itemID); - data.writeInt(stack.stackSize); - data.writeInt(stack.getItemDamage()); - - if(stack.hasTagCompound()) { - byte[] compressed = CompressedStreamTools.compress(stack.getTagCompound()); - data.writeShort(compressed.length); - data.write(compressed); - } else { - data.writeShort(0); - } - - } else { - data.writeInt(0); - } + Utils.writeStack(data, stack); } @Override - public void readData(DataInputStream data) throws IOException { - + public void readData(ByteBuf data) { super.readData(data); this.slot = data.readInt(); - int id = data.readInt(); - - if (id != 0) { - stack = new ItemStack(id, data.readInt(), data.readInt()); - - // Yes, this stuff may indeed have NBT and don't you forget it. - short length = data.readShort(); - - if(length > 0) { - byte[] compressed = new byte[length]; - data.readFully(compressed); - stack.setTagCompound(CompressedStreamTools.decompress(compressed)); - } - - - } else { - stack = null; - } + stack = Utils.readStack(data); } - } diff --git a/common/buildcraft/core/network/PacketTileState.java b/common/buildcraft/core/network/PacketTileState.java index fd4c2581..7fdca50c 100644 --- a/common/buildcraft/core/network/PacketTileState.java +++ b/common/buildcraft/core/network/PacketTileState.java @@ -1,5 +1,15 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.network; +import io.netty.buffer.ByteBuf; + import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; @@ -21,7 +31,7 @@ public class PacketTileState extends PacketCoordinates { private List stateList = new LinkedList(); /** - * Default constructor for incomming packets + * Default constructor for incoming packets */ public PacketTileState() { } @@ -43,11 +53,11 @@ public class PacketTileState extends PacketCoordinates { } @Override - public void readData(DataInputStream data) throws IOException { + public void readData(ByteBuf data) { super.readData(data); } - public void applyStates(DataInputStream data, ISyncedTile tile) throws IOException { + public void applyStates(ByteBuf data, ISyncedTile tile) throws IOException { byte stateCount = data.readByte(); for (int i = 0; i < stateCount; i++) { byte stateId = data.readByte(); @@ -61,7 +71,7 @@ public class PacketTileState extends PacketCoordinates { } @Override - public void writeData(DataOutputStream data) throws IOException { + public void writeData(ByteBuf data) { super.writeData(data); data.writeByte(stateList.size()); for (StateWithId stateWithId : stateList) { diff --git a/common/buildcraft/core/network/PacketTileUpdate.java b/common/buildcraft/core/network/PacketTileUpdate.java index fd611c5f..07ccc0bb 100644 --- a/common/buildcraft/core/network/PacketTileUpdate.java +++ b/common/buildcraft/core/network/PacketTileUpdate.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.network; import net.minecraft.tileentity.TileEntity; @@ -28,7 +36,7 @@ public class PacketTileUpdate extends PacketUpdate { } public TileEntity getTarget(World world) { - return world.getBlockTileEntity(posX, posY, posZ); + return world.getTileEntity(posX, posY, posZ); } } diff --git a/common/buildcraft/core/network/PacketUpdate.java b/common/buildcraft/core/network/PacketUpdate.java index e824c11a..9e06cee3 100644 --- a/common/buildcraft/core/network/PacketUpdate.java +++ b/common/buildcraft/core/network/PacketUpdate.java @@ -1,5 +1,15 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.network; +import io.netty.buffer.ByteBuf; + import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; @@ -32,12 +42,11 @@ public class PacketUpdate extends BuildCraftPacket { public PacketUpdate(int packetId) { this.packetId = packetId; this.isChunkDataPacket = true; - } @Override - public void writeData(DataOutputStream data) throws IOException { - + public void writeData(ByteBuf data) { + data.writeByte(packetId); data.writeInt(posX); data.writeInt(posY); data.writeInt(posZ); @@ -50,16 +59,17 @@ public class PacketUpdate extends BuildCraftPacket { } @Override - public void readData(DataInputStream data) throws IOException { - + public void readData(ByteBuf data) { + packetId = data.readByte(); posX = data.readInt(); posY = data.readInt(); posZ = data.readInt(); payload = PacketPayload.makePayload(); - if (payload != null) + if (payload != null) { payload.readData(data); + } } @Override diff --git a/common/buildcraft/core/network/RPCHandler.java b/common/buildcraft/core/network/RPCHandler.java index 75e0df8f..bb0f8e93 100755 --- a/common/buildcraft/core/network/RPCHandler.java +++ b/common/buildcraft/core/network/RPCHandler.java @@ -1,8 +1,8 @@ package buildcraft.core.network; -import java.io.ByteArrayOutputStream; -import java.io.DataInputStream; -import java.io.DataOutputStream; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; + import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -12,12 +12,13 @@ import java.util.LinkedList; import java.util.Map; import java.util.TreeMap; -import buildcraft.core.DefaultProps; -import buildcraft.core.proxy.CoreProxy; -import buildcraft.transport.Pipe; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.tileentity.TileEntity; +import buildcraft.BuildCraftCore; +import buildcraft.core.DefaultProps; +import buildcraft.core.utils.Utils; +import buildcraft.transport.Pipe; /** * This is a first implementation of a RPC connector, using the regular tile @@ -95,7 +96,7 @@ public class RPCHandler { PacketRPCTile packet = handlers.get (tile.getClass().getName()).createRCPPacket(tile, method, actuals); if (packet != null) { - CoreProxy.proxy.sendToServer(packet.getPacket()); + BuildCraftCore.instance.sendToServer(packet); } } @@ -107,7 +108,7 @@ public class RPCHandler { PacketRPCTile packet = handlers.get (tile.getClass().getName()).createRCPPacket(tile, method, actuals); if (packet != null) { - CoreProxy.proxy.sendToPlayer(player, packet); + BuildCraftCore.instance.sendToPlayer(player, packet); } } @@ -127,13 +128,13 @@ public class RPCHandler { PacketRPCTile packet = handlers.get (tile.getClass().getName()).createRCPPacket(tile, method, actuals); if (packet != null) { - for (Object o : tile.worldObj.playerEntities) { + for (Object o : tile.getWorldObj().playerEntities) { EntityPlayerMP player = (EntityPlayerMP) o; if (Math.abs(player.posX - tile.xCoord) <= maxDistance && Math.abs(player.posY - tile.yCoord) <= maxDistance && Math.abs(player.posZ - tile.zCoord) <= maxDistance) { - CoreProxy.proxy.sendToPlayer(player, packet); + BuildCraftCore.instance.sendToPlayer(player, packet); } } } @@ -147,19 +148,19 @@ public class RPCHandler { PacketRPCPipe packet = handlers.get (pipe.getClass().getName()).createRCPPacket(pipe, method, actuals); if (packet != null) { - for (Object o : pipe.container.worldObj.playerEntities) { + for (Object o : pipe.container.getWorld().playerEntities) { EntityPlayerMP player = (EntityPlayerMP) o; if (Math.abs(player.posX - pipe.container.xCoord) <= maxDistance && Math.abs(player.posY - pipe.container.yCoord) <= maxDistance && Math.abs(player.posZ - pipe.container.zCoord) <= maxDistance) { - CoreProxy.proxy.sendToPlayer(player, packet); + BuildCraftCore.instance.sendToPlayer(player, packet); } } } } - public static void receiveRPC (TileEntity tile, RPCMessageInfo info, DataInputStream data) { + public static void receiveRPC (TileEntity tile, RPCMessageInfo info, ByteBuf data) { if (tile != null) { if (!handlers.containsKey(tile.getClass().getName())) { handlers.put(tile.getClass().getName(), @@ -171,7 +172,7 @@ public class RPCHandler { } } - public static void receiveRPC (Pipe pipe, RPCMessageInfo info, DataInputStream data) { + public static void receiveRPC (Pipe pipe, RPCMessageInfo info, ByteBuf data) { if (pipe != null) { if (!handlers.containsKey(pipe.getClass().getName())) { handlers.put(pipe.getClass().getName(), @@ -184,22 +185,19 @@ public class RPCHandler { } private PacketRPCPipe createRCPPacket (Pipe pipe, String method, Object ... actuals) { - ByteArrayOutputStream bytes = new ByteArrayOutputStream(); - DataOutputStream data = new DataOutputStream(bytes); + ByteBuf data = Unpooled.buffer(); try { TileEntity tile = pipe.container; // In order to save space on message, we assuming dimensions ids // small. Maybe worth using a varint instead - data.writeShort(tile.worldObj.provider.dimensionId); + data.writeShort(tile.getWorldObj().provider.dimensionId); data.writeInt(tile.xCoord); data.writeInt(tile.yCoord); data.writeInt(tile.zCoord); writeParameters(method, data, actuals); - - data.flush(); } catch (IOException e) { e.printStackTrace(); } catch (IllegalArgumentException e) { @@ -210,38 +208,39 @@ public class RPCHandler { e.printStackTrace(); } - return new PacketRPCPipe(bytes.toByteArray()); + byte [] bytes = new byte [data.readableBytes()]; + data.readBytes(bytes); + + return new PacketRPCPipe(bytes); } private PacketRPCTile createRCPPacket (TileEntity tile, String method, Object ... actuals) { - ByteArrayOutputStream bytes = new ByteArrayOutputStream(); - DataOutputStream data = new DataOutputStream(bytes); + ByteBuf data = Unpooled.buffer(); try { // In order to save space on message, we assuming dimensions ids // small. Maybe worth using a varint instead - data.writeShort(tile.worldObj.provider.dimensionId); + data.writeShort(tile.getWorldObj().provider.dimensionId); data.writeInt(tile.xCoord); data.writeInt(tile.yCoord); data.writeInt(tile.zCoord); writeParameters(method, data, actuals); - - data.flush(); } catch (IOException e) { e.printStackTrace(); } catch (IllegalArgumentException e) { - // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { - // TODO Auto-generated catch block e.printStackTrace(); } - return new PacketRPCTile(bytes.toByteArray()); + byte [] bytes = new byte [data.readableBytes()]; + data.readBytes(bytes); + + return new PacketRPCTile(bytes); } - private void writeParameters (String method, DataOutputStream data, Object ... actuals) throws IOException, IllegalArgumentException, IllegalAccessException { + private void writeParameters (String method, ByteBuf data, Object ... actuals) throws IOException, IllegalArgumentException, IllegalAccessException { if (!methodsMap.containsKey(method)) { throw new RuntimeException(method + " is not a callable method of " + getClass().getName()); } @@ -270,14 +269,14 @@ public class RPCHandler { } else if (formals [i].equals(char.class)) { data.writeChar((Character) actuals [i]); } else if (formals [i].equals(String.class)) { - data.writeUTF((String) actuals [i]); + Utils.writeUTF(data, (String) actuals [i]); } else { m.mappings [i].setData(actuals [i], data); } } } - private void internalRpcReceive (Object o, RPCMessageInfo info, DataInputStream data) { + private void internalRpcReceive (Object o, RPCMessageInfo info, ByteBuf data) { try { short methodIndex = data.readShort(); @@ -296,7 +295,7 @@ public class RPCHandler { } else if (formals [i].equals(char.class)) { actuals [i] = data.readChar(); } else if (formals [i].equals(String.class)) { - actuals [i] = data.readUTF(); + actuals [i] = Utils.readUTF(data); } else { actuals [i] = m.mappings [i].updateFromData(actuals [i], data); } @@ -307,8 +306,6 @@ public class RPCHandler { } m.method.invoke(o, actuals); - } catch (IOException e) { - e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (IllegalArgumentException e) { diff --git a/common/buildcraft/core/network/TilePacketWrapper.java b/common/buildcraft/core/network/TilePacketWrapper.java index 750aa642..624ee624 100644 --- a/common/buildcraft/core/network/TilePacketWrapper.java +++ b/common/buildcraft/core/network/TilePacketWrapper.java @@ -1,14 +1,15 @@ /** - * Copyright (c) SpaceToad, 2011 + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.core.network; +import io.netty.buffer.ByteBuf; + import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.DataInputStream; @@ -37,7 +38,7 @@ public class TilePacketWrapper { public PacketPayload toPayload(final TileEntity tile) { return new PacketPayloadStream(new PacketPayloadStream.StreamWriter() { @Override - public void writeData(DataOutputStream data) throws IOException { + public void writeData(ByteBuf data) { data.writeInt(tile.xCoord); data.writeInt(tile.yCoord); data.writeInt(tile.zCoord); @@ -66,7 +67,7 @@ public class TilePacketWrapper { public PacketPayload toPayload(final int x, final int y, final int z, final Object[] obj) { return new PacketPayloadStream(new PacketPayloadStream.StreamWriter() { @Override - public void writeData(DataOutputStream data) throws IOException { + public void writeData(ByteBuf data) { data.writeInt(x); data.writeInt(y); data.writeInt(z); @@ -89,7 +90,7 @@ public class TilePacketWrapper { public void fromPayload(TileEntity tile, PacketPayloadStream packet) { try { - DataInputStream data = packet.stream; + ByteBuf data = packet.stream; data.readInt(); data.readInt(); @@ -107,7 +108,7 @@ public class TilePacketWrapper { public void fromPayload(Object[] obj, PacketPayloadStream packet) { try { - DataInputStream data = packet.stream; + ByteBuf data = packet.stream; data.readInt(); data.readInt(); diff --git a/common/buildcraft/core/proxy/CoreProxy.java b/common/buildcraft/core/proxy/CoreProxy.java index 64323684..a6856327 100644 --- a/common/buildcraft/core/proxy/CoreProxy.java +++ b/common/buildcraft/core/proxy/CoreProxy.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.core.proxy; @@ -14,9 +15,13 @@ import buildcraft.core.network.BuildCraftPacket; import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.registry.GameRegistry; + import java.io.File; import java.util.List; import java.util.Random; + +import com.mojang.authlib.GameProfile; + import net.minecraft.block.Block; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; @@ -28,14 +33,20 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.CraftingManager; -import net.minecraft.network.packet.Packet; +import net.minecraft.network.Packet; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ChatMessageComponent; import net.minecraft.util.ChunkCoordinates; +import net.minecraft.util.IChatComponent; import net.minecraft.world.World; import net.minecraftforge.oredict.ShapedOreRecipe; import net.minecraftforge.oredict.ShapelessOreRecipe; + +/** + * This class comes from the old times where there were two Minecrafts + * codebases, one client and one server. We should slowly aim at removing it. + */ +@Deprecated public class CoreProxy { @SidedProxy(clientSide = "buildcraft.core.proxy.CoreProxyClient", serverSide = "buildcraft.core.proxy.CoreProxy") @@ -54,18 +65,6 @@ public class CoreProxy { return null; } - /** - * Return true if this world is holding the actual game simulation, that is - * for example if this is the server world. - */ - public boolean isSimulating(World world) { - return !world.isRemote; - } - - public boolean isRenderWorld(World world) { - return world.isRemote; - } - public String getCurrentLanguage() { return null; } @@ -77,7 +76,7 @@ public class CoreProxy { /* WRAPPER */ @SuppressWarnings("rawtypes") - public void feedSubBlocks(int id, CreativeTabs tab, List itemList) { + public void feedSubBlocks(Block block, CreativeTabs tab, List itemList) { } /* LOCALIZATION */ @@ -134,34 +133,10 @@ public class CoreProxy { //GameRegistry.addShapelessRecipe(result, recipe); } - public void sendToPlayers(Packet packet, World world, int x, int y, int z, int maxDistance) { - if (packet != null) { - for (int j = 0; j < world.playerEntities.size(); j++) { - EntityPlayerMP player = (EntityPlayerMP) world.playerEntities.get(j); - - if (Math.abs(player.posX - x) <= maxDistance && Math.abs(player.posY - y) <= maxDistance && Math.abs(player.posZ - z) <= maxDistance) { - player.playerNetServerHandler.sendPacketToPlayer(packet); - } - } - } - } - - public void sendToPlayer(EntityPlayer entityplayer, BuildCraftPacket packet) { - EntityPlayerMP player = (EntityPlayerMP) entityplayer; - player.playerNetServerHandler.sendPacketToPlayer(packet.getPacket()); - } - - public void sendToServer(Packet packet) { - } - public int addCustomTexture(String pathToTexture) { return 0; } - public void TakenFromCrafting(EntityPlayer thePlayer, ItemStack itemstack, IInventory craftMatrix) { - GameRegistry.onItemCrafted(thePlayer, itemstack, craftMatrix); - } - public Random createNewRandom(World world) { return new Random(world.getSeed()); } @@ -174,9 +149,9 @@ public class CoreProxy { } private EntityPlayer createNewPlayer(World world) { - EntityPlayer player = new EntityPlayer(world, "[BuildCraft]") { + EntityPlayer player = new EntityPlayer(world, new GameProfile (null, "[BuildCraft]")) { @Override - public void sendChatToPlayer(ChatMessageComponent var1) { + public void addChatMessage(IChatComponent var1) { } @Override @@ -193,11 +168,11 @@ public class CoreProxy { } private EntityPlayer createNewPlayer(World world, int x, int y, int z) { - EntityPlayer player = new EntityPlayer(world, "[BuildCraft]") { + EntityPlayer player = new EntityPlayer(world, new GameProfile (null, "[BuildCraft]")) { @Override - public void sendChatToPlayer(ChatMessageComponent var1) { + public void addChatMessage(IChatComponent var1) { } - + @Override public boolean canCommandSenderUseCommand(int var1, String var2) { return false; @@ -206,7 +181,7 @@ public class CoreProxy { @Override public ChunkCoordinates getPlayerCoordinates() { return null; - } + } }; player.posX = x; player.posY = y; @@ -218,7 +193,7 @@ public class CoreProxy { if (CoreProxy.buildCraftPlayer == null) { CoreProxy.buildCraftPlayer = createNewPlayer(world); } else { - CoreProxy.buildCraftPlayer.worldObj = world; + CoreProxy.buildCraftPlayer.worldObj= world; } return CoreProxy.buildCraftPlayer; diff --git a/common/buildcraft/core/proxy/CoreProxyClient.java b/common/buildcraft/core/proxy/CoreProxyClient.java index 251bc19c..71b348a2 100644 --- a/common/buildcraft/core/proxy/CoreProxyClient.java +++ b/common/buildcraft/core/proxy/CoreProxyClient.java @@ -1,14 +1,29 @@ /** - * Copyright (c) SpaceToad, 2011 + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.core.proxy; +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.multiplayer.WorldClient; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ChunkCoordinates; +import net.minecraft.util.IChatComponent; +import net.minecraft.world.World; +import net.minecraftforge.client.MinecraftForgeClient; import buildcraft.BuildCraftCore; import buildcraft.api.core.LaserKind; import buildcraft.core.EntityBlock; @@ -22,32 +37,16 @@ import buildcraft.core.render.RenderLaser; import buildcraft.core.render.RenderRobot; import buildcraft.core.render.RenderingEntityBlocks; import buildcraft.core.render.RenderingMarkers; -import buildcraft.core.render.RenderingOil; import buildcraft.core.robots.EntityRobot; import buildcraft.core.robots.EntityRobotBuilder; import buildcraft.transport.render.TileEntityPickupFX; + +import com.mojang.authlib.GameProfile; + import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; -import java.util.List; - -import net.minecraft.block.Block; -import net.minecraft.client.Minecraft; -import net.minecraft.client.multiplayer.WorldClient; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.network.packet.Packet; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ChatMessageComponent; -import net.minecraft.util.ChunkCoordinates; -import net.minecraft.world.World; -import net.minecraftforge.client.MinecraftForgeClient; - public class CoreProxyClient extends CoreProxy { /* INSTANCES */ @@ -66,19 +65,19 @@ public class CoreProxyClient extends CoreProxy { public void removeEntity(Entity entity) { super.removeEntity(entity); - if (isRenderWorld(entity.worldObj)) { - ((WorldClient) entity.worldObj).removeEntityFromWorld(entity.entityId); + if (entity.worldObj.isRemote) { + ((WorldClient) entity.worldObj).removeEntityFromWorld(entity.getEntityId()); } } /* WRAPPER */ @SuppressWarnings("rawtypes") @Override - public void feedSubBlocks(int id, CreativeTabs tab, List itemList) { - if (Block.blocksList[id] == null) + public void feedSubBlocks(Block block, CreativeTabs tab, List itemList) { + if (block == null) return; - Block.blocksList[id].getSubBlocks(id, tab, itemList); + block.getSubBlocks(Item.getItemFromBlock(block), tab, itemList); } /* LOCALIZATION */ @@ -99,10 +98,10 @@ public class CoreProxyClient extends CoreProxy { @Override public String getItemDisplayName(ItemStack stack) { - if (Item.itemsList[stack.itemID] == null) + if (stack.getItem() == null) return ""; - return Item.itemsList[stack.itemID].getItemDisplayName(stack); + return stack.getDisplayName(); } /* GFX */ @@ -116,16 +115,14 @@ public class CoreProxyClient extends CoreProxy { BuildCraftCore.blockByEntityModel = RenderingRegistry.getNextAvailableRenderId(); BuildCraftCore.legacyPipeModel = RenderingRegistry.getNextAvailableRenderId(); BuildCraftCore.markerModel = RenderingRegistry.getNextAvailableRenderId(); - BuildCraftCore.oilModel = RenderingRegistry.getNextAvailableRenderId(); RenderingRegistry.registerBlockHandler(new RenderingEntityBlocks()); RenderingRegistry.registerBlockHandler(BuildCraftCore.legacyPipeModel, new RenderingEntityBlocks()); - RenderingRegistry.registerBlockHandler(new RenderingOil()); RenderingRegistry.registerBlockHandler(new RenderingMarkers()); - MinecraftForgeClient.registerItemRenderer(BuildCraftCore.robotBaseItem.itemID, new RenderRobot()); - MinecraftForgeClient.registerItemRenderer(BuildCraftCore.robotBuilderItem.itemID, new RenderRobot()); - MinecraftForgeClient.registerItemRenderer(BuildCraftCore.robotPickerItem.itemID, new RenderRobot()); + MinecraftForgeClient.registerItemRenderer(BuildCraftCore.robotBaseItem, new RenderRobot()); + MinecraftForgeClient.registerItemRenderer(BuildCraftCore.robotBuilderItem, new RenderRobot()); + MinecraftForgeClient.registerItemRenderer(BuildCraftCore.robotPickerItem, new RenderRobot()); } @Override @@ -138,22 +135,16 @@ public class CoreProxyClient extends CoreProxy { RenderingRegistry.registerEntityRenderingHandler(EntityFrame.class, new RenderFrame()); } - /* NETWORKING */ - @Override - public void sendToServer(Packet packet) { - FMLClientHandler.instance().getClient().getNetHandler().addToSendQueue(packet); - } - /* BUILDCRAFT PLAYER */ @Override public String playerName() { - return FMLClientHandler.instance().getClient().thePlayer.username; + return FMLClientHandler.instance().getClient().thePlayer.getDisplayName(); } private EntityPlayer createNewPlayer(World world) { - EntityPlayer player = new EntityPlayer(world, "[BuildCraft]") { + EntityPlayer player = new EntityPlayer(world, new GameProfile(null, "[BuildCraft]")) { @Override - public void sendChatToPlayer(ChatMessageComponent var1) { + public void addChatMessage(IChatComponent var1) { } @Override @@ -166,6 +157,7 @@ public class CoreProxyClient extends CoreProxy { return null; } }; + return player; } diff --git a/common/buildcraft/core/recipes/AssemblyRecipeManager.java b/common/buildcraft/core/recipes/AssemblyRecipeManager.java index a500d339..a86de95f 100644 --- a/common/buildcraft/core/recipes/AssemblyRecipeManager.java +++ b/common/buildcraft/core/recipes/AssemblyRecipeManager.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.recipes; import buildcraft.api.recipes.IAssemblyRecipeManager; @@ -12,7 +20,7 @@ import net.minecraft.block.Block; import net.minecraft.inventory.IInventory; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.oredict.OreDictionary; public class AssemblyRecipeManager implements IAssemblyRecipeManager { diff --git a/common/buildcraft/core/recipes/IntegrationRecipeManager.java b/common/buildcraft/core/recipes/IntegrationRecipeManager.java index f2faa0d6..6c1791af 100644 --- a/common/buildcraft/core/recipes/IntegrationRecipeManager.java +++ b/common/buildcraft/core/recipes/IntegrationRecipeManager.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.recipes; import buildcraft.api.recipes.IIntegrationRecipeManager; diff --git a/common/buildcraft/core/recipes/RefineryRecipeManager.java b/common/buildcraft/core/recipes/RefineryRecipeManager.java index 39278c3f..5552f66a 100644 --- a/common/buildcraft/core/recipes/RefineryRecipeManager.java +++ b/common/buildcraft/core/recipes/RefineryRecipeManager.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.core.recipes; diff --git a/common/buildcraft/core/render/FluidRenderer.java b/common/buildcraft/core/render/FluidRenderer.java index 2b32c7be..a35c0070 100644 --- a/common/buildcraft/core/render/FluidRenderer.java +++ b/common/buildcraft/core/render/FluidRenderer.java @@ -1,30 +1,31 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.core.render; import buildcraft.core.render.RenderEntityBlock.RenderInfo; + import java.util.HashMap; import java.util.Map; + import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.GLAllocation; import net.minecraft.client.renderer.texture.TextureMap; -import net.minecraft.util.Icon; +import net.minecraft.init.Blocks; +import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; + import org.lwjgl.opengl.GL11; -/** - * - * @author CovertJaguar - */ public class FluidRenderer { private static final ResourceLocation BLOCK_TEXTURE = TextureMap.locationBlocksTexture; @@ -33,18 +34,18 @@ public class FluidRenderer { public static final int DISPLAY_STAGES = 100; private static final RenderInfo liquidBlock = new RenderInfo(); - public static Icon getFluidTexture(FluidStack fluidStack, boolean flowing) { + public static IIcon getFluidTexture(FluidStack fluidStack, boolean flowing) { if (fluidStack == null) { return null; } return getFluidTexture(fluidStack.getFluid(), flowing); } - public static Icon getFluidTexture(Fluid fluid, boolean flowing) { + public static IIcon getFluidTexture(Fluid fluid, boolean flowing) { if (fluid == null) { return null; } - Icon icon = flowing ? fluid.getFlowingIcon() : fluid.getStillIcon(); + IIcon icon = flowing ? fluid.getFlowingIcon() : fluid.getStillIcon(); if (icon == null) { icon = ((TextureMap) Minecraft.getMinecraft().getTextureManager().getTexture(TextureMap.locationBlocksTexture)).getAtlasSprite("missingno"); } @@ -85,11 +86,11 @@ public class FluidRenderer { diplayLists = new int[DISPLAY_STAGES]; - if (fluid.getBlockID() > 0) { - liquidBlock.baseBlock = Block.blocksList[fluid.getBlockID()]; + if (fluid.getBlock() != null) { + liquidBlock.baseBlock = fluid.getBlock(); liquidBlock.texture = getFluidTexture(fluidStack, flowing); } else { - liquidBlock.baseBlock = Block.waterStill; + liquidBlock.baseBlock = Blocks.water; liquidBlock.texture = getFluidTexture(fluidStack, flowing); } diff --git a/common/buildcraft/core/render/RenderEnergyLaser.java b/common/buildcraft/core/render/RenderEnergyLaser.java index a7547155..5793605d 100644 --- a/common/buildcraft/core/render/RenderEnergyLaser.java +++ b/common/buildcraft/core/render/RenderEnergyLaser.java @@ -1,12 +1,11 @@ /** - * Copyright (c) SpaceToad, 2011 + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.core.render; import net.minecraft.client.model.ModelRenderer; diff --git a/common/buildcraft/core/render/RenderEntityBlock.java b/common/buildcraft/core/render/RenderEntityBlock.java index 11955ee3..8e169f6f 100644 --- a/common/buildcraft/core/render/RenderEntityBlock.java +++ b/common/buildcraft/core/render/RenderEntityBlock.java @@ -1,28 +1,35 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.core.render; import buildcraft.core.EntityBlock; + import java.util.Arrays; + import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.entity.Render; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.entity.Entity; -import net.minecraft.util.Icon; +import net.minecraft.init.Blocks; +import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; + import org.lwjgl.opengl.GL11; public class RenderEntityBlock extends Render { public static RenderEntityBlock INSTANCE = new RenderEntityBlock(); + protected RenderBlocks renderBlocks; @Override protected ResourceLocation getEntityTexture(Entity entity) { @@ -37,9 +44,9 @@ public class RenderEntityBlock extends Render { public double maxX; public double maxY; public double maxZ; - public Block baseBlock = Block.sand; - public Icon texture = null; - public Icon[] textureArray = null; + public Block baseBlock = Blocks.sand; + public IIcon texture = null; + public IIcon[] textureArray = null; public boolean[] renderSide = new boolean[6]; public float light = -1f; public int brightness = -1; @@ -48,7 +55,7 @@ public class RenderEntityBlock extends Render { setRenderAllSides(); } - public RenderInfo(Block template, Icon[] texture) { + public RenderInfo(Block template, IIcon[] texture) { this(); this.baseBlock = template; this.textureArray = texture; @@ -60,7 +67,7 @@ public class RenderEntityBlock extends Render { } public float getBlockBrightness(IBlockAccess iblockaccess, int i, int j, int k) { - return baseBlock.getBlockBrightness(iblockaccess, i, j, k); + return baseBlock.getMixedBrightnessForBlock(iblockaccess, i, j, k); } public final void setBounds(double minX, double minY, double minZ, double maxX, double maxY, double maxZ) { @@ -103,7 +110,7 @@ public class RenderEntityBlock extends Render { maxZ = 1 - temp; } - public Icon getBlockTextureFromSide(int i) { + public IIcon getBlockTextureFromSide(int i) { if (texture != null) return texture; if (textureArray == null || textureArray.length == 0) @@ -117,6 +124,7 @@ public class RenderEntityBlock extends Render { } private RenderEntityBlock() { + renderBlocks = field_147909_c; } @Override @@ -188,13 +196,15 @@ public class RenderEntityBlock extends Render { if (blockAccess == null) doLight = false; - if (doTessellating && !tessellator.isDrawing) + // TODO: needs to cancel the test because the variable is now private... May need to + // duplicate the tessellator code. + //if (doTessellating && !tessellator.isDrawing) tessellator.startDrawingQuads(); float light = 0; if (doLight) { if (info.light < 0) { - light = info.baseBlock.getBlockBrightness(blockAccess, (int) lightX, (int) lightY, (int) lightZ); + light = info.baseBlock.getMixedBrightnessForBlock(blockAccess, (int) lightX, (int) lightY, (int) lightZ); light = light + ((1.0f - light) * 0.4f); } else light = info.light; @@ -246,96 +256,9 @@ public class RenderEntityBlock extends Render { if (info.renderSide[5]) renderBlocks.renderFaceXPos(info.baseBlock, x, y, z, info.getBlockTextureFromSide(5)); - if (doTessellating && tessellator.isDrawing) + // TODO: needs to cancel the test because the variable is now private... May need to + // duplicate the tessellator code. + //if (doTessellating && tessellator.isDrawing) tessellator.draw(); } -// -// public void renderBlock(RenderInfo block, IBlockAccess blockAccess, int i, int j, int k, boolean doLight, boolean doTessellating) { -// float f = 0.5F; -// float f1 = 1.0F; -// float f2 = 0.8F; -// float f3 = 0.6F; -// -// renderBlocks.renderMaxX = block.maxX; -// renderBlocks.renderMinX = block.minX; -// renderBlocks.renderMaxY = block.maxY; -// renderBlocks.renderMinY = block.minY; -// renderBlocks.renderMaxZ = block.maxZ; -// renderBlocks.renderMinZ = block.minZ; -// renderBlocks.enableAO = false; -// -// -// Tessellator tessellator = Tessellator.instance; -// -// if (doTessellating) { -// tessellator.startDrawingQuads(); -// } -// -// float f4 = 0, f5 = 0; -// -// if (doLight) { -// f4 = block.getBlockBrightness(blockAccess, i, j, k); -// f5 = block.getBlockBrightness(blockAccess, i, j, k); -// if (f5 < f4) { -// f5 = f4; -// } -// tessellator.setColorOpaque_F(f * f5, f * f5, f * f5); -// } -// -// renderBlocks.renderFaceYNeg(null, 0, 0, 0, block.getBlockTextureFromSide(0)); -// -// if (doLight) { -// f5 = block.getBlockBrightness(blockAccess, i, j, k); -// if (f5 < f4) { -// f5 = f4; -// } -// tessellator.setColorOpaque_F(f1 * f5, f1 * f5, f1 * f5); -// } -// -// renderBlocks.renderFaceYPos(null, 0, 0, 0, block.getBlockTextureFromSide(1)); -// -// if (doLight) { -// f5 = block.getBlockBrightness(blockAccess, i, j, k); -// if (f5 < f4) { -// f5 = f4; -// } -// tessellator.setColorOpaque_F(f2 * f5, f2 * f5, f2 * f5); -// } -// -// renderBlocks.renderFaceZNeg(null, 0, 0, 0, block.getBlockTextureFromSide(2)); -// -// if (doLight) { -// f5 = block.getBlockBrightness(blockAccess, i, j, k); -// if (f5 < f4) { -// f5 = f4; -// } -// tessellator.setColorOpaque_F(f2 * f5, f2 * f5, f2 * f5); -// } -// -// renderBlocks.renderFaceZPos(null, 0, 0, 0, block.getBlockTextureFromSide(3)); -// -// if (doLight) { -// f5 = block.getBlockBrightness(blockAccess, i, j, k); -// if (f5 < f4) { -// f5 = f4; -// } -// tessellator.setColorOpaque_F(f3 * f5, f3 * f5, f3 * f5); -// } -// -// renderBlocks.renderFaceXNeg(null, 0, 0, 0, block.getBlockTextureFromSide(4)); -// -// if (doLight) { -// f5 = block.getBlockBrightness(blockAccess, i, j, k); -// if (f5 < f4) { -// f5 = f4; -// } -// tessellator.setColorOpaque_F(f3 * f5, f3 * f5, f3 * f5); -// } -// -// renderBlocks.renderFaceXPos(null, 0, 0, 0, block.getBlockTextureFromSide(5)); -// -// if (doTessellating) { -// tessellator.draw(); -// } -// } } diff --git a/common/buildcraft/core/render/RenderLaser.java b/common/buildcraft/core/render/RenderLaser.java index c5e9242a..63def2af 100644 --- a/common/buildcraft/core/render/RenderLaser.java +++ b/common/buildcraft/core/render/RenderLaser.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.render; import java.util.Date; diff --git a/common/buildcraft/core/render/RenderRobot.java b/common/buildcraft/core/render/RenderRobot.java index 5fe99f96..411d0d36 100644 --- a/common/buildcraft/core/render/RenderRobot.java +++ b/common/buildcraft/core/render/RenderRobot.java @@ -8,10 +8,6 @@ */ package buildcraft.core.render; -import buildcraft.BuildCraftCore; -import buildcraft.core.DefaultProps; -import buildcraft.core.EntityLaser; -import buildcraft.core.robots.EntityRobot; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.renderer.RenderBlocks; @@ -24,6 +20,11 @@ import net.minecraftforge.client.IItemRenderer; import org.lwjgl.opengl.GL11; +import buildcraft.BuildCraftCore; +import buildcraft.core.DefaultProps; +import buildcraft.core.EntityLaser; +import buildcraft.core.robots.EntityRobot; + public class RenderRobot extends Render implements IItemRenderer { public static final ResourceLocation TEXTURE_BASE = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_ENTITIES + "/robot_base.png"); @@ -107,11 +108,11 @@ public class RenderRobot extends Render implements IItemRenderer { // FIXME: Texture localisation should be factorized between items and // entities. - if (item.itemID == BuildCraftCore.robotBaseItem.itemID) { + if (item.getItem() == BuildCraftCore.robotBaseItem) { RenderManager.instance.renderEngine.bindTexture(TEXTURE_BASE); - } else if (item.itemID == BuildCraftCore.robotBuilderItem.itemID) { + } else if (item.getItem() == BuildCraftCore.robotBuilderItem) { RenderManager.instance.renderEngine.bindTexture(TEXTURE_BUILDER); - } else if (item.itemID == BuildCraftCore.robotPickerItem.itemID) { + } else if (item.getItem() == BuildCraftCore.robotPickerItem) { RenderManager.instance.renderEngine.bindTexture(TEXTURE_PICKER); } diff --git a/common/buildcraft/core/render/RenderUtils.java b/common/buildcraft/core/render/RenderUtils.java index 62b88d4c..dedad7ae 100644 --- a/common/buildcraft/core/render/RenderUtils.java +++ b/common/buildcraft/core/render/RenderUtils.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.render; import org.lwjgl.opengl.GL11; diff --git a/common/buildcraft/core/render/RenderVoid.java b/common/buildcraft/core/render/RenderVoid.java index 842ed879..7960f227 100644 --- a/common/buildcraft/core/render/RenderVoid.java +++ b/common/buildcraft/core/render/RenderVoid.java @@ -1,12 +1,11 @@ /** - * Copyright (c) SpaceToad, 2011 + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.core.render; import net.minecraft.client.renderer.entity.Render; diff --git a/common/buildcraft/core/render/RenderingEntityBlocks.java b/common/buildcraft/core/render/RenderingEntityBlocks.java index cc4a8bc2..223146c1 100644 --- a/common/buildcraft/core/render/RenderingEntityBlocks.java +++ b/common/buildcraft/core/render/RenderingEntityBlocks.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.render; import buildcraft.BuildCraftCore; @@ -106,7 +114,7 @@ public class RenderingEntityBlocks implements ISimpleBlockRenderingHandler { } @Override - public boolean shouldRender3DInInventory() { + public boolean shouldRender3DInInventory(int modelId) { return true; } @@ -162,4 +170,6 @@ public class RenderingEntityBlocks implements ISimpleBlockRenderingHandler { block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); } + + } diff --git a/common/buildcraft/core/render/RenderingMarkers.java b/common/buildcraft/core/render/RenderingMarkers.java index 5b92c7ba..704429ec 100644 --- a/common/buildcraft/core/render/RenderingMarkers.java +++ b/common/buildcraft/core/render/RenderingMarkers.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.render; import buildcraft.BuildCraftCore; @@ -5,7 +13,7 @@ import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; -import net.minecraft.util.Icon; +import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; public class RenderingMarkers implements ISimpleBlockRenderingHandler { @@ -22,8 +30,8 @@ public class RenderingMarkers implements ISimpleBlockRenderingHandler { public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { Tessellator tessellator = Tessellator.instance; - float f = block.getBlockBrightness(world, x, y, z); - if (Block.lightValue[block.blockID] > 0) { + float f = block.getMixedBrightnessForBlock(world, x, y, z); + if (block.getLightValue() > 0) { f = 1.0F; } tessellator.setColorOpaque_F(f, f, f); @@ -33,7 +41,7 @@ public class RenderingMarkers implements ISimpleBlockRenderingHandler { } @Override - public boolean shouldRender3DInInventory() { + public boolean shouldRender3DInInventory(int modelId) { return false; } @@ -125,7 +133,7 @@ public class RenderingMarkers implements ISimpleBlockRenderingHandler { int yCoord = (int) y; int zCoord = (int) z; - Icon i = block.getBlockTexture(iblockaccess, xCoord, yCoord, zCoord, 1); + IIcon i = block.getIcon(iblockaccess, xCoord, yCoord, zCoord, 1); int m = metaToOld[meta]; x += 0.5D; @@ -173,9 +181,7 @@ public class RenderingMarkers implements ISimpleBlockRenderingHandler { tessellator.addVertexWithUV(x - s, y + 0.5 - s, z - s, minU, minV); } - i = block.getBlockTexture(iblockaccess, xCoord, yCoord, zCoord, 0); - - + i = block.getIcon(iblockaccess, xCoord, yCoord, zCoord, 0); minU = i.getMinU(); maxU = i.getMaxU(); @@ -228,5 +234,4 @@ public class RenderingMarkers implements ISimpleBlockRenderingHandler { face[j][3] = tmp; } } - } diff --git a/common/buildcraft/core/render/RenderingOil.java b/common/buildcraft/core/render/RenderingOil.java deleted file mode 100644 index 0d771be7..00000000 --- a/common/buildcraft/core/render/RenderingOil.java +++ /dev/null @@ -1,35 +0,0 @@ -package buildcraft.core.render; - -import buildcraft.BuildCraftCore; -import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; -import net.minecraft.block.Block; -import net.minecraft.client.renderer.RenderBlocks; -import net.minecraft.world.IBlockAccess; - -public class RenderingOil implements ISimpleBlockRenderingHandler { - - @Override - public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { - } - - @Override - public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { - - if (block.getRenderType() != BuildCraftCore.oilModel) - return true; - - renderer.renderBlockFluids(block, x, y, z); - return true; - } - - @Override - public boolean shouldRender3DInInventory() { - return false; - } - - @Override - public int getRenderId() { - return BuildCraftCore.oilModel; - } - -} diff --git a/common/buildcraft/core/robots/AIMoveAround.java b/common/buildcraft/core/robots/AIMoveAround.java index 8b85c75b..ef7069c2 100755 --- a/common/buildcraft/core/robots/AIMoveAround.java +++ b/common/buildcraft/core/robots/AIMoveAround.java @@ -9,7 +9,7 @@ package buildcraft.core.robots; import net.minecraft.block.Block; -import buildcraft.core.proxy.CoreProxy; +import net.minecraft.init.Blocks; public class AIMoveAround extends AIBase { @@ -27,7 +27,7 @@ public class AIMoveAround extends AIBase { @Override public void update(EntityRobot robot) { - if (!CoreProxy.proxy.isSimulating(robot.worldObj)) { + if (robot.worldObj.isRemote) { return; } @@ -47,7 +47,7 @@ public class AIMoveAround extends AIBase { float testY = aroundY + robot.worldObj.rand.nextFloat() * 5F; float testZ = aroundZ + robot.worldObj.rand.nextFloat() * 10F - 5F; - int blockId = robot.worldObj.getBlockId((int) testX, (int) testY, + Block block = robot.worldObj.getBlock((int) testX, (int) testY, (int) testZ); // We set a destination. If it's wrong, we try a new one. @@ -56,9 +56,7 @@ public class AIMoveAround extends AIBase { setDestination(robot, testX, testY, testZ); - if (Block.blocksList[blockId] == null - || Block.blocksList[blockId].isAirBlock(robot.worldObj, - (int) testX, (int) testY, (int) testZ)) { + if (block == Blocks.air) { return; } } diff --git a/common/buildcraft/core/robots/AIReturnToDock.java b/common/buildcraft/core/robots/AIReturnToDock.java index 33aa605f..c6ea3201 100755 --- a/common/buildcraft/core/robots/AIReturnToDock.java +++ b/common/buildcraft/core/robots/AIReturnToDock.java @@ -8,7 +8,6 @@ */ package buildcraft.core.robots; -import buildcraft.core.proxy.CoreProxy; public class AIReturnToDock extends AIBase { @@ -18,7 +17,7 @@ public class AIReturnToDock extends AIBase { @Override public void update(EntityRobot robot) { - if (!CoreProxy.proxy.isSimulating(robot.worldObj)) { + if (robot.worldObj.isRemote) { return; } diff --git a/common/buildcraft/core/robots/EntityRobot.java b/common/buildcraft/core/robots/EntityRobot.java index c0f242d5..c0e21d1c 100755 --- a/common/buildcraft/core/robots/EntityRobot.java +++ b/common/buildcraft/core/robots/EntityRobot.java @@ -8,24 +8,22 @@ */ package buildcraft.core.robots; -import buildcraft.builders.blueprints.IBlueprintBuilderAgent; -import buildcraft.core.DefaultProps; -import buildcraft.core.LaserData; -import buildcraft.core.proxy.CoreProxy; -import buildcraft.transport.TileGenericPipe; - -import com.google.common.io.ByteArrayDataInput; -import com.google.common.io.ByteArrayDataOutput; - +import io.netty.buffer.ByteBuf; import net.minecraft.block.Block; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; +import buildcraft.builders.blueprints.IBlueprintBuilderAgent; +import buildcraft.core.DefaultProps; +import buildcraft.core.LaserData; +import buildcraft.core.proxy.CoreProxy; +import buildcraft.transport.TileGenericPipe; import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData; public class EntityRobot extends EntityLivingBase implements @@ -126,12 +124,12 @@ public class EntityRobot extends EntityLivingBase implements @Override public void onUpdate() { - if (CoreProxy.proxy.isSimulating(worldObj) && needsUpdate) { + if (!worldObj.isRemote && needsUpdate) { updateDataServer(); needsUpdate = false; } - if (CoreProxy.proxy.isRenderWorld(worldObj)) { + if (worldObj.isRemote) { updateDataClient(); } @@ -199,12 +197,12 @@ public class EntityRobot extends EntityLivingBase implements } @Override - public void writeSpawnData(ByteArrayDataOutput data) { + public void writeSpawnData(ByteBuf data) { } @Override - public void readSpawnData(ByteArrayDataInput data) { + public void readSpawnData(ByteBuf data) { init(); } @@ -214,16 +212,9 @@ public class EntityRobot extends EntityLivingBase implements return null; } - @Override - public ItemStack getCurrentItemOrArmor(int i) { - // TODO Auto-generated method stub - return null; - } - @Override public void setCurrentItemOrArmor(int i, ItemStack itemstack) { // TODO Auto-generated method stub - } @Override @@ -253,14 +244,14 @@ public class EntityRobot extends EntityLivingBase implements */ @Override public boolean breakBlock (int x, int y, int z) { - Block block = Block.blocksList[worldObj.getBlockId(x, y, z)]; + Block block = worldObj.getBlock(x, y, z); if (block != null) { curBlockDamage += 1 / (block.getBlockHardness(worldObj, x,y, z) * 20); } if (block != null && curBlockDamage < 1) { - worldObj.destroyBlockInWorldPartially(entityId, x, y, z, + worldObj.destroyBlockInWorldPartially(getEntityId(), x, y, z, (int) (this.curBlockDamage * 10.0F) - 1); setLaserDestination(x + 0.5F, y + 0.5F, z + 0.5F); @@ -268,8 +259,8 @@ public class EntityRobot extends EntityLivingBase implements return false; } else { - worldObj.destroyBlockInWorldPartially(entityId, x, y, z, -1); - worldObj.setBlock(x, y, z, 0); + worldObj.destroyBlockInWorldPartially(getEntityId(), x, y, z, -1); + worldObj.setBlock(x, y, z, Blocks.air); curBlockDamage = 0; hideLaser(); @@ -281,10 +272,10 @@ public class EntityRobot extends EntityLivingBase implements @Override public boolean buildBlock(int x, int y, int z) { if (buildingStack == null) { - if (worldObj.getBlockId(x, y, z) != 0) { + if (worldObj.getBlock(x, y, z) != Blocks.air) { breakBlock(x, y, z); } else { - setLaserDestination((float) x + 0.5F, (float) y + 0.5F, (float) z + 0.5F); + setLaserDestination(x + 0.5F, y + 0.5F, z + 0.5F); showLaser(); buildingStack = getInventory().decrStackSize(0, 1); @@ -323,13 +314,13 @@ public class EntityRobot extends EntityLivingBase implements @Override public ItemStack getStackInSlot(int i) { // Fake inventory filled with bricks - return new ItemStack(Block.brick); + return new ItemStack(Blocks.brick_block); } @Override public ItemStack decrStackSize(int i, int j) { // Fake inventory filled with bricks - return new ItemStack(Block.brick); + return new ItemStack(Blocks.brick_block); } @Override @@ -344,48 +335,18 @@ public class EntityRobot extends EntityLivingBase implements } - @Override - public String getInvName() { - // TODO Auto-generated method stub - return null; - } - - @Override - public boolean isInvNameLocalized() { - // TODO Auto-generated method stub - return false; - } - @Override public int getInventoryStackLimit() { // TODO Auto-generated method stub return 0; } - @Override - public void onInventoryChanged() { - // TODO Auto-generated method stub - - } - @Override public boolean isUseableByPlayer(EntityPlayer entityplayer) { // TODO Auto-generated method stub return false; } - @Override - public void openChest() { - // TODO Auto-generated method stub - - } - - @Override - public void closeChest() { - // TODO Auto-generated method stub - - } - @Override public boolean isItemValidForSlot(int i, ItemStack itemstack) { // TODO Auto-generated method stub @@ -409,4 +370,40 @@ public class EntityRobot extends EntityLivingBase implements dockingStation.z = tile.zCoord; dockingStation.side = side; } + + @Override + public String getInventoryName() { + // TODO Auto-generated method stub + return null; + } + + @Override + public boolean hasCustomInventoryName() { + // TODO Auto-generated method stub + return false; + } + + @Override + public void markDirty() { + // TODO Auto-generated method stub + + } + + @Override + public void openInventory() { + // TODO Auto-generated method stub + + } + + @Override + public void closeInventory() { + // TODO Auto-generated method stub + + } + + @Override + public ItemStack getEquipmentInSlot(int var1) { + // TODO Auto-generated method stub + return null; + } } diff --git a/common/buildcraft/core/robots/EntityRobotBuilder.java b/common/buildcraft/core/robots/EntityRobotBuilder.java index 02cb8b1c..20c89539 100644 --- a/common/buildcraft/core/robots/EntityRobotBuilder.java +++ b/common/buildcraft/core/robots/EntityRobotBuilder.java @@ -1,23 +1,14 @@ /** - * Copyright (c) SpaceToad, 2011-2012 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.core.robots; -import buildcraft.builders.blueprints.BlueprintBuilder.SchematicBuilder; -import buildcraft.core.BlockIndex; -import buildcraft.core.Box; -import buildcraft.core.proxy.CoreProxy; -import buildcraft.core.utils.BCLog; -import buildcraft.core.utils.BlockUtil; - -import com.google.common.io.ByteArrayDataInput; -import com.google.common.io.ByteArrayDataOutput; - -import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData; +import io.netty.buffer.ByteBuf; import java.util.ArrayList; import java.util.LinkedList; @@ -25,6 +16,12 @@ import java.util.List; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; +import buildcraft.builders.blueprints.BlueprintBuilder.SchematicBuilder; +import buildcraft.core.BlockIndex; +import buildcraft.core.Box; +import buildcraft.core.utils.BCLog; +import buildcraft.core.utils.BlockUtil; +import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData; public class EntityRobotBuilder extends EntityRobot implements IEntityAdditionalSpawnData { @@ -44,6 +41,7 @@ public class EntityRobotBuilder extends EntityRobot implements IEntityAdditional this.box = box; } + @Override protected void init() { if (box != null) { //setDestination((int) box.centerX(), (int) box.centerY(), (int) box.centerZ()); @@ -53,7 +51,7 @@ public class EntityRobotBuilder extends EntityRobot implements IEntityAdditional } @Override - public void writeSpawnData(ByteArrayDataOutput data) { + public void writeSpawnData(ByteBuf data) { super.writeSpawnData(data); if (box == null) { @@ -69,7 +67,7 @@ public class EntityRobotBuilder extends EntityRobot implements IEntityAdditional } @Override - public void readSpawnData(ByteArrayDataInput data) { + public void readSpawnData(ByteBuf data) { box = new Box(); box.xMin = data.readInt(); @@ -97,6 +95,7 @@ public class EntityRobotBuilder extends EntityRobot implements IEntityAdditional super.writeEntityToNBT(nbttagcompound); } + @Override protected void move() { super.move(); @@ -113,8 +112,9 @@ public class EntityRobotBuilder extends EntityRobot implements IEntityAdditional public void onUpdate() { super.onUpdate(); - if (CoreProxy.proxy.isRenderWorld(worldObj)) + if (worldObj.isRemote) { return; + } build(); updateLaser(); @@ -147,7 +147,6 @@ public class EntityRobotBuilder extends EntityRobot implements IEntityAdditional } protected void build() { - updateWait(); if (wait <= 0 && !targets.isEmpty()) { @@ -162,6 +161,7 @@ public class EntityRobotBuilder extends EntityRobot implements IEntityAdditional if (!worldObj.isAirBlock(target.getX(), target.getY(), target.getZ())) { BlockUtil.breakBlock(worldObj, target.getX(), target.getY(), target.getZ()); } else { + targets.pop(); try { target.build(this); @@ -214,9 +214,11 @@ public class EntityRobotBuilder extends EntityRobot implements IEntityAdditional if (!readyToBuild()) { return false; } + if (schematic != null && !schematic.blockExists()) { return targets.add(schematic); } + return false; } diff --git a/common/buildcraft/core/robots/EntityRobotPicker.java b/common/buildcraft/core/robots/EntityRobotPicker.java index 9dbd0bb1..a9ad1785 100755 --- a/common/buildcraft/core/robots/EntityRobotPicker.java +++ b/common/buildcraft/core/robots/EntityRobotPicker.java @@ -11,13 +11,12 @@ package buildcraft.core.robots; import java.util.HashSet; import java.util.Set; -import buildcraft.api.core.SafeTimeTracker; -import buildcraft.core.DefaultProps; -import buildcraft.core.proxy.CoreProxy; import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityItem; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; +import buildcraft.api.core.SafeTimeTracker; +import buildcraft.core.DefaultProps; public class EntityRobotPicker extends EntityRobot { @@ -43,13 +42,13 @@ public class EntityRobotPicker extends EntityRobot { public void onUpdate () { super.onUpdate(); - if (CoreProxy.proxy.isRenderWorld(worldObj)) { + if (worldObj.isRemote) { return; } if (target != null) { if (target.isDead) { - targettedItems.remove(target.entityId); + targettedItems.remove(target.getEntityId()); target = null; currentAI = new AIReturnToDock(); hideLaser(); @@ -80,7 +79,7 @@ public class EntityRobotPicker extends EntityRobot { for (Object o : worldObj.loadedEntityList) { Entity e = (Entity) o; - if (!e.isDead && e instanceof EntityItem && !targettedItems.contains(e.entityId)) { + if (!e.isDead && e instanceof EntityItem && !targettedItems.contains(e.getEntityId())) { double dx = e.posX - posX; double dy = e.posY - posY; double dz = e.posZ - posZ; @@ -91,7 +90,7 @@ public class EntityRobotPicker extends EntityRobot { if (sqrDistance <= maxDistance) { EntityItem item = (EntityItem) e; target = item; - targettedItems.add(e.entityId); + targettedItems.add(e.getEntityId()); currentAI = new AIMoveAround(this, (float) e.posX, (float) e.posY, (float) e.posZ); pickTime = -1; break; diff --git a/common/buildcraft/core/triggers/ActionMachineControl.java b/common/buildcraft/core/triggers/ActionMachineControl.java index b9c6f3ef..c06378f2 100644 --- a/common/buildcraft/core/triggers/ActionMachineControl.java +++ b/common/buildcraft/core/triggers/ActionMachineControl.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.triggers; import buildcraft.core.utils.StringUtils; diff --git a/common/buildcraft/core/triggers/ActionRedstoneOutput.java b/common/buildcraft/core/triggers/ActionRedstoneOutput.java index ec43af46..122c0dc9 100644 --- a/common/buildcraft/core/triggers/ActionRedstoneOutput.java +++ b/common/buildcraft/core/triggers/ActionRedstoneOutput.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.core.triggers; diff --git a/common/buildcraft/core/triggers/ActionTriggerIconProvider.java b/common/buildcraft/core/triggers/ActionTriggerIconProvider.java index d853b201..9cabafed 100644 --- a/common/buildcraft/core/triggers/ActionTriggerIconProvider.java +++ b/common/buildcraft/core/triggers/ActionTriggerIconProvider.java @@ -1,16 +1,22 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.triggers; import buildcraft.api.core.IIconProvider; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.client.renderer.texture.IconRegister; -import net.minecraft.util.Icon; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.util.IIcon; /** * Don't put new Trigger Icons in here please, put them in the Trigger classes * like the #TriggerClockTimer. This class will go away someday. - * - * @author CovertJaguar */ public class ActionTriggerIconProvider implements IIconProvider { @@ -51,22 +57,27 @@ public class ActionTriggerIconProvider implements IIconProvider { public static final int Trigger_Inventory_Below25 = 33; public static final int Trigger_Inventory_Below50 = 34; public static final int Trigger_Inventory_Below75 = 35; - public static final int MAX = 39; + public static final int Trigger_FluidContainer_Below25 = 36; + public static final int Trigger_FluidContainer_Below50 = 37; + public static final int Trigger_FluidContainer_Below75 = 38; + + public static final int MAX = 45; + @SideOnly(Side.CLIENT) - private final Icon[] icons = new Icon[MAX]; + private final IIcon[] icons = new IIcon[MAX]; private ActionTriggerIconProvider() { } @Override @SideOnly(Side.CLIENT) - public Icon getIcon(int iconIndex) { + public IIcon getIcon(int iconIndex) { return icons[iconIndex]; } @Override @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister iconRegister) { + public void registerIcons(IIconRegister iconRegister) { icons[ActionTriggerIconProvider.Action_MachineControl_On] = iconRegister.registerIcon("buildcraft:triggers/action_machinecontrol_on"); icons[ActionTriggerIconProvider.Action_MachineControl_Off] = iconRegister.registerIcon("buildcraft:triggers/action_machinecontrol_off"); icons[ActionTriggerIconProvider.Action_MachineControl_Loop] = iconRegister.registerIcon("buildcraft:triggers/action_machinecontrol_loop"); @@ -104,5 +115,8 @@ public class ActionTriggerIconProvider implements IIconProvider { icons[ActionTriggerIconProvider.Trigger_Inventory_Below25] = iconRegister.registerIcon("buildcraft:triggers/trigger_inventory_below25"); icons[ActionTriggerIconProvider.Trigger_Inventory_Below50] = iconRegister.registerIcon("buildcraft:triggers/trigger_inventory_below50"); icons[ActionTriggerIconProvider.Trigger_Inventory_Below75] = iconRegister.registerIcon("buildcraft:triggers/trigger_inventory_below75"); + icons[ActionTriggerIconProvider.Trigger_FluidContainer_Below25] = iconRegister.registerIcon("buildcraft:triggers/trigger_liquidcontainer_below25"); + icons[ActionTriggerIconProvider.Trigger_FluidContainer_Below50] = iconRegister.registerIcon("buildcraft:triggers/trigger_liquidcontainer_below50"); + icons[ActionTriggerIconProvider.Trigger_FluidContainer_Below75] = iconRegister.registerIcon("buildcraft:triggers/trigger_liquidcontainer_below75"); } } diff --git a/common/buildcraft/core/triggers/BCAction.java b/common/buildcraft/core/triggers/BCAction.java index 5b2d916a..acd083ac 100644 --- a/common/buildcraft/core/triggers/BCAction.java +++ b/common/buildcraft/core/triggers/BCAction.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.core.triggers; @@ -12,8 +13,8 @@ import static buildcraft.api.gates.ActionManager.actions; import buildcraft.api.gates.IAction; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.client.renderer.texture.IconRegister; -import net.minecraft.util.Icon; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.util.IIcon; public abstract class BCAction implements IAction { @@ -44,7 +45,7 @@ public abstract class BCAction implements IAction { @Override @SideOnly(Side.CLIENT) - public Icon getIcon() { + public IIcon getIcon() { return ActionTriggerIconProvider.INSTANCE.getIcon(getIconIndex()); } @@ -54,7 +55,7 @@ public abstract class BCAction implements IAction { @Override @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister iconRegister) { + public void registerIcons(IIconRegister iconRegister) { } @Override diff --git a/common/buildcraft/core/triggers/BCTrigger.java b/common/buildcraft/core/triggers/BCTrigger.java index c8205d93..b6eb66b6 100644 --- a/common/buildcraft/core/triggers/BCTrigger.java +++ b/common/buildcraft/core/triggers/BCTrigger.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.core.triggers; @@ -13,8 +14,8 @@ import buildcraft.api.gates.ITriggerParameter; import buildcraft.api.gates.TriggerParameter; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.client.renderer.texture.IconRegister; -import net.minecraft.util.Icon; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.util.IIcon; /** * This class has to be implemented to create new triggers kinds to BuildCraft @@ -50,13 +51,13 @@ public abstract class BCTrigger implements ITrigger { @Override @SideOnly(Side.CLIENT) - public Icon getIcon() { + public IIcon getIcon() { return ActionTriggerIconProvider.INSTANCE.getIcon(getIconIndex()); } @Override @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister iconRegister) { + public void registerIcons(IIconRegister iconRegister) { } @Override diff --git a/common/buildcraft/core/triggers/DefaultActionProvider.java b/common/buildcraft/core/triggers/DefaultActionProvider.java index 3eea5f3c..a5bc68b0 100644 --- a/common/buildcraft/core/triggers/DefaultActionProvider.java +++ b/common/buildcraft/core/triggers/DefaultActionProvider.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.triggers; import buildcraft.BuildCraftCore; @@ -5,8 +13,8 @@ import buildcraft.api.gates.IAction; import buildcraft.api.gates.IActionProvider; import buildcraft.core.IMachine; import cpw.mods.fml.common.FMLLog; +import org.apache.logging.log4j.Level; import java.util.LinkedList; -import java.util.logging.Level; import net.minecraft.block.Block; import net.minecraft.tileentity.TileEntity; @@ -28,8 +36,8 @@ public class DefaultActionProvider implements IActionProvider { if (machine.allowAction(BuildCraftCore.actionLoop)) res.add(BuildCraftCore.actionLoop); } - } catch (Throwable error) { - FMLLog.log("Buildcraft", Level.SEVERE, "Outdated API detected, please update your mods!"); + } catch (Throwable error) { + FMLLog.log("Buildcraft", Level.FATAL, "Outdated API detected, please update your mods!"); } return res; diff --git a/common/buildcraft/core/triggers/DefaultTriggerProvider.java b/common/buildcraft/core/triggers/DefaultTriggerProvider.java index 2c681c68..8fe73e93 100644 --- a/common/buildcraft/core/triggers/DefaultTriggerProvider.java +++ b/common/buildcraft/core/triggers/DefaultTriggerProvider.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.triggers; import buildcraft.BuildCraftCore; @@ -10,7 +18,7 @@ import java.util.LinkedList; import net.minecraft.block.Block; import net.minecraft.inventory.IInventory; import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidHandler; @@ -41,6 +49,9 @@ public class DefaultTriggerProvider implements ITriggerProvider { res.add(BuildCraftCore.triggerContainsFluid); res.add(BuildCraftCore.triggerSpaceFluid); res.add(BuildCraftCore.triggerFullFluid); + res.add(BuildCraftCore.triggerFluidContainerBelow25); + res.add(BuildCraftCore.triggerFluidContainerBelow50); + res.add(BuildCraftCore.triggerFluidContainerBelow75); } } diff --git a/common/buildcraft/core/triggers/TriggerFluidContainer.java b/common/buildcraft/core/triggers/TriggerFluidContainer.java index 8aff2fd6..83aac0fa 100644 --- a/common/buildcraft/core/triggers/TriggerFluidContainer.java +++ b/common/buildcraft/core/triggers/TriggerFluidContainer.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.core.triggers; @@ -12,7 +13,7 @@ import buildcraft.api.gates.ITriggerParameter; import buildcraft.core.utils.StringUtils; import java.util.Locale; import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; diff --git a/common/buildcraft/core/triggers/TriggerFluidContainerLevel.java b/common/buildcraft/core/triggers/TriggerFluidContainerLevel.java new file mode 100644 index 00000000..3e8fbec6 --- /dev/null +++ b/common/buildcraft/core/triggers/TriggerFluidContainerLevel.java @@ -0,0 +1,102 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ +package buildcraft.core.triggers; + +import buildcraft.api.gates.ITileTrigger; +import buildcraft.api.gates.ITriggerParameter; +import buildcraft.core.triggers.TriggerInventoryLevel.TriggerType; +import buildcraft.core.utils.StringUtils; +import java.util.Locale; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.FluidTankInfo; +import net.minecraftforge.fluids.IFluidHandler; + +public class TriggerFluidContainerLevel extends BCTrigger implements ITileTrigger { + + public enum TriggerType { + + BELOW_25(0.25F), BELOW_50(0.5F), BELOW_75(0.75F); + + public final float level; + + private TriggerType(float level) { + this.level = level; + } + }; + + public TriggerType type; + + public TriggerFluidContainerLevel(TriggerType type) { + super("buildcraft:fluid." + type.name().toLowerCase(Locale.ENGLISH), "buildcraft.fluid." + type.name().toLowerCase(Locale.ENGLISH)); + this.type = type; + } + + @Override + public boolean hasParameter() { + return true; + } + + @Override + public String getDescription() { + return String.format(StringUtils.localize("gate.trigger.fluidlevel.below"), (int) (type.level * 100)); + } + + @Override + public boolean isTriggerActive(ForgeDirection side, TileEntity tile, ITriggerParameter parameter) { + if (tile instanceof IFluidHandler) { + IFluidHandler container = (IFluidHandler) tile; + + FluidStack searchedFluid = null; + + if (parameter != null && parameter.getItemStack() != null) { + searchedFluid = FluidContainerRegistry.getFluidForFilledItem(parameter.getItemStack()); + } + + if (searchedFluid != null) { + searchedFluid.amount = 1; + } + + FluidTankInfo[] liquids = container.getTankInfo(side); + if (liquids == null || liquids.length == 0) + return false; + + for (FluidTankInfo c : liquids) { + if (c.fluid == null) { + if ( searchedFluid == null){ + return true; + } + return container.fill(side, searchedFluid, false) > 0; + } + + if (searchedFluid == null || searchedFluid.isFluidEqual(c.fluid)) { + float percentage = (float) c.fluid.amount / (float) c.capacity; + return percentage < type.level; + } + } + } + + return false; + } + + @Override + public int getIconIndex() { + switch (type) { + case BELOW_25: + return ActionTriggerIconProvider.Trigger_FluidContainer_Below25; + case BELOW_50: + return ActionTriggerIconProvider.Trigger_FluidContainer_Below50; + case BELOW_75: + default: + return ActionTriggerIconProvider.Trigger_FluidContainer_Below75; + } + } +} diff --git a/common/buildcraft/core/triggers/TriggerInventory.java b/common/buildcraft/core/triggers/TriggerInventory.java index db7af481..70ae3cc1 100644 --- a/common/buildcraft/core/triggers/TriggerInventory.java +++ b/common/buildcraft/core/triggers/TriggerInventory.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.core.triggers; @@ -18,7 +19,7 @@ import java.util.Locale; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; public class TriggerInventory extends BCTrigger implements ITileTrigger { diff --git a/common/buildcraft/core/triggers/TriggerInventoryLevel.java b/common/buildcraft/core/triggers/TriggerInventoryLevel.java index cae03387..28302948 100644 --- a/common/buildcraft/core/triggers/TriggerInventoryLevel.java +++ b/common/buildcraft/core/triggers/TriggerInventoryLevel.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.core.triggers; @@ -17,7 +18,7 @@ import java.util.Locale; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; public class TriggerInventoryLevel extends BCTrigger implements ITileTrigger { diff --git a/common/buildcraft/core/triggers/TriggerMachine.java b/common/buildcraft/core/triggers/TriggerMachine.java index e2eecfe9..7d816caa 100644 --- a/common/buildcraft/core/triggers/TriggerMachine.java +++ b/common/buildcraft/core/triggers/TriggerMachine.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.core.triggers; @@ -12,7 +13,7 @@ import buildcraft.api.gates.ITriggerParameter; import buildcraft.core.IMachine; import buildcraft.core.utils.StringUtils; import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; public class TriggerMachine extends BCTrigger implements ITileTrigger { diff --git a/common/buildcraft/core/triggers/TriggerRedstoneInput.java b/common/buildcraft/core/triggers/TriggerRedstoneInput.java index a5d1d654..15154136 100644 --- a/common/buildcraft/core/triggers/TriggerRedstoneInput.java +++ b/common/buildcraft/core/triggers/TriggerRedstoneInput.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.core.triggers; diff --git a/common/buildcraft/core/utils/BCLog.java b/common/buildcraft/core/utils/BCLog.java index e987345e..54b49d75 100644 --- a/common/buildcraft/core/utils/BCLog.java +++ b/common/buildcraft/core/utils/BCLog.java @@ -1,7 +1,7 @@ -/* - * Copyright (c) SpaceToad, 2011-2012 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * + * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt @@ -13,16 +13,14 @@ import cpw.mods.fml.common.FMLLog; import java.util.logging.Level; import java.util.logging.Logger; -/** - * - * @author CovertJaguar - */ public class BCLog { public static final Logger logger = Logger.getLogger("Buildcraft"); public static void initLog() { - logger.setParent(FMLLog.getLogger()); + // TODO: check if the code below is still useful and remove otherwise. + //logger.setParent(FMLLog.getLogger()); + logger.info("Starting BuildCraft " + Version.getVersion()); logger.info("Copyright (c) SpaceToad, 2011"); logger.info("http://www.mod-buildcraft.com"); diff --git a/common/buildcraft/core/utils/BlockUtil.java b/common/buildcraft/core/utils/BlockUtil.java index 358bee7a..d85973ad 100644 --- a/common/buildcraft/core/utils/BlockUtil.java +++ b/common/buildcraft/core/utils/BlockUtil.java @@ -1,9 +1,10 @@ /** - * BuildCraft is open-source. It is distributed under the terms of the - * BuildCraft Open Source License. It grants rights to read, modify, compile or - * run the code. It does *NOT* grant the right to redistribute this software or - * its modifications in any form, binary or source, except if expressively - * granted by the copyright holder. + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.core.utils; @@ -17,16 +18,17 @@ import java.util.ArrayList; import java.util.List; import net.minecraft.block.Block; -import net.minecraft.block.BlockFluid; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; -import net.minecraft.network.packet.Packet60Explosion; +import net.minecraft.network.play.server.S27PacketExplosion; import net.minecraft.world.ChunkPosition; import net.minecraft.world.Explosion; import net.minecraft.world.World; import net.minecraftforge.event.ForgeEventFactory; +import net.minecraftforge.fluids.BlockFluidBase; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidRegistry; @@ -36,17 +38,17 @@ import net.minecraftforge.fluids.IFluidBlock; public class BlockUtil { public static List getItemStackFromBlock(World world, int i, int j, int k) { - Block block = Block.blocksList[world.getBlockId(i, j, k)]; + Block block = world.getBlock(i, j, k); if (block == null) return null; - if (block.isAirBlock(world, i, j, k)) + if (block.isAir(world, i, j, k)) return null; int meta = world.getBlockMetadata(i, j, k); - ArrayList dropsList = block.getBlockDropped(world, i, j, k, meta, 0); + ArrayList dropsList = block.getDrops(world, i, j, k, meta, 0); float dropChance = ForgeEventFactory.fireBlockHarvesting(dropsList, world, block, i, j, k, meta, 0, 1.0F, false, CoreProxy.proxy.getBuildCraftPlayer(world)); ArrayList returnList = new ArrayList(); @@ -81,104 +83,86 @@ public class BlockUtil { } } - world.setBlock(x, y, z, 0); + world.setBlockToAir(x, y, z); } - public static boolean isAnObstructingBlock(int blockID, World world, int x, int y, int z) { - Block block = Block.blocksList[blockID]; - - if (blockID == 0 || block == null || block.isAirBlock(world, x, y, z)) + public static boolean isAnObstructingBlock(Block block, World world, int x, int y, int z) { + if (block == null || block.isAir(world, x, y, z)) return false; return true; } public static boolean canChangeBlock(World world, int x, int y, int z) { - return canChangeBlock(world.getBlockId(x, y, z), world, x, y, z); + return canChangeBlock(world.getBlock(x, y, z), world, x, y, z); } - public static boolean canChangeBlock(int blockID, World world, int x, int y, int z) { - Block block = Block.blocksList[blockID]; - - if (blockID == 0 || block == null || block.isAirBlock(world, x, y, z)) + public static boolean canChangeBlock(Block block, World world, int x, int y, int z) { + if (block == null || block.isAir(world, x, y, z)) return true; if (block.getBlockHardness(world, x, y, z) < 0) return false; - if (blockID == BuildCraftEnergy.blockOil.blockID) + if (block == BuildCraftEnergy.blockOil) return false; - if (blockID == Block.lavaStill.blockID || blockID == Block.lavaMoving.blockID) + if (block == Blocks.lava || block == Blocks.lava) return false; return true; } public static boolean isSoftBlock(World world, int x, int y, int z) { - return isSoftBlock(world.getBlockId(x, y, z), world, x, y, z); + return isSoftBlock(world.getBlock(x, y, z), world, x, y, z); } - public static boolean isSoftBlock(int blockID, World world, int x, int y, int z) { - Block block = Block.blocksList[blockID]; - - return blockID == 0 || block == null || BuildCraftAPI.softBlocks[blockID] || block.isAirBlock(world, x, y, z); + public static boolean isSoftBlock(Block block, World world, int x, int y, int z) { + return block == null || BuildCraftAPI.softBlocks.contains(block) || block.isAir(world, x, y, z); } /** * Returns true if a block cannot be harvested without a tool. */ public static boolean isToughBlock(World world, int x, int y, int z) { - return !world.getBlockMaterial(x, y, z).isToolNotRequired(); + return !world.getBlock(x, y, z).getMaterial().isToolNotRequired(); } public static boolean isFullFluidBlock(World world, int x, int y, int z) { - return isFullFluidBlock(world.getBlockId(x, y, z), world, x, y, z); + return isFullFluidBlock(world.getBlock(x, y, z), world, x, y, z); } - public static boolean isFullFluidBlock(int blockId, World world, int x, int y, int z) { - Block block = Block.blocksList[blockId]; - if (block instanceof BlockFluid || block instanceof IFluidBlock) + public static boolean isFullFluidBlock(Block block, World world, int x, int y, int z) { + if (block instanceof BlockFluidBase || block instanceof IFluidBlock) return world.getBlockMetadata(x, y, z) == 0; return false; } - public static Fluid getFluid(int blockId) { - Block block = Block.blocksList[blockId]; - if (block instanceof IFluidBlock) { - return ((IFluidBlock) block).getFluid(); - } else if (blockId == Block.waterStill.blockID || blockId == Block.waterMoving.blockID) { - return FluidRegistry.WATER; - } else if (blockId == Block.lavaStill.blockID || blockId == Block.lavaMoving.blockID) { - return FluidRegistry.LAVA; - } - return null; + public static Fluid getFluid(Block block) { + return FluidRegistry.lookupFluidForBlock (block); } public static FluidStack drainBlock(World world, int x, int y, int z, boolean doDrain) { - return drainBlock(world.getBlockId(x, y, z), world, x, y, z, doDrain); + return drainBlock(world.getBlock(x, y, z), world, x, y, z, doDrain); } - public static FluidStack drainBlock(int blockId, World world, int x, int y, int z, boolean doDrain) { - if (Block.blocksList[blockId] instanceof IFluidBlock) { - IFluidBlock fluidBlock = (IFluidBlock) Block.blocksList[blockId]; - if (fluidBlock.canDrain(world, x, y, z)) - return fluidBlock.drain(world, x, y, z, doDrain); - } else if (blockId == Block.waterStill.blockID || blockId == Block.waterMoving.blockID) { + public static FluidStack drainBlock(Block block, World world, int x, int y, int z, boolean doDrain) { + Fluid fluid = FluidRegistry.lookupFluidForBlock(block); + + if (fluid != null) { int meta = world.getBlockMetadata(x, y, z); - if (meta != 0) + + if (meta != 0) { return null; - if (doDrain) + } + + if (doDrain) { world.setBlockToAir(x, y, z); - return new FluidStack(FluidRegistry.WATER, FluidContainerRegistry.BUCKET_VOLUME); - } else if (blockId == Block.lavaStill.blockID || blockId == Block.lavaMoving.blockID) { - int meta = world.getBlockMetadata(x, y, z); - if (meta != 0) - return null; - if (doDrain) - world.setBlockToAir(x, y, z); - return new FluidStack(FluidRegistry.LAVA, FluidContainerRegistry.BUCKET_VOLUME); + } + + return new FluidStack(fluid, FluidContainerRegistry.BUCKET_VOLUME); + } else { + return null; } - return null; } /** @@ -198,7 +182,7 @@ public class BlockUtil { continue; if (player.getDistanceSq(x, y, z) < 4096) { - ((EntityPlayerMP) player).playerNetServerHandler.sendPacketToPlayer(new Packet60Explosion(x + .5, y + .5, z + .5, 3f, explosion.affectedBlockPositions, null)); + ((EntityPlayerMP) player).playerNetServerHandler.sendPacket(new S27PacketExplosion(x + .5, y + .5, z + .5, 3f, explosion.affectedBlockPositions, null)); } } } diff --git a/common/buildcraft/core/utils/ConfigUtils.java b/common/buildcraft/core/utils/ConfigUtils.java index cb439f66..2b630682 100644 --- a/common/buildcraft/core/utils/ConfigUtils.java +++ b/common/buildcraft/core/utils/ConfigUtils.java @@ -1,7 +1,7 @@ -/* - * Copyright (c) SpaceToad, 2011-2012 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * + * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt @@ -10,13 +10,9 @@ package buildcraft.core.utils; import buildcraft.BuildCraftCore; import java.util.logging.Level; -import net.minecraftforge.common.Configuration; -import net.minecraftforge.common.Property; +import net.minecraftforge.common.config.Configuration; +import net.minecraftforge.common.config.Property; -/** - * - * @author CovertJaguar - */ public class ConfigUtils { private static final String COMMENT_PREFIX = ""; diff --git a/common/buildcraft/core/utils/CraftingHelper.java b/common/buildcraft/core/utils/CraftingHelper.java index cfa9f706..c47435be 100644 --- a/common/buildcraft/core/utils/CraftingHelper.java +++ b/common/buildcraft/core/utils/CraftingHelper.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.utils; import java.util.ArrayList; @@ -40,9 +48,9 @@ public class CraftingHelper { } } - if (itemNum == 2 && item1.itemID == item2.itemID && item1.stackSize == 1 && item2.stackSize == 1 && Item.itemsList[item1.itemID].isRepairable()) + if (itemNum == 2 && item1.getItem() == item2.getItem() && item1.stackSize == 1 && item2.stackSize == 1 && item1.getItem().isRepairable()) { - Item itemBase = Item.itemsList[item1.itemID]; + Item itemBase = item1.getItem(); int item1Durability = itemBase.getMaxDamage() - item1.getItemDamageForDisplay(); int item2Durability = itemBase.getMaxDamage() - item2.getItemDamageForDisplay(); int repairAmt = item1Durability + item2Durability + itemBase.getMaxDamage() * 5 / 100; @@ -56,7 +64,7 @@ public class CraftingHelper { ArrayList ingredients = new ArrayList(2); ingredients.add(item1); ingredients.add(item2); - return new ShapelessRecipes(new ItemStack(item1.itemID, 1, newDamage),ingredients); + return new ShapelessRecipes(new ItemStack(item1.getItem(), 1, newDamage),ingredients); } // End repair recipe handler else diff --git a/common/buildcraft/core/utils/EnumColor.java b/common/buildcraft/core/utils/EnumColor.java index 2c522f6a..9e02a85b 100644 --- a/common/buildcraft/core/utils/EnumColor.java +++ b/common/buildcraft/core/utils/EnumColor.java @@ -1,11 +1,15 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.utils; import java.util.Locale; -/** - * - * @author CovertJaguar - */ public enum EnumColor { BLACK, diff --git a/common/buildcraft/core/utils/INBTTagable.java b/common/buildcraft/core/utils/INBTTagable.java index d1d7abf1..c3587b47 100644 --- a/common/buildcraft/core/utils/INBTTagable.java +++ b/common/buildcraft/core/utils/INBTTagable.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.utils; import net.minecraft.nbt.NBTTagCompound; diff --git a/common/buildcraft/core/utils/Localization.java b/common/buildcraft/core/utils/Localization.java index 9ec1fa45..f7d21ad8 100644 --- a/common/buildcraft/core/utils/Localization.java +++ b/common/buildcraft/core/utils/Localization.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.utils; import buildcraft.core.proxy.CoreProxy; @@ -7,10 +15,7 @@ import java.util.LinkedList; import java.util.Properties; /** - * Simple mod localization class. - * - * @author Jimeo Wan - * @license Public domain + * Simple mod localization class. */ public class Localization { diff --git a/common/buildcraft/core/utils/MathUtils.java b/common/buildcraft/core/utils/MathUtils.java index d0c3adff..54f36fb8 100644 --- a/common/buildcraft/core/utils/MathUtils.java +++ b/common/buildcraft/core/utils/MathUtils.java @@ -1,17 +1,13 @@ -/* - * Copyright (c) SpaceToad, 2011-2012 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * + * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.core.utils; -/** - * - * @author CovertJaguar - */ public class MathUtils { public static int clamp(int value, int min, int max) { diff --git a/common/buildcraft/core/utils/MatrixTranformations.java b/common/buildcraft/core/utils/MatrixTranformations.java index c5eae1a4..92794b91 100644 --- a/common/buildcraft/core/utils/MatrixTranformations.java +++ b/common/buildcraft/core/utils/MatrixTranformations.java @@ -1,19 +1,15 @@ -/* - * Copyright (c) SpaceToad, 2011-2012 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * + * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.core.utils; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; -/** - * - * @author Krapht - */ public class MatrixTranformations { /** diff --git a/common/buildcraft/core/utils/NBTUtils.java b/common/buildcraft/core/utils/NBTUtils.java index 3fa415a6..7843e2d3 100644 --- a/common/buildcraft/core/utils/NBTUtils.java +++ b/common/buildcraft/core/utils/NBTUtils.java @@ -1,7 +1,7 @@ -/* - * Copyright (c) SpaceToad, 2011-2012 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * + * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt @@ -12,16 +12,12 @@ import java.util.UUID; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -/** - * - * @author CovertJaguar - */ public class NBTUtils { public static NBTTagCompound getItemData(ItemStack stack) { NBTTagCompound nbt = stack.getTagCompound(); if (nbt == null) { - nbt = new NBTTagCompound("tag"); + nbt = new NBTTagCompound(); stack.setTagCompound(nbt); } return nbt; diff --git a/common/buildcraft/core/utils/RevolvingList.java b/common/buildcraft/core/utils/RevolvingList.java index c2b08343..6ec887f5 100644 --- a/common/buildcraft/core/utils/RevolvingList.java +++ b/common/buildcraft/core/utils/RevolvingList.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.core.utils; @@ -10,10 +11,6 @@ package buildcraft.core.utils; import com.google.common.collect.ForwardingCollection; import java.util.*; -/** - * - * @author CovertJaguar - */ public class RevolvingList extends ForwardingCollection { private Deque list = new LinkedList(); diff --git a/common/buildcraft/core/utils/SessionVars.java b/common/buildcraft/core/utils/SessionVars.java index 74c00965..9aa7477f 100644 --- a/common/buildcraft/core/utils/SessionVars.java +++ b/common/buildcraft/core/utils/SessionVars.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.utils; public class SessionVars { diff --git a/common/buildcraft/core/utils/StringUtils.java b/common/buildcraft/core/utils/StringUtils.java index a64e79c1..dde2fcbd 100644 --- a/common/buildcraft/core/utils/StringUtils.java +++ b/common/buildcraft/core/utils/StringUtils.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.core.utils; public class StringUtils { diff --git a/common/buildcraft/core/utils/Utils.java b/common/buildcraft/core/utils/Utils.java index 8d88b8ec..ee90bbc0 100644 --- a/common/buildcraft/core/utils/Utils.java +++ b/common/buildcraft/core/utils/Utils.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.core.utils; @@ -14,6 +15,7 @@ import buildcraft.api.core.Position; import buildcraft.api.transport.IPipeTile; import buildcraft.api.transport.IPipeTile.PipeType; import buildcraft.core.BlockIndex; +import buildcraft.core.DefaultProps; import buildcraft.core.EntityBlock; import buildcraft.core.IDropControlInventory; import buildcraft.core.IFramePipeConnection; @@ -21,38 +23,67 @@ import buildcraft.core.TileBuildCraft; import buildcraft.core.inventory.ITransactor; import buildcraft.core.inventory.InvUtils; import buildcraft.core.inventory.Transactor; +import buildcraft.core.network.BuildCraftPacket; import buildcraft.core.network.ISynchronizedTile; +import buildcraft.core.network.PacketTileUpdate; import buildcraft.core.network.PacketUpdate; import buildcraft.core.proxy.CoreProxy; import buildcraft.energy.TileEngine; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.nio.charset.Charset; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Random; +import cpw.mods.fml.common.network.internal.FMLProxyPacket; import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.InventoryLargeChest; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.CompressedStreamTools; +import net.minecraft.nbt.NBTBase; +import net.minecraft.nbt.NBTTagByte; +import net.minecraft.nbt.NBTTagByteArray; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagDouble; +import net.minecraft.nbt.NBTTagEnd; +import net.minecraft.nbt.NBTTagFloat; +import net.minecraft.nbt.NBTTagInt; +import net.minecraft.nbt.NBTTagIntArray; import net.minecraft.nbt.NBTTagList; +import net.minecraft.nbt.NBTTagLong; +import net.minecraft.nbt.NBTTagShort; import net.minecraft.nbt.NBTTagString; +import net.minecraft.network.INetHandler; +import net.minecraft.network.NetHandlerPlayServer; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityChest; import net.minecraft.util.MathHelper; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; public class Utils { public static final Random RANDOM = new Random(); private static final List directions = new ArrayList(Arrays.asList(ForgeDirection.VALID_DIRECTIONS)); + public enum NBTTag_Types { + NBTTagEnd, NBTTagByte, NBTTagShort, + NBTTagInt, NBTTagLong, NBTTagFloat, + NBTTagDouble, NBTTagByteArray, NBTTagString, + NBTTagList, NBTTagCompound, NBTTagIntArray + } + /* IINVENTORY HELPERS */ /** * Tries to add the passed stack to any valid inventories around the given @@ -71,7 +102,7 @@ public class Utils { Position pos = new Position(x, y, z, orientation); pos.moveForwards(1.0); - TileEntity tileInventory = world.getBlockTileEntity((int) pos.x, (int) pos.y, (int) pos.z); + TileEntity tileInventory = world.getTileEntity((int) pos.x, (int) pos.y, (int) pos.z); ITransactor transactor = Transactor.getTransactorFor(tileInventory); if (transactor != null && !(tileInventory instanceof TileEngine) && transactor.add(stack, orientation.getOpposite(), false).stackSize > 0) { return transactor.add(stack, orientation.getOpposite(), true).stackSize; @@ -147,7 +178,7 @@ public class Utils { pos.moveForwards(1.0); - TileEntity tile = world.getBlockTileEntity((int) pos.x, (int) pos.y, (int) pos.z); + TileEntity tile = world.getTileEntity((int) pos.x, (int) pos.y, (int) pos.z); if (tile instanceof IPipeTile) { IPipeTile pipe = (IPipeTile) tile; @@ -176,16 +207,16 @@ public class Utils { tmp.orientation = step; tmp.moveForwards(1.0); - return world.getBlockTileEntity((int) tmp.x, (int) tmp.y, (int) tmp.z); + return world.getTileEntity((int) tmp.x, (int) tmp.y, (int) tmp.z); } public static IAreaProvider getNearbyAreaProvider(World world, int i, int j, int k) { - TileEntity a1 = world.getBlockTileEntity(i + 1, j, k); - TileEntity a2 = world.getBlockTileEntity(i - 1, j, k); - TileEntity a3 = world.getBlockTileEntity(i, j, k + 1); - TileEntity a4 = world.getBlockTileEntity(i, j, k - 1); - TileEntity a5 = world.getBlockTileEntity(i, j + 1, k); - TileEntity a6 = world.getBlockTileEntity(i, j - 1, k); + TileEntity a1 = world.getTileEntity(i + 1, j, k); + TileEntity a2 = world.getTileEntity(i - 1, j, k); + TileEntity a3 = world.getTileEntity(i, j, k + 1); + TileEntity a4 = world.getTileEntity(i, j, k - 1); + TileEntity a5 = world.getTileEntity(i, j + 1, k); + TileEntity a6 = world.getTileEntity(i, j - 1, k); if (a1 instanceof IAreaProvider) { return (IAreaProvider) a1; @@ -306,9 +337,9 @@ public class Utils { } public static void preDestroyBlock(World world, int i, int j, int k) { - TileEntity tile = world.getBlockTileEntity(i, j, k); + TileEntity tile = world.getTileEntity(i, j, k); - if (tile instanceof IInventory && !CoreProxy.proxy.isRenderWorld(world)) { + if (tile instanceof IInventory && !world.isRemote) { if (!(tile instanceof IDropControlInventory) || ((IDropControlInventory) tile).doDrop()) { InvUtils.dropItems(world, (IInventory) tile, i, j, k); InvUtils.wipeInventory((IInventory) tile); @@ -353,8 +384,8 @@ public class Utils { public static boolean checkLegacyPipesConnections(IBlockAccess blockAccess, int x1, int y1, int z1, int x2, int y2, int z2) { - Block b1 = Block.blocksList[blockAccess.getBlockId(x1, y1, z1)]; - Block b2 = Block.blocksList[blockAccess.getBlockId(x2, y2, z2)]; + Block b1 = blockAccess.getBlock(x1, y1, z1); + Block b2 = blockAccess.getBlock(x2, y2, z2); if (!(b1 instanceof IFramePipeConnection) && !(b2 instanceof IFramePipeConnection)) { return false; @@ -397,4 +428,101 @@ public class Utils { } return slots; } + + public static void writeUTF (ByteBuf data, String str) { + try { + byte [] b = str.getBytes("UTF-8"); + data.writeInt (b.length); + data.writeBytes(b); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + data.writeInt (0); + } + } + + public static String readUTF (ByteBuf data) { + try { + int len = data.readInt(); + byte [] b = new byte [len]; + data.readBytes(b); + return new String (b, "UTF-8"); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + return null; + } + } + + public static void writeNBT (ByteBuf data, NBTTagCompound nbt) { + try { + byte[] compressed = CompressedStreamTools.compress(nbt); + data.writeShort(compressed.length); + data.writeBytes(compressed); + } catch (IOException e) { + e.printStackTrace(); + } + } + + public static NBTTagCompound readNBT(ByteBuf data) { + try { + short length = data.readShort(); + byte[] compressed = new byte[length]; + data.readBytes(compressed); + return CompressedStreamTools.decompress(compressed); + } catch (IOException e) { + e.printStackTrace(); + return null; + } + } + + public static void writeStack (ByteBuf data, ItemStack stack) { + if (stack == null) { + data.writeBoolean(false); + } else { + data.writeBoolean(true); + NBTTagCompound nbt = new NBTTagCompound(); + stack.writeToNBT(nbt); + Utils.writeNBT(data, nbt); + } + } + + + public static ItemStack readStack(ByteBuf data) { + if (!data.readBoolean()) { + return null; + } else { + NBTTagCompound nbt = readNBT(data); + return ItemStack.loadItemStackFromNBT(nbt); + } + } + + /** + * This subprogram transforms a packet into a FML packet to be send in the + * minecraft default packet mechanism. This always use BC-CORE as a + * channel, and as a result, should use discriminators declared there. + * + * WARNING! The implementation of this subprogram relies on the internal + * behavior of #FMLIndexedMessageToMessageCodec (in particular the encode + * member). It is probably opening a maintenance issue and should be + * replaced eventually by some more solid mechanism. + */ + public static FMLProxyPacket toPacket (BuildCraftPacket packet, int discriminator) { + ByteBuf buf = Unpooled.buffer(); + + buf.writeByte((byte) discriminator); + packet.writeData(buf); + + return new FMLProxyPacket(buf, DefaultProps.NET_CHANNEL_NAME + "-CORE"); + } + + /** + * This function returns either the player from the handler if it's on the + * server, or directly from the minecraft instance if it's the client. + */ + public static EntityPlayer getPlayerFromNetHandler (INetHandler handler) { + if (handler instanceof NetHandlerPlayServer) { + return ((NetHandlerPlayServer) handler).playerEntity; + } else { + return Minecraft.getMinecraft().thePlayer; + } + } } diff --git a/common/buildcraft/energy/BlockBuildcraftFluid.java b/common/buildcraft/energy/BlockBuildcraftFluid.java index cca5a974..31151a40 100644 --- a/common/buildcraft/energy/BlockBuildcraftFluid.java +++ b/common/buildcraft/energy/BlockBuildcraftFluid.java @@ -1,5 +1,5 @@ -/* - * Copyright (c) SpaceToad, 2011-2012 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com * * BuildCraft is distributed under the terms of the Minecraft Mod Public @@ -12,49 +12,48 @@ import buildcraft.energy.render.EntityDropParticleFX; import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; + import java.util.Random; + +import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.particle.EntityFX; -import net.minecraft.client.renderer.texture.IconRegister; -import net.minecraft.util.Icon; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.BlockFluidClassic; import net.minecraftforge.fluids.Fluid; -/** - * - * @author CovertJaguar - */ public class BlockBuildcraftFluid extends BlockFluidClassic { protected float particleRed; protected float particleGreen; protected float particleBlue; - public BlockBuildcraftFluid(int id, Fluid fluid, Material material) { - super(id, fluid, material); + public BlockBuildcraftFluid(Fluid fluid, Material material) { + super(fluid, material); } @SideOnly(Side.CLIENT) - protected Icon[] theIcon; + protected IIcon[] theIcon; protected boolean flammable; protected int flammability = 0; @Override - public Icon getIcon(int side, int meta) { + public IIcon getIcon(int side, int meta) { return side != 0 && side != 1 ? this.theIcon[1] : this.theIcon[0]; } @Override @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister iconRegister) { - this.theIcon = new Icon[] { iconRegister.registerIcon("buildcraft:" + fluidName + "_still"), iconRegister.registerIcon("buildcraft:" + fluidName + "_flow") }; + public void registerBlockIcons(IIconRegister iconRegister) { + this.theIcon = new IIcon[] { iconRegister.registerIcon("buildcraft:" + fluidName + "_still"), iconRegister.registerIcon("buildcraft:" + fluidName + "_flow") }; } @Override - public void onNeighborBlockChange(World world, int x, int y, int z, int blockId) { - super.onNeighborBlockChange(world, x, y, z, blockId); + public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { + super.onNeighborBlockChange(world, x, y, z, block); if (flammable && world.provider.dimensionId == -1) { world.newExplosion(null, x, y, z, 4F, true, true); world.setBlockToAir(x, y, z); @@ -72,22 +71,22 @@ public class BlockBuildcraftFluid extends BlockFluidClassic { } @Override - public int getFireSpreadSpeed(World world, int x, int y, int z, int metadata, ForgeDirection face) { + public int getFireSpreadSpeed(IBlockAccess world, int x, int y, int z, ForgeDirection face) { return flammable ? 300 : 0; } @Override - public int getFlammability(IBlockAccess world, int x, int y, int z, int metadata, ForgeDirection face) { + public int getFlammability(IBlockAccess world, int x, int y, int z, ForgeDirection face) { return flammability; } @Override - public boolean isFlammable(IBlockAccess world, int x, int y, int z, int metadata, ForgeDirection face) { + public boolean isFlammable(IBlockAccess world, int x, int y, int z, ForgeDirection face) { return flammable; } @Override - public boolean isFireSource(World world, int x, int y, int z, int metadata, ForgeDirection side) { + public boolean isFireSource(World world, int x, int y, int z, ForgeDirection side) { return flammable && flammability == 0; } @@ -103,7 +102,10 @@ public class BlockBuildcraftFluid extends BlockFluidClassic { public void randomDisplayTick(World world, int x, int y, int z, Random rand) { super.randomDisplayTick(world, x, y, z, rand); - if (rand.nextInt(10) == 0 && world.doesBlockHaveSolidTopSurface(x, y - 1, z) && !world.getBlockMaterial(x, y - 2, z).blocksMovement()) { + if (rand.nextInt(10) == 0 + && World.doesBlockHaveSolidTopSurface(world, x, y - 1, z) + && !world.getBlock(x, y - 2, z).getMaterial().blocksMovement()) { + double px = (double) ((float) x + rand.nextFloat()); double py = (double) y - 1.05D; double pz = (double) ((float) z + rand.nextFloat()); @@ -115,14 +117,14 @@ public class BlockBuildcraftFluid extends BlockFluidClassic { @Override public boolean canDisplace(IBlockAccess world, int x, int y, int z) { - if (world.getBlockMaterial(x, y, z).isLiquid()) + if (world.getBlock(x, y, z).getMaterial().isLiquid()) return false; return super.canDisplace(world, x, y, z); } @Override public boolean displaceIfPossible(World world, int x, int y, int z) { - if (world.getBlockMaterial(x, y, z).isLiquid()) + if (world.getBlock(x, y, z).getMaterial().isLiquid()) return false; return super.displaceIfPossible(world, x, y, z); } diff --git a/common/buildcraft/energy/BlockEnergyEmitter.java b/common/buildcraft/energy/BlockEnergyEmitter.java index d2f0f6fd..8cd96a94 100755 --- a/common/buildcraft/energy/BlockEnergyEmitter.java +++ b/common/buildcraft/energy/BlockEnergyEmitter.java @@ -12,20 +12,20 @@ import net.minecraft.block.material.Material; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; import buildcraft.core.BlockBuildCraft; import buildcraft.core.CreativeTabBuildCraft; public class BlockEnergyEmitter extends BlockBuildCraft { - public BlockEnergyEmitter(int id) { - super(id, Material.glass); + public BlockEnergyEmitter() { + super(Material.glass); setCreativeTab(CreativeTabBuildCraft.MACHINES.get()); } @Override - public TileEntity createNewTileEntity(World world) { + public TileEntity createNewTileEntity(World world, int p) { return new TileEnergyEmitter(); } @@ -55,7 +55,7 @@ public class BlockEnergyEmitter extends BlockBuildCraft { //} @Override - public boolean isBlockSolidOnSide(World world, int x, int y, int z, ForgeDirection side) { + public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) { return false; } diff --git a/common/buildcraft/energy/BlockEnergyReceiver.java b/common/buildcraft/energy/BlockEnergyReceiver.java index 11e3a28f..fef586b7 100755 --- a/common/buildcraft/energy/BlockEnergyReceiver.java +++ b/common/buildcraft/energy/BlockEnergyReceiver.java @@ -16,14 +16,14 @@ import buildcraft.core.CreativeTabBuildCraft; public class BlockEnergyReceiver extends BlockBuildCraft { - public BlockEnergyReceiver(int id) { - super(id, Material.iron); + public BlockEnergyReceiver() { + super(Material.iron); setCreativeTab(CreativeTabBuildCraft.MACHINES.get()); } @Override - public TileEntity createNewTileEntity(World world) { + public TileEntity createNewTileEntity(World world, int p) { return new TileEnergyReceiver(); } diff --git a/common/buildcraft/energy/BlockEngine.java b/common/buildcraft/energy/BlockEngine.java index 4e702925..7149ce7e 100644 --- a/common/buildcraft/energy/BlockEngine.java +++ b/common/buildcraft/energy/BlockEngine.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.energy; @@ -12,27 +13,32 @@ import buildcraft.core.BlockBuildCraft; import buildcraft.core.IItemPipe; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; + import java.util.List; import java.util.Random; + +import net.minecraft.block.Block; import net.minecraft.block.material.Material; -import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Icon; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; public class BlockEngine extends BlockBuildCraft { - private static Icon woodTexture; - private static Icon stoneTexture; - private static Icon ironTexture; + private static IIcon woodTexture; + private static IIcon stoneTexture; + private static IIcon ironTexture; - public BlockEngine(int i) { - super(i, Material.iron); - setUnlocalizedName("engineBlock"); + public BlockEngine() { + super(Material.iron); + setBlockName("engineBlock"); } @Override @@ -47,7 +53,7 @@ public class BlockEngine extends BlockBuildCraft { @Override @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister par1IconRegister) { + public void registerBlockIcons(IIconRegister par1IconRegister) { woodTexture = par1IconRegister.registerIcon("buildcraft:engineWoodBottom"); stoneTexture = par1IconRegister.registerIcon("buildcraft:engineStoneBottom"); ironTexture = par1IconRegister.registerIcon("buildcraft:engineIronBottom"); @@ -69,8 +75,8 @@ public class BlockEngine extends BlockBuildCraft { } @Override - public boolean isBlockSolidOnSide(World world, int x, int y, int z, ForgeDirection side) { - TileEntity tile = world.getBlockTileEntity(x, y, z); + public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) { + TileEntity tile = world.getTileEntity(x, y, z); if (tile instanceof TileEngine) { return ((TileEngine) tile).orientation.getOpposite() == side; } @@ -79,7 +85,7 @@ public class BlockEngine extends BlockBuildCraft { @Override public boolean rotateBlock(World world, int x, int y, int z, ForgeDirection axis) { - TileEntity tile = world.getBlockTileEntity(x, y, z); + TileEntity tile = world.getTileEntity(x, y, z); if (tile instanceof TileEngine) { return ((TileEngine) tile).switchOrientation(false); } @@ -89,7 +95,7 @@ public class BlockEngine extends BlockBuildCraft { @Override public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer player, int side, float par7, float par8, float par9) { - TileEngine tile = (TileEngine) world.getBlockTileEntity(i, j, k); + TileEngine tile = (TileEngine) world.getTileEntity(i, j, k); // Drop through if the player is sneaking if (player.isSneaking()) @@ -111,7 +117,7 @@ public class BlockEngine extends BlockBuildCraft { @Override public void onPostBlockPlaced(World world, int x, int y, int z, int par5) { - TileEngine tile = (TileEngine) world.getBlockTileEntity(x, y, z); + TileEngine tile = (TileEngine) world.getTileEntity(x, y, z); tile.orientation = ForgeDirection.UP; if (!tile.isOrientationValid()) tile.switchOrientation(true); @@ -125,7 +131,7 @@ public class BlockEngine extends BlockBuildCraft { @SuppressWarnings({"all"}) @Override public void randomDisplayTick(World world, int i, int j, int k, Random random) { - TileEngine tile = (TileEngine) world.getBlockTileEntity(i, j, k); + TileEngine tile = (TileEngine) world.getTileEntity(i, j, k); if (!tile.isBurning()) { return; @@ -145,15 +151,15 @@ public class BlockEngine extends BlockBuildCraft { @SuppressWarnings({"unchecked", "rawtypes"}) @Override - public void getSubBlocks(int blockid, CreativeTabs par2CreativeTabs, List itemList) { + public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List itemList) { itemList.add(new ItemStack(this, 1, 0)); itemList.add(new ItemStack(this, 1, 1)); itemList.add(new ItemStack(this, 1, 2)); } @Override - public void onNeighborBlockChange(World world, int i, int j, int k, int l) { - TileEngine tile = (TileEngine) world.getBlockTileEntity(i, j, k); + public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { + TileEngine tile = (TileEngine) world.getTileEntity(x, y, z); if (tile != null) { tile.checkRedstonePower(); @@ -162,7 +168,7 @@ public class BlockEngine extends BlockBuildCraft { @Override @SideOnly(Side.CLIENT) - public Icon getIcon(int side, int meta) { + public IIcon getIcon(int side, int meta) { switch (meta) { case 0: return woodTexture; @@ -176,7 +182,7 @@ public class BlockEngine extends BlockBuildCraft { } @Override - public TileEntity createNewTileEntity(World world) { + public TileEntity createNewTileEntity(World world, int metadata) { return null; } } diff --git a/common/buildcraft/energy/BlockPollution.java b/common/buildcraft/energy/BlockPollution.java deleted file mode 100644 index ae50a074..00000000 --- a/common/buildcraft/energy/BlockPollution.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Copyright (c) SpaceToad, 2011 - * http://www.mod-buildcraft.com - * - * BuildCraft is distributed under the terms of the Minecraft Mod Public - * License 1.0, or MMPL. Please check the contents of the license located in - * http://www.mod-buildcraft.com/MMPL-1.0.txt - */ - -package buildcraft.energy; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.block.BlockContainer; -import net.minecraft.block.material.Material; -import net.minecraft.client.renderer.texture.IconRegister; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; - -public class BlockPollution extends BlockContainer { - - public BlockPollution(int i) { - super(i, Material.air); - } - - @Override - public boolean renderAsNormalBlock() { - return false; - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public TileEntity createNewTileEntity(World var1) { - return new TilePollution(); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister par1IconRegister) - { - par1IconRegister.registerIcon("buildcraft:blockPollution"); - } -} diff --git a/common/buildcraft/energy/BptBlockEngine.java b/common/buildcraft/energy/BptBlockEngine.java index 554aaf30..96a649bd 100644 --- a/common/buildcraft/energy/BptBlockEngine.java +++ b/common/buildcraft/energy/BptBlockEngine.java @@ -1,12 +1,11 @@ /** - * Copyright (c) SpaceToad, 2011 + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.energy; import buildcraft.api.blueprints.BlockSignature; @@ -15,7 +14,7 @@ import buildcraft.api.blueprints.BptSlotInfo; import buildcraft.api.blueprints.IBptContext; import buildcraft.core.Version; import net.minecraft.block.Block; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; @Deprecated public class BptBlockEngine extends BptBlock { @@ -35,16 +34,16 @@ public class BptBlockEngine extends BptBlock { @Override public void initializeFromWorld(BptSlotInfo bptSlot, IBptContext context, int x, int y, int z) { - TileEngine engine = (TileEngine) context.world().getBlockTileEntity(x, y, z); + TileEngine engine = (TileEngine) context.world().getTileEntity(x, y, z); bptSlot.cpt.setInteger("orientation", engine.orientation.ordinal()); } @Override public void buildBlock(BptSlotInfo slot, IBptContext context) { - context.world().setBlock(slot.x, slot.y, slot.z, slot.blockId, slot.meta,1); + //context.world().setBlock(slot.x, slot.y, slot.z, slot.blockId, slot.meta,1); - TileEngine engine = (TileEngine) context.world().getBlockTileEntity(slot.x, slot.y, slot.z); + TileEngine engine = (TileEngine) context.world().getTileEntity(slot.x, slot.y, slot.z); engine.orientation = ForgeDirection.getOrientation(slot.cpt.getInteger("orientation")); } diff --git a/common/buildcraft/energy/BucketHandler.java b/common/buildcraft/energy/BucketHandler.java index 969c081f..efb86e9b 100644 --- a/common/buildcraft/energy/BucketHandler.java +++ b/common/buildcraft/energy/BucketHandler.java @@ -1,22 +1,26 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.energy; import buildcraft.BuildCraftEnergy; + import java.util.HashMap; import java.util.Map; + +import cpw.mods.fml.common.eventhandler.SubscribeEvent; import net.minecraft.block.Block; +import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; -import net.minecraftforge.event.Event.Result; -import net.minecraftforge.event.ForgeSubscribe; +import cpw.mods.fml.common.eventhandler.Event.Result; import net.minecraftforge.event.entity.player.FillBucketEvent; public class BucketHandler { @@ -27,28 +31,28 @@ public class BucketHandler { private BucketHandler() { } - @ForgeSubscribe + @SubscribeEvent public void onBucketFill(FillBucketEvent event) { - ItemStack result = fillCustomBucket(event.world, event.target); - if (result == null) + if (result == null) { return; + } event.result = result; event.setResult(Result.ALLOW); } private ItemStack fillCustomBucket(World world, MovingObjectPosition pos) { + Block block = world.getBlock(pos.blockX, pos.blockY, pos.blockZ); - int blockID = world.getBlockId(pos.blockX, pos.blockY, pos.blockZ); - - Item bucket = buckets.get(Block.blocksList[blockID]); + Item bucket = Item.getItemFromBlock(block); + if (bucket != null && world.getBlockMetadata(pos.blockX, pos.blockY, pos.blockZ) == 0) { - world.setBlock(pos.blockX, pos.blockY, pos.blockZ, 0); + world.setBlockToAir(pos.blockX, pos.blockY, pos.blockZ); return new ItemStack(bucket); - } else + } else { return null; - + } } } diff --git a/common/buildcraft/energy/EnergyProxy.java b/common/buildcraft/energy/EnergyProxy.java index 299b847e..12ecaa94 100644 --- a/common/buildcraft/energy/EnergyProxy.java +++ b/common/buildcraft/energy/EnergyProxy.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.energy; import cpw.mods.fml.common.SidedProxy; diff --git a/common/buildcraft/energy/EnergyProxyClient.java b/common/buildcraft/energy/EnergyProxyClient.java index b33e5066..329d14ac 100644 --- a/common/buildcraft/energy/EnergyProxyClient.java +++ b/common/buildcraft/energy/EnergyProxyClient.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.energy; import buildcraft.BuildCraftEnergy; diff --git a/common/buildcraft/energy/GuiHandler.java b/common/buildcraft/energy/GuiHandler.java index 580a9867..4ad92d12 100644 --- a/common/buildcraft/energy/GuiHandler.java +++ b/common/buildcraft/energy/GuiHandler.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.energy; import net.minecraft.entity.player.EntityPlayer; @@ -17,7 +25,7 @@ public class GuiHandler implements IGuiHandler { if (!world.blockExists(x, y, z)) return null; - TileEntity tile = world.getBlockTileEntity(x, y, z); + TileEntity tile = world.getTileEntity(x, y, z); if (!(tile instanceof TileEngineWithInventory)) return null; @@ -42,7 +50,7 @@ public class GuiHandler implements IGuiHandler { if (!world.blockExists(x, y, z)) return null; - TileEntity tile = world.getBlockTileEntity(x, y, z); + TileEntity tile = world.getTileEntity(x, y, z); if (!(tile instanceof TileEngineWithInventory)) return null; diff --git a/common/buildcraft/energy/ItemBucketBuildcraft.java b/common/buildcraft/energy/ItemBucketBuildcraft.java index 8501e23d..6b41b9ea 100644 --- a/common/buildcraft/energy/ItemBucketBuildcraft.java +++ b/common/buildcraft/energy/ItemBucketBuildcraft.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.energy; @@ -11,7 +12,9 @@ import buildcraft.core.CreativeTabBuildCraft; import buildcraft.core.utils.StringUtils; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.block.Block; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemBucket; import net.minecraft.item.ItemStack; @@ -20,14 +23,14 @@ public class ItemBucketBuildcraft extends ItemBucket { private String iconName; - public ItemBucketBuildcraft(int i, int blockId) { - super(i, blockId); + public ItemBucketBuildcraft(Block block) { + super(block); setCreativeTab(CreativeTabBuildCraft.MACHINES.get()); - setContainerItem(Item.bucketEmpty); + setContainerItem(Items.bucket); } @Override - public String getItemDisplayName(ItemStack itemstack) { + public String getItemStackDisplayName(ItemStack itemstack) { return StringUtils.localize(getUnlocalizedName(itemstack)); } @@ -39,7 +42,7 @@ public class ItemBucketBuildcraft extends ItemBucket { @Override @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister par1IconRegister) { + public void registerIcons(IIconRegister par1IconRegister) { this.itemIcon = par1IconRegister.registerIcon("buildcraft:" + iconName); } } diff --git a/common/buildcraft/energy/ItemEngine.java b/common/buildcraft/energy/ItemEngine.java index a32bbe73..c0307673 100644 --- a/common/buildcraft/energy/ItemEngine.java +++ b/common/buildcraft/energy/ItemEngine.java @@ -1,21 +1,21 @@ -/** - * Copyright (c) SpaceToad, 2011 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * - * BuildCraft is distributed under the terms of the Minecraft Mod Public + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.energy; import buildcraft.core.ItemBlockBuildCraft; +import net.minecraft.block.Block; import net.minecraft.item.ItemStack; public class ItemEngine extends ItemBlockBuildCraft { - public ItemEngine(int i) { - super(i); + public ItemEngine(Block block) { + super(block); setMaxDamage(0); setHasSubtypes(true); } diff --git a/common/buildcraft/energy/TileEnergyEmitter.java b/common/buildcraft/energy/TileEnergyEmitter.java index e58be9fb..eb2e2ef7 100755 --- a/common/buildcraft/energy/TileEnergyEmitter.java +++ b/common/buildcraft/energy/TileEnergyEmitter.java @@ -21,7 +21,6 @@ import buildcraft.core.network.RPC; import buildcraft.core.network.RPCHandler; import buildcraft.core.network.RPCMessageInfo; import buildcraft.core.network.RPCSide; -import buildcraft.core.proxy.CoreProxy; public class TileEnergyEmitter extends TileBuildCraft { @@ -56,7 +55,7 @@ public class TileEnergyEmitter extends TileBuildCraft { public void initialize () { super.initialize(); - if (CoreProxy.proxy.isRenderWorld(worldObj)) { + if (worldObj.isRemote) { RPCHandler.rpcServer(this, "requestLasers"); } } @@ -65,7 +64,7 @@ public class TileEnergyEmitter extends TileBuildCraft { public void updateEntity() { super.updateEntity(); - if (CoreProxy.proxy.isRenderWorld(worldObj)) { + if (worldObj.isRemote) { for (Target t : targets.values()) { if (t.data.isVisible) { t.data.update(); @@ -118,7 +117,7 @@ public class TileEnergyEmitter extends TileBuildCraft { if (syncMJ.markTimeIfDelay(worldObj)) { RPCHandler.rpcBroadcastPlayers(this, "synchronizeMJ", mjAcc - / (float) accumulated); + / accumulated); mjAcc = 0; accumulated = 0; } diff --git a/common/buildcraft/energy/TileEnergyReceiver.java b/common/buildcraft/energy/TileEnergyReceiver.java index 59d05ae8..328112bc 100755 --- a/common/buildcraft/energy/TileEnergyReceiver.java +++ b/common/buildcraft/energy/TileEnergyReceiver.java @@ -11,7 +11,7 @@ package buildcraft.energy; import java.util.LinkedList; import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; import buildcraft.api.power.IPowerReceptor; import buildcraft.api.power.PowerHandler; import buildcraft.api.power.PowerHandler.PowerReceiver; diff --git a/common/buildcraft/energy/TileEngine.java b/common/buildcraft/energy/TileEngine.java index 0b45163f..9410ea1f 100644 --- a/common/buildcraft/energy/TileEngine.java +++ b/common/buildcraft/energy/TileEngine.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.energy; @@ -14,7 +15,8 @@ import net.minecraft.inventory.ICrafting; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; +import buildcraft.BuildCraftBuilders; import buildcraft.BuildCraftEnergy; import buildcraft.api.gates.IOverrideDefaultTriggers; import buildcraft.api.gates.ITrigger; @@ -40,10 +42,10 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto public static final ResourceLocation IRON_TEXTURE = new ResourceLocation(DefaultProps.TEXTURE_PATH_BLOCKS + "/base_iron.png"); public enum EnergyStage { - BLUE, GREEN, YELLOW, RED, OVERHEAT; public static final EnergyStage[] VALUES = values(); } + public static final float MIN_HEAT = 20; public static final float IDEAL_HEAT = 100; public static final float MAX_HEAT = 250; @@ -72,7 +74,7 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto @Override public void initialize() { - if (!CoreProxy.proxy.isRenderWorld(worldObj)) { + if (!worldObj.isRemote) { powerHandler.configure(minEnergyReceived(), maxEnergyReceived(), 1, getMaxEnergy()); checkRedstonePower(); } @@ -103,7 +105,7 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto } public final EnergyStage getEnergyStage() { - if (CoreProxy.proxy.isSimulating(worldObj)) { + if (!worldObj.isRemote) { if (energyStage == EnergyStage.OVERHEAT) return energyStage; EnergyStage newStage = computeEnergyStage(); @@ -134,8 +136,10 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto } public float getPistonSpeed() { - if (CoreProxy.proxy.isSimulating(worldObj)) + if (!worldObj.isRemote) { return Math.max(0.16f * getHeatLevel(), 0.01f); + } + switch (getEnergyStage()) { case BLUE: return 0.02F; @@ -154,7 +158,7 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto public void updateEntity() { super.updateEntity(); - if (CoreProxy.proxy.isRenderWorld(worldObj)) { + if (worldObj.isRemote) { if (progressPart != 0) { progress += getPistonSpeed(); @@ -162,21 +166,26 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto progressPart = 0; progress = 0; } - } else if (this.isPumping) + } else if (this.isPumping) { progressPart = 1; + } return; } if (checkOrienation) { checkOrienation = false; - if (!isOrientationValid()) + + if (!isOrientationValid()) { switchOrientation(true); + } } - if (!isRedstonePowered) - if (energy > 1) + if (!isRedstonePowered) { + if (energy > 1) { energy--; + } + } updateHeatLevel(); getEnergyStage(); @@ -194,17 +203,20 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto progress = 0; progressPart = 0; } - } else if (isRedstonePowered && isActive()) - if (isPoweredTile(tile, orientation)) + } else if (isRedstonePowered && isActive()) { + if (isPoweredTile(tile, orientation)) { if (getPowerToExtract() > 0) { progressPart = 1; setPumping(true); - } else + } else { setPumping(false); - else + } + } else { setPumping(false); - else + } + } else { setPumping(false); + } // Uncomment for constant power // if (isRedstonePowered && isActive()) { @@ -245,10 +257,11 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto protected void engineUpdate() { if (!isRedstonePowered) - if (energy >= 1) + if (energy >= 1) { energy -= 1; - else if (energy < 1) + } else if (energy < 1) { energy = 0; + } } public boolean isActive() { @@ -256,8 +269,9 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto } protected final void setPumping(boolean isActive) { - if (this.isPumping == isActive) + if (this.isPumping == isActive) { return; + } this.isPumping = isActive; sendNetworkUpdate(); @@ -265,13 +279,16 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto public boolean isOrientationValid() { TileEntity tile = getTileBuffer(orientation).getTile(); + return isPoweredTile(tile, orientation); } public boolean switchOrientation(boolean preferPipe) { - if (preferPipe && switchOrientation_do(true)) + if (preferPipe && switchOrientation_do(true)) { return true; - return switchOrientation_do(false); + } else { + return switchOrientation_do(false); + } } private boolean switchOrientation_do(boolean pipesOnly) { @@ -283,17 +300,20 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto if ((!pipesOnly || tile instanceof IPipeTile) && isPoweredTile(tile, o)) { orientation = o; worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, worldObj.getBlockId(xCoord, yCoord, zCoord)); + worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); return true; } } + return false; } public TileBuffer getTileBuffer(ForgeDirection side) { - if (tileCache == null) + if (tileCache == null) { tileCache = TileBuffer.makeBuffer(worldObj, xCoord, yCoord, zCoord, false); + } + return tileCache[side.ordinal()]; } @@ -314,15 +334,17 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto @Override public void readFromNBT(NBTTagCompound data) { super.readFromNBT(data); + orientation = ForgeDirection.getOrientation(data.getInteger("orientation")); progress = data.getFloat("progress"); energy = data.getDouble("energy"); - heat = data.getFloat("heat"); + heat = data.getFloat("heat"); } @Override public void writeToNBT(NBTTagCompound data) { super.writeToNBT(data); + data.setInteger("orientation", orientation.ordinal()); data.setFloat("progress", progress); data.setDouble("energy", energy); @@ -369,8 +391,9 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto @Override public void doWork(PowerHandler workProvider) { - if (CoreProxy.proxy.isRenderWorld(worldObj)) + if (worldObj.isRemote) { return; + } addEnergy(powerHandler.useEnergy(1, maxEnergyReceived(), true) * 0.95F); } @@ -383,44 +406,53 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto worldObj.setBlockToAir(xCoord, yCoord, zCoord); } - if (energy > getMaxEnergy()) + if (energy > getMaxEnergy()) { energy = getMaxEnergy(); + } } public double extractEnergy(double min, double max, boolean doExtract) { - if (energy < min) + if (energy < min) { return 0; + } double actualMax; - if (max > maxEnergyExtracted()) + if (max > maxEnergyExtracted()) { actualMax = maxEnergyExtracted(); - else + } else { actualMax = max; + } - if (actualMax < min) + if (actualMax < min) { return 0; + } double extracted; if (energy >= actualMax) { extracted = actualMax; - if (doExtract) + + if (doExtract) { energy -= actualMax; + } } else { extracted = energy; - if (doExtract) + + if (doExtract) { energy = 0; + } } return extracted; } public boolean isPoweredTile(TileEntity tile, ForgeDirection side) { - if (tile instanceof IPowerReceptor) + if (tile instanceof IPowerReceptor) { return ((IPowerReceptor) tile).getPowerReceiver(side.getOpposite()) != null; - - return false; + } else { + return false; + } } public abstract double getMaxEnergy(); @@ -455,11 +487,13 @@ public abstract class TileEngine extends TileBuildCraft implements IPowerRecepto @Override public ConnectOverride overridePipeConnection(PipeType type, ForgeDirection with) { - if (type == PipeType.POWER) + if (type == PipeType.POWER) { return ConnectOverride.DEFAULT; - if (with == orientation) + } else if (with == orientation) { return ConnectOverride.DISCONNECT; - return ConnectOverride.DEFAULT; + } else { + return ConnectOverride.DEFAULT; + } } @Override diff --git a/common/buildcraft/energy/TileEngineIron.java b/common/buildcraft/energy/TileEngineIron.java index 67656185..e8e247b2 100644 --- a/common/buildcraft/energy/TileEngineIron.java +++ b/common/buildcraft/energy/TileEngineIron.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.energy; @@ -15,7 +16,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ResourceLocation; import net.minecraft.world.biome.BiomeGenBase; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidStack; @@ -72,7 +73,7 @@ public class TileEngineIron extends TileEngineWithInventory implements IFluidHan } ItemStack current = player.getCurrentEquippedItem(); if (current != null) { - if (CoreProxy.proxy.isSimulating(worldObj)) { + if (!worldObj.isRemote) { if (FluidUtils.handleRightClick(this, side, player, true, true)) { return true; } @@ -83,7 +84,7 @@ public class TileEngineIron extends TileEngineWithInventory implements IFluidHan } } } - if (!CoreProxy.proxy.isRenderWorld(worldObj)) { + if (!worldObj.isRemote) { player.openGui(BuildCraftEnergy.instance, GuiIds.ENGINE_IRON, worldObj, xCoord, yCoord, zCoord); } return true; @@ -96,7 +97,7 @@ public class TileEngineIron extends TileEngineWithInventory implements IFluidHan @Override public float getPistonSpeed() { - if (CoreProxy.proxy.isSimulating(worldObj)) { + if (!worldObj.isRemote) { return Math.max(0.07f * getHeatLevel(), 0.01f); } switch (getEnergyStage()) { @@ -148,7 +149,7 @@ public class TileEngineIron extends TileEngineWithInventory implements IFluidHan lastPowered = true; - if (burnTime > 0 || fuel.amount > 0) { + if (burnTime > 0 || (fuel != null && fuel.amount > 0)) { if (burnTime > 0) { burnTime--; } @@ -425,7 +426,15 @@ public class TileEngineIron extends TileEngineWithInventory implements IFluidHan triggers.add(BuildCraftCore.triggerContainsFluid); triggers.add(BuildCraftCore.triggerSpaceFluid); triggers.add(BuildCraftCore.triggerFullFluid); + triggers.add(BuildCraftCore.triggerFluidContainerBelow25); + triggers.add(BuildCraftCore.triggerFluidContainerBelow50); + triggers.add(BuildCraftCore.triggerFluidContainerBelow75); return triggers; } + + @Override + public boolean hasCustomInventoryName() { + return false; + } } diff --git a/common/buildcraft/energy/TileEngineLegacy.java b/common/buildcraft/energy/TileEngineLegacy.java index 0313800b..6756df4b 100644 --- a/common/buildcraft/energy/TileEngineLegacy.java +++ b/common/buildcraft/energy/TileEngineLegacy.java @@ -1,12 +1,14 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.energy; +import buildcraft.BuildCraftEnergy; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; @@ -15,8 +17,6 @@ import net.minecraft.util.ResourceLocation; * This class is just intended to update pre 4.0 engines to the design. * * It can be deleted someday. - * - * @author CovertJaguar */ public class TileEngineLegacy extends TileEngine { @@ -24,8 +24,8 @@ public class TileEngineLegacy extends TileEngine { @Override public void updateEntity() { - worldObj.removeBlockTileEntity(xCoord, yCoord, zCoord); - TileEntity newTile = worldObj.getBlockTileEntity(xCoord, yCoord, zCoord); + worldObj.removeTileEntity(xCoord, yCoord, zCoord); + TileEntity newTile = worldObj.getTileEntity(xCoord, yCoord, zCoord); if (newTile instanceof TileEngine) { newTile.readFromNBT(nbt); sendNetworkUpdate(); diff --git a/common/buildcraft/energy/TileEngineStone.java b/common/buildcraft/energy/TileEngineStone.java index 21988f4f..89c24e1a 100644 --- a/common/buildcraft/energy/TileEngineStone.java +++ b/common/buildcraft/energy/TileEngineStone.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.energy; @@ -15,7 +16,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntityFurnace; import net.minecraft.util.ResourceLocation; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; import buildcraft.BuildCraftCore; import buildcraft.BuildCraftEnergy; import buildcraft.api.gates.ITrigger; @@ -43,7 +44,7 @@ public class TileEngineStone extends TileEngineWithInventory { @Override public boolean onBlockActivated(EntityPlayer player, ForgeDirection side) { - if (!CoreProxy.proxy.isRenderWorld(worldObj)) { + if (!worldObj.isRemote) { player.openGui(BuildCraftEnergy.instance, GuiIds.ENGINE_STONE, worldObj, xCoord, yCoord, zCoord); } return true; @@ -162,4 +163,9 @@ public class TileEngineStone extends TileEngineWithInventory { return triggers; } + + @Override + public boolean hasCustomInventoryName() { + return false; + } } \ No newline at end of file diff --git a/common/buildcraft/energy/TileEngineWithInventory.java b/common/buildcraft/energy/TileEngineWithInventory.java index 5469c1b2..87b42808 100644 --- a/common/buildcraft/energy/TileEngineWithInventory.java +++ b/common/buildcraft/energy/TileEngineWithInventory.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.energy; import net.minecraft.entity.player.EntityPlayer; @@ -47,7 +55,7 @@ public abstract class TileEngineWithInventory extends TileEngine implements IInv } @Override - public String getInvName() { + public String getInventoryName() { return "Engine"; } @@ -58,15 +66,15 @@ public abstract class TileEngineWithInventory extends TileEngine implements IInv @Override public boolean isUseableByPlayer(EntityPlayer entityplayer) { - return worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) == this; + return worldObj.getTileEntity(xCoord, yCoord, zCoord) == this; } @Override - public void openChest() { + public void openInventory() { } @Override - public void closeChest() { + public void closeInventory() { } @Override diff --git a/common/buildcraft/energy/TileEngineWood.java b/common/buildcraft/energy/TileEngineWood.java index a610a660..f0910115 100644 --- a/common/buildcraft/energy/TileEngineWood.java +++ b/common/buildcraft/energy/TileEngineWood.java @@ -1,15 +1,16 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.energy; import buildcraft.api.power.PowerHandler; import net.minecraft.util.ResourceLocation; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; import buildcraft.api.transport.IPipeTile.PipeType; import buildcraft.core.proxy.CoreProxy; @@ -52,7 +53,7 @@ public class TileEngineWood extends TileEngine { @Override public float getPistonSpeed() { - if (CoreProxy.proxy.isSimulating(worldObj)) + if (!worldObj.isRemote) return Math.max(0.08f * getHeatLevel(), 0.01f); switch (getEnergyStage()) { case GREEN: diff --git a/common/buildcraft/energy/TilePollution.java b/common/buildcraft/energy/TilePollution.java deleted file mode 100644 index ac0f3dfe..00000000 --- a/common/buildcraft/energy/TilePollution.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Copyright (c) SpaceToad, 2011 - * http://www.mod-buildcraft.com - * - * BuildCraft is distributed under the terms of the Minecraft Mod Public - * License 1.0, or MMPL. Please check the contents of the license located in - * http://www.mod-buildcraft.com/MMPL-1.0.txt - */ - -package buildcraft.energy; - -import buildcraft.BuildCraftEnergy; -import buildcraft.api.core.SafeTimeTracker; -import buildcraft.core.BlockIndex; -import net.minecraft.tileentity.TileEntity; - -public class TilePollution extends TileEntity { - - public boolean init = false; - public SafeTimeTracker timeTracker = new SafeTimeTracker(); - public int saturation = 0; /* from 0 to 100 */ - - @Override - public void updateEntity() { - if (!init) { - init = true; - timeTracker.markTime(worldObj); - BlockIndex index = new BlockIndex(xCoord, yCoord, zCoord); - - if (BuildCraftEnergy.saturationStored.containsKey(index)) { - saturation = BuildCraftEnergy.saturationStored.remove(index); - } else { - saturation = 1; - } - } else { - if (timeTracker.markTimeIfDelay(worldObj, 20)) { - // int remaining = BuildCraftEnergy.createPollution(worldObj, - // xCoord, yCoord, zCoord, saturation); - // - // saturation = remaining; - // - // if (remaining == 0) { - // worldObj.setBlockWithNotify(xCoord, yCoord, zCoord, 0); - // } else { - // worldObj.setBlockMetadata(xCoord, yCoord, zCoord, - // saturation * 16 / 100); - // worldObj.markBlockNeedsUpdate(zCoord, yCoord, zCoord); - // } - } - } - - } - -} diff --git a/common/buildcraft/energy/gui/ContainerEngine.java b/common/buildcraft/energy/gui/ContainerEngine.java index 5b8d017a..9666230e 100644 --- a/common/buildcraft/energy/gui/ContainerEngine.java +++ b/common/buildcraft/energy/gui/ContainerEngine.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.energy.gui; diff --git a/common/buildcraft/energy/gui/GuiCombustionEngine.java b/common/buildcraft/energy/gui/GuiCombustionEngine.java index 3566aab9..6357bc53 100644 --- a/common/buildcraft/energy/gui/GuiCombustionEngine.java +++ b/common/buildcraft/energy/gui/GuiCombustionEngine.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.energy.gui; @@ -11,7 +12,7 @@ import org.lwjgl.opengl.GL11; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.util.Icon; +import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; @@ -35,8 +36,8 @@ public class GuiCombustionEngine extends GuiEngine { protected void drawGuiContainerForegroundLayer(int par1, int par2) { super.drawGuiContainerForegroundLayer(par1, par2); String title = StringUtils.localize("tile.engineIron"); - fontRenderer.drawString(title, getCenteredOffset(title), 6, 0x404040); - fontRenderer.drawString(StringUtils.localize("gui.inventory"), 8, (ySize - 96) + 2, 0x404040); + fontRendererObj.drawString(title, getCenteredOffset(title), 6, 0x404040); + fontRendererObj.drawString(StringUtils.localize("gui.inventory"), 8, (ySize - 96) + 2, 0x404040); } @Override @@ -62,7 +63,7 @@ public class GuiCombustionEngine extends GuiEngine { } int start = 0; - Icon liquidIcon = null; + IIcon liquidIcon = null; Fluid fluid = liquid.getFluid(); if (fluid != null && fluid.getStillIcon() != null) { liquidIcon = fluid.getStillIcon(); diff --git a/common/buildcraft/energy/gui/GuiEngine.java b/common/buildcraft/energy/gui/GuiEngine.java index 1733d5ea..9abf7bb4 100644 --- a/common/buildcraft/energy/gui/GuiEngine.java +++ b/common/buildcraft/energy/gui/GuiEngine.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.energy.gui; import buildcraft.BuildCraftCore; @@ -41,13 +49,13 @@ public abstract class GuiEngine extends GuiBuildCraft { if (!isFullyOpened()) return; - fontRenderer.drawStringWithShadow(StringUtils.localize("gui.energy"), x + 22, y + 8, headerColour); - fontRenderer.drawStringWithShadow(StringUtils.localize("gui.currentOutput") + ":", x + 22, y + 20, subheaderColour); - fontRenderer.drawString(String.format("%.1f MJ/t", engine.currentOutput), x + 22, y + 32, textColour); - fontRenderer.drawStringWithShadow(StringUtils.localize("gui.stored") + ":", x + 22, y + 44, subheaderColour); - fontRenderer.drawString(String.format("%.1f MJ", engine.getEnergyStored()), x + 22, y + 56, textColour); - fontRenderer.drawStringWithShadow(StringUtils.localize("gui.heat") + ":", x + 22, y + 68, subheaderColour); - fontRenderer.drawString(String.format("%.2f \u00B0C", engine.getHeat()), x + 22, y + 80, textColour); + fontRendererObj.drawStringWithShadow(StringUtils.localize("gui.energy"), x + 22, y + 8, headerColour); + fontRendererObj.drawStringWithShadow(StringUtils.localize("gui.currentOutput") + ":", x + 22, y + 20, subheaderColour); + fontRendererObj.drawString(String.format("%.1f MJ/t", engine.currentOutput), x + 22, y + 32, textColour); + fontRendererObj.drawStringWithShadow(StringUtils.localize("gui.stored") + ":", x + 22, y + 44, subheaderColour); + fontRendererObj.drawString(String.format("%.1f MJ", engine.getEnergyStored()), x + 22, y + 56, textColour); + fontRendererObj.drawStringWithShadow(StringUtils.localize("gui.heat") + ":", x + 22, y + 68, subheaderColour); + fontRendererObj.drawString(String.format("%.2f \u00B0C", engine.getHeat()), x + 22, y + 80, textColour); } diff --git a/common/buildcraft/energy/gui/GuiStoneEngine.java b/common/buildcraft/energy/gui/GuiStoneEngine.java index fa590286..7a2e72d0 100644 --- a/common/buildcraft/energy/gui/GuiStoneEngine.java +++ b/common/buildcraft/energy/gui/GuiStoneEngine.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.energy.gui; @@ -29,8 +30,8 @@ public class GuiStoneEngine extends GuiEngine { protected void drawGuiContainerForegroundLayer(int par1, int par2) { super.drawGuiContainerForegroundLayer(par1, par2); String title = StringUtils.localize("tile.engineStone"); - fontRenderer.drawString(title, getCenteredOffset(title), 6, 0x404040); - fontRenderer.drawString(StringUtils.localize("gui.inventory"), 8, (ySize - 96) + 2, 0x404040); + fontRendererObj.drawString(title, getCenteredOffset(title), 6, 0x404040); + fontRendererObj.drawString(StringUtils.localize("gui.inventory"), 8, (ySize - 96) + 2, 0x404040); } @Override diff --git a/common/buildcraft/energy/render/EntityDropParticleFX.java b/common/buildcraft/energy/render/EntityDropParticleFX.java index cf10bf93..fa49a890 100644 --- a/common/buildcraft/energy/render/EntityDropParticleFX.java +++ b/common/buildcraft/energy/render/EntityDropParticleFX.java @@ -1,12 +1,21 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.energy.render; import net.minecraft.client.particle.*; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.block.BlockFluid; +import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.util.MathHelper; import net.minecraft.world.World; +import net.minecraftforge.fluids.BlockFluidBase; @SideOnly(Side.CLIENT) public class EntityDropParticleFX extends EntityFX { @@ -80,10 +89,16 @@ public class EntityDropParticleFX extends EntityFX { this.motionZ *= 0.699999988079071D; } - Material material = this.worldObj.getBlockMaterial(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ)); + int x = MathHelper.floor_double(this.posX); + int y = MathHelper.floor_double(this.posY); + int z = MathHelper.floor_double(this.posZ); + Block block = worldObj.getBlock(x, y, z); + + Material material = block.getMaterial(); if (material.isLiquid() || material.isSolid()) { - double d0 = (double) ((float) (MathHelper.floor_double(this.posY) + 1) - BlockFluid.getFluidHeightPercent(this.worldObj.getBlockMetadata(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ)))); + double d0 = (double) ((float) (MathHelper.floor_double(this.posY) + 1) - ((BlockFluidBase) block) + .getFilledPercentage(worldObj, x, y, z)); if (this.posY < d0) { this.setDead(); diff --git a/common/buildcraft/energy/render/RenderEnergyEmitter.java b/common/buildcraft/energy/render/RenderEnergyEmitter.java index a0ba9c68..debba238 100755 --- a/common/buildcraft/energy/render/RenderEnergyEmitter.java +++ b/common/buildcraft/energy/render/RenderEnergyEmitter.java @@ -7,6 +7,13 @@ */ package buildcraft.energy.render; +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; +import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; + import org.lwjgl.opengl.GL11; import buildcraft.BuildCraftCore; @@ -16,11 +23,6 @@ import buildcraft.core.EntityLaser; import buildcraft.core.render.RenderLaser; import buildcraft.energy.TileEnergyEmitter; import buildcraft.energy.TileEnergyEmitter.Target; -import net.minecraft.client.model.ModelBase; -import net.minecraft.client.model.ModelRenderer; -import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ResourceLocation; public class RenderEnergyEmitter extends TileEntitySpecialRenderer { @@ -73,6 +75,7 @@ public class RenderEnergyEmitter extends TileEntitySpecialRenderer { GL11.glPopMatrix(); } + @Override public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f) { TileEnergyEmitter emitter = ((TileEnergyEmitter) tileentity); @@ -89,7 +92,7 @@ public class RenderEnergyEmitter extends TileEntitySpecialRenderer { for (Target t : emitter.targets.values()) { GL11.glPushMatrix(); GL11.glTranslated(0.5F, 0.5F, 0.5F); - RenderLaser.doRenderLaserWave(tileEntityRenderer.renderEngine, + RenderLaser.doRenderLaserWave(TileEntityRendererDispatcher.instance.field_147553_e, t.data, EntityLaser.LASER_TEXTURES[3]); GL11.glPopMatrix(); } diff --git a/common/buildcraft/energy/render/RenderEngine.java b/common/buildcraft/energy/render/RenderEngine.java index a72a96c8..8ab069de 100644 --- a/common/buildcraft/energy/render/RenderEngine.java +++ b/common/buildcraft/energy/render/RenderEngine.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.energy.render; @@ -15,17 +16,18 @@ import buildcraft.energy.TileEngine; import buildcraft.energy.TileEngine.EnergyStage; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; -import net.minecraft.client.renderer.tileentity.TileEntityRenderer; +import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; -import net.minecraftforge.common.ForgeDirection; -import static net.minecraftforge.common.ForgeDirection.DOWN; -import static net.minecraftforge.common.ForgeDirection.EAST; -import static net.minecraftforge.common.ForgeDirection.NORTH; -import static net.minecraftforge.common.ForgeDirection.SOUTH; -import static net.minecraftforge.common.ForgeDirection.UP; -import static net.minecraftforge.common.ForgeDirection.WEST; +import net.minecraftforge.common.util.ForgeDirection; +import static net.minecraftforge.common.util.ForgeDirection.DOWN; +import static net.minecraftforge.common.util.ForgeDirection.EAST; +import static net.minecraftforge.common.util.ForgeDirection.NORTH; +import static net.minecraftforge.common.util.ForgeDirection.SOUTH; +import static net.minecraftforge.common.util.ForgeDirection.UP; +import static net.minecraftforge.common.util.ForgeDirection.WEST; + import org.lwjgl.opengl.GL11; public class RenderEngine extends TileEntitySpecialRenderer implements IInventoryRenderer { @@ -84,7 +86,7 @@ public class RenderEngine extends TileEntitySpecialRenderer implements IInventor public RenderEngine(ResourceLocation baseTexture) { this(); this.baseTexture = baseTexture; - setTileEntityRenderer(TileEntityRenderer.instance); + field_147501_a = TileEntityRendererDispatcher.instance; } @Override diff --git a/common/buildcraft/energy/triggers/TriggerEngineHeat.java b/common/buildcraft/energy/triggers/TriggerEngineHeat.java index 8e8f5006..c1b76131 100644 --- a/common/buildcraft/energy/triggers/TriggerEngineHeat.java +++ b/common/buildcraft/energy/triggers/TriggerEngineHeat.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.energy.triggers; @@ -16,16 +17,16 @@ import buildcraft.energy.TileEngine.EnergyStage; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import java.util.Locale; -import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Icon; -import net.minecraftforge.common.ForgeDirection; +import net.minecraft.util.IIcon; +import net.minecraftforge.common.util.ForgeDirection; public class TriggerEngineHeat extends BCTrigger implements ITileTrigger { public EnergyStage stage; @SideOnly(Side.CLIENT) - private Icon icon; + private IIcon icon; public TriggerEngineHeat(EnergyStage stage) { super("buildcraft:engine.stage." + stage.name().toLowerCase(Locale.ENGLISH), "buildcraft.engine.stage." + stage.name().toLowerCase(Locale.ENGLISH)); @@ -51,13 +52,13 @@ public class TriggerEngineHeat extends BCTrigger implements ITileTrigger { @Override @SideOnly(Side.CLIENT) - public Icon getIcon() { + public IIcon getIcon() { return icon; } @Override @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister iconRegister) { + public void registerIcons(IIconRegister iconRegister) { icon = iconRegister.registerIcon("buildcraft:triggers/trigger_engineheat_" + stage.name().toLowerCase(Locale.ENGLISH)); } } diff --git a/common/buildcraft/energy/worldgen/BiomeGenOilDesert.java b/common/buildcraft/energy/worldgen/BiomeGenOilDesert.java index 170c50f7..7a23b977 100644 --- a/common/buildcraft/energy/worldgen/BiomeGenOilDesert.java +++ b/common/buildcraft/energy/worldgen/BiomeGenOilDesert.java @@ -1,14 +1,21 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.energy.worldgen; +import net.minecraft.world.biome.BiomeGenBase; import net.minecraft.world.biome.BiomeGenDesert; import net.minecraftforge.common.BiomeDictionary; -/** - * - * @author CovertJaguar - */ public class BiomeGenOilDesert extends BiomeGenDesert { + protected static final BiomeGenBase.Height height_OilDesert = new BiomeGenBase.Height(0.1F, 0.2F); + public static BiomeGenOilDesert makeBiome(int id) { BiomeGenOilDesert biome = new BiomeGenOilDesert(id); BiomeDictionary.registerBiomeType(biome, BiomeDictionary.Type.DESERT); @@ -23,6 +30,6 @@ public class BiomeGenOilDesert extends BiomeGenDesert { setBiomeName("Desert Oil Field"); setDisableRain(); setTemperatureRainfall(2.0F, 0.0F); - setMinMaxHeight(0.1F, 0.2F); + setHeight(height_OilDesert); } } diff --git a/common/buildcraft/energy/worldgen/BiomeGenOilOcean.java b/common/buildcraft/energy/worldgen/BiomeGenOilOcean.java index 963a4108..e2727db1 100644 --- a/common/buildcraft/energy/worldgen/BiomeGenOilOcean.java +++ b/common/buildcraft/energy/worldgen/BiomeGenOilOcean.java @@ -1,14 +1,21 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.energy.worldgen; +import net.minecraft.world.biome.BiomeGenBase; import net.minecraft.world.biome.BiomeGenOcean; import net.minecraftforge.common.BiomeDictionary; -/** - * - * @author CovertJaguar - */ public class BiomeGenOilOcean extends BiomeGenOcean { + protected static final BiomeGenBase.Height height_OilOcean = new BiomeGenBase.Height(0.1F, 0.2F); + public static BiomeGenOilOcean makeBiome(int id) { BiomeGenOilOcean biome = new BiomeGenOilOcean(id); BiomeDictionary.registerBiomeType(biome, BiomeDictionary.Type.WATER); @@ -21,6 +28,6 @@ public class BiomeGenOilOcean extends BiomeGenOcean { super(id); setBiomeName("Ocean Oil Field"); setColor(112); - setMinMaxHeight(-1.0F, 0.4F); + setHeight(height_Oceans); } } diff --git a/common/buildcraft/energy/worldgen/BiomeInitializer.java b/common/buildcraft/energy/worldgen/BiomeInitializer.java index bd6e630b..05bd9ce2 100644 --- a/common/buildcraft/energy/worldgen/BiomeInitializer.java +++ b/common/buildcraft/energy/worldgen/BiomeInitializer.java @@ -1,19 +1,23 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.energy.worldgen; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; import buildcraft.BuildCraftEnergy; -import net.minecraftforge.event.ForgeSubscribe; import net.minecraftforge.event.terraingen.WorldTypeEvent; -/** - * - * @author CovertJaguar - */ public class BiomeInitializer { public BiomeInitializer() { } - @ForgeSubscribe + @SubscribeEvent public void initBiomes(WorldTypeEvent.InitBiomeGens event) { if (BuildCraftEnergy.biomeOilDesert != null) { event.newBiomeGens[0] = new GenLayerAddOilDesert(event.seed, 1500L, event.newBiomeGens[0]); diff --git a/common/buildcraft/energy/worldgen/GenLayerAddOilDesert.java b/common/buildcraft/energy/worldgen/GenLayerAddOilDesert.java index 5e2bc8dd..f25f7855 100644 --- a/common/buildcraft/energy/worldgen/GenLayerAddOilDesert.java +++ b/common/buildcraft/energy/worldgen/GenLayerAddOilDesert.java @@ -1,13 +1,17 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.energy.worldgen; import buildcraft.BuildCraftEnergy; import net.minecraft.world.biome.BiomeGenBase; import net.minecraft.world.gen.layer.GenLayer; -/** - * - * @author CovertJaguar - */ public class GenLayerAddOilDesert extends GenLayerBiomeReplacer { protected static final double NOISE_FIELD_SCALE = 0.001; diff --git a/common/buildcraft/energy/worldgen/GenLayerAddOilOcean.java b/common/buildcraft/energy/worldgen/GenLayerAddOilOcean.java index cf0a1be7..e3e7c462 100644 --- a/common/buildcraft/energy/worldgen/GenLayerAddOilOcean.java +++ b/common/buildcraft/energy/worldgen/GenLayerAddOilOcean.java @@ -1,13 +1,17 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.energy.worldgen; import buildcraft.BuildCraftEnergy; import net.minecraft.world.biome.BiomeGenBase; import net.minecraft.world.gen.layer.GenLayer; -/** - * - * @author CovertJaguar - */ public class GenLayerAddOilOcean extends GenLayerBiomeReplacer { public static final double NOISE_FIELD_SCALE = 0.0005; diff --git a/common/buildcraft/energy/worldgen/GenLayerBiomeReplacer.java b/common/buildcraft/energy/worldgen/GenLayerBiomeReplacer.java index 934cd971..89851ab9 100644 --- a/common/buildcraft/energy/worldgen/GenLayerBiomeReplacer.java +++ b/common/buildcraft/energy/worldgen/GenLayerBiomeReplacer.java @@ -1,13 +1,17 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.energy.worldgen; import java.util.Random; import net.minecraft.world.gen.layer.GenLayer; import net.minecraft.world.gen.layer.IntCache; -/** - * - * @author CovertJaguar - */ public abstract class GenLayerBiomeReplacer extends GenLayer { public static final int OFFSET_RANGE = 500000; diff --git a/common/buildcraft/energy/worldgen/OilPopulate.java b/common/buildcraft/energy/worldgen/OilPopulate.java index 7e8377b9..b29ae03a 100644 --- a/common/buildcraft/energy/worldgen/OilPopulate.java +++ b/common/buildcraft/energy/worldgen/OilPopulate.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.energy.worldgen; @@ -13,10 +14,12 @@ import buildcraft.BuildCraftEnergy; import java.util.HashSet; import java.util.Random; import java.util.Set; + +import cpw.mods.fml.common.eventhandler.SubscribeEvent; import net.minecraft.block.Block; import net.minecraft.block.BlockFlower; -import net.minecraft.block.BlockFluid; import net.minecraft.block.material.Material; +import net.minecraft.init.Blocks; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; import net.minecraft.world.chunk.Chunk; @@ -25,13 +28,13 @@ import static net.minecraftforge.common.BiomeDictionary.Type.DESERT; import static net.minecraftforge.common.BiomeDictionary.Type.FOREST; import static net.minecraftforge.common.BiomeDictionary.Type.FROZEN; import static net.minecraftforge.common.BiomeDictionary.Type.WASTELAND; -import net.minecraftforge.common.EnumHelper; -import net.minecraftforge.common.ForgeDirection; -import net.minecraftforge.event.ForgeSubscribe; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.event.terraingen.PopulateChunkEvent; import net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType; import net.minecraftforge.event.terraingen.TerrainGen; +import net.minecraftforge.fluids.BlockFluidBase; import net.minecraftforge.fluids.IFluidBlock; +import net.minecraftforge.common.util.EnumHelper; public class OilPopulate { @@ -57,7 +60,7 @@ public class OilPopulate { excludedBiomes.add(BiomeGenBase.hell.biomeID); } - @ForgeSubscribe + @SubscribeEvent public void populate(PopulateChunkEvent.Pre event) { boolean doGen = TerrainGen.populate(event.chunkProvider, event.world, event.rand, event.chunkX, event.chunkX, event.hasVillageGenerated, EVENT_TYPE); @@ -150,7 +153,7 @@ public class OilPopulate { int distance = poolX * poolX + poolY * poolY + poolZ * poolZ; if (distance <= radiusSq) { - world.setBlock(poolX + wellX, poolY + wellY, poolZ + wellZ, BuildCraftEnergy.blockOil.blockID, 0, distance == radiusSq ? 3 : 2); + world.setBlock(poolX + wellX, poolY + wellY, poolZ + wellZ, BuildCraftEnergy.blockOil, 0, distance == radiusSq ? 3 : 2); } } } @@ -178,19 +181,19 @@ public class OilPopulate { baseY = wellY; } - if (makeSpring && world.getBlockId(wellX, baseY, wellZ) == Block.bedrock.blockID) { - world.setBlock(wellX, baseY, wellZ, BuildCraftCore.springBlock.blockID, 1, 3); + if (makeSpring && world.getBlock(wellX, baseY, wellZ) == Blocks.bedrock) { + world.setBlock(wellX, baseY, wellZ, BuildCraftCore.springBlock, 1, 3); } for (int y = baseY + 1; y <= maxHeight; ++y) { - world.setBlock(wellX, y, wellZ, BuildCraftEnergy.blockOil.blockID); + world.setBlock(wellX, y, wellZ, BuildCraftEnergy.blockOil); } if (type == GenType.LARGE) { for (int y = wellY; y <= maxHeight - wellHeight / 2; ++y) { - world.setBlock(wellX + 1, y, wellZ, BuildCraftEnergy.blockOil.blockID); - world.setBlock(wellX - 1, y, wellZ, BuildCraftEnergy.blockOil.blockID); - world.setBlock(wellX, y, wellZ + 1, BuildCraftEnergy.blockOil.blockID); - world.setBlock(wellX, y, wellZ - 1, BuildCraftEnergy.blockOil.blockID); + world.setBlock(wellX + 1, y, wellZ, BuildCraftEnergy.blockOil); + world.setBlock(wellX - 1, y, wellZ, BuildCraftEnergy.blockOil); + world.setBlock(wellX, y, wellZ + 1, BuildCraftEnergy.blockOil); + world.setBlock(wellX, y, wellZ - 1, BuildCraftEnergy.blockOil); } } @@ -200,8 +203,8 @@ public class OilPopulate { int lakeZ = z; int lakeY = groundLevel; - int blockId = world.getBlockId(lakeX, lakeY, lakeZ); - if (blockId == biome.topBlock) { + Block block = world.getBlock(lakeX, lakeY, lakeZ); + if (block == biome.topBlock) { generateSurfaceDeposit(world, rand, biome, lakeX, lakeY, lakeZ, 5 + rand.nextInt(10)); } } @@ -253,38 +256,45 @@ public class OilPopulate { } } - private boolean isReplaceableFluid(World world, int x, int y, int z) { - int blockId = world.getBlockId(x, y, z); - Block block = Block.blocksList[blockId]; - return (block instanceof BlockFluid || block instanceof IFluidBlock) && block.blockMaterial != Material.lava; + private boolean isReplaceableFluid(World world, int x, int y, int z) { + Block block = world.getBlock(x, y, z); + return (block instanceof BlockFluidBase || block instanceof IFluidBlock) && block.getMaterial() != Material.lava; } private boolean isOil(World world, int x, int y, int z) { - int blockId = world.getBlockId(x, y, z); - return (blockId == BuildCraftEnergy.blockOil.blockID); + Block block = world.getBlock(x, y, z); + return (block == BuildCraftEnergy.blockOil); } private boolean isReplaceableForLake(World world, BiomeGenBase biome, int x, int y, int z) { - int blockId = world.getBlockId(x, y, z); - if (blockId == 0) { + Block block = world.getBlock(x, y, z); + + if (block == null) { return true; } - if (blockId == biome.fillerBlock || blockId == biome.topBlock) { + + if (block == biome.fillerBlock || block == biome.topBlock) { return true; } - Block block = Block.blocksList[blockId]; - if (!block.blockMaterial.blocksMovement()) { - return true; - } - if (block.isGenMineableReplaceable(world, x, y, z, Block.stone.blockID)) { + + if (!block.getMaterial().blocksMovement()) { return true; } + + // TODO: The code below doesn't seem to have been replaced by something + // in 1.7.2 - to update or remove. + //if (block.isGenMineableReplaceable(world, x, y, z, Blocks.stone)) { + // return true; + //} + if (block instanceof BlockFlower) { return true; } - if (!world.isBlockOpaqueCube(x, y, z)) { + + if (!block.isOpaqueCube()) { return true; } + return false; } @@ -303,7 +313,7 @@ public class OilPopulate { } private void setOilWithProba(World world, BiomeGenBase biome, Random rand, float proba, int x, int y, int z, int depth) { - if (rand.nextFloat() <= proba && world.getBlockId(x, y - depth - 1, z) != 0) { + if (rand.nextFloat() <= proba && world.getBlock(x, y - depth - 1, z) != null) { if (isOilAdjacent(world, x, y, z)) { setOilColumnForLake(world, biome, x, y, z, depth, 3); } @@ -315,20 +325,20 @@ public class OilPopulate { if (!world.isAirBlock(x, y + 2, z)) { return; } - if (isReplaceableFluid(world, x, y, z) || world.isBlockSolidOnSide(x, y - 1, z, ForgeDirection.UP)) { - world.setBlock(x, y, z, BuildCraftEnergy.blockOil.blockID, 0, update); + if (isReplaceableFluid(world, x, y, z) || world.isSideSolid(x, y - 1, z, ForgeDirection.UP)) { + world.setBlock(x, y, z, BuildCraftEnergy.blockOil, 0, update); } else { return; } if (!world.isAirBlock(x, y + 1, z)) { - world.setBlock(x, y + 1, z, 0, 0, update); + world.setBlock(x, y + 1, z, Blocks.air, 0, update); } for (int d = 1; d <= depth - 1; d++) { - if (isReplaceableFluid(world, x, y - d, z) || !world.isBlockSolidOnSide(x, y - d - 1, z, ForgeDirection.UP)) { + if (isReplaceableFluid(world, x, y - d, z) || !world.isSideSolid(x, y - d - 1, z, ForgeDirection.UP)) { return; } - world.setBlock(x, y - d, z, BuildCraftEnergy.blockOil.blockID, 0, 2); + world.setBlock(x, y - d, z, BuildCraftEnergy.blockOil, 0, 2); } } } @@ -341,23 +351,28 @@ public class OilPopulate { int trimmedZ = z & 15; for (; y > 0; --y) { - int blockId = chunk.getBlockID(trimmedX, y, trimmedZ); - Block block = Block.blocksList[blockId]; - if (blockId == 0) { + Block block = chunk.getBlock(trimmedX, y, trimmedZ); + + if (block == null) { continue; } - if (block instanceof BlockFluid) { + + if (block instanceof BlockFluidBase) { return y; } + if (block instanceof IFluidBlock) { return y; } - if (!block.blockMaterial.blocksMovement()) { + + if (!block.getMaterial().blocksMovement()) { continue; } + if (block instanceof BlockFlower) { continue; } + return y - 1; } diff --git a/common/buildcraft/energy/worldgen/SimplexNoise.java b/common/buildcraft/energy/worldgen/SimplexNoise.java index f4196c0a..6fd47406 100644 --- a/common/buildcraft/energy/worldgen/SimplexNoise.java +++ b/common/buildcraft/energy/worldgen/SimplexNoise.java @@ -1,6 +1,14 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.energy.worldgen; -/* +/** * A speed-improved simplex noise algorithm for 2D, 3D and 4D in Java. * * Based on example code by Stefan Gustavson (stegu@itn.liu.se). @@ -16,7 +24,6 @@ package buildcraft.energy.worldgen; * attribution is appreciated. * */ - public class SimplexNoise { // Simplex noise in 2D, 3D and 4D private static Grad grad3[] = { new Grad(1, 1, 0), new Grad(-1, 1, 0), new Grad(1, -1, 0), new Grad(-1, -1, 0), new Grad(1, 0, 1), new Grad(-1, 0, 1), new Grad(1, 0, -1), new Grad(-1, 0, -1), new Grad(0, 1, 1), new Grad(0, -1, 1), new Grad(0, 1, -1), new Grad(0, -1, -1) }; diff --git a/common/buildcraft/factory/BlockAutoWorkbench.java b/common/buildcraft/factory/BlockAutoWorkbench.java index 45e1e90e..1f9b0b0c 100644 --- a/common/buildcraft/factory/BlockAutoWorkbench.java +++ b/common/buildcraft/factory/BlockAutoWorkbench.java @@ -1,12 +1,11 @@ /** - * Copyright (c) SpaceToad, 2011 + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.factory; import buildcraft.BuildCraftFactory; @@ -18,25 +17,25 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import java.util.ArrayList; import net.minecraft.block.material.Material; -import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Icon; +import net.minecraft.util.IIcon; import net.minecraft.world.World; public class BlockAutoWorkbench extends BlockBuildCraft { - Icon topTexture; - Icon sideTexture; + IIcon topTexture; + IIcon sideTexture; - public BlockAutoWorkbench(int i) { - super(i, Material.wood); + public BlockAutoWorkbench() { + super(Material.wood); setHardness(3.0F); } @Override - public Icon getIcon(int i, int j) { + public IIcon getIcon(int i, int j) { if (i == 1 || i == 0) return topTexture; else @@ -56,7 +55,7 @@ public class BlockAutoWorkbench extends BlockBuildCraft { return false; } - if (!CoreProxy.proxy.isRenderWorld(world)) { + if (!world.isRemote) { entityplayer.openGui(BuildCraftFactory.instance, GuiIds.AUTO_CRAFTING_TABLE, world, i, j, k); } @@ -64,18 +63,13 @@ public class BlockAutoWorkbench extends BlockBuildCraft { } @Override - public TileEntity createNewTileEntity(World var1) { + public TileEntity createNewTileEntity(World world, int metadata) { return new TileAutoWorkbench(); } - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - public void addCreativeItems(ArrayList itemList) { - itemList.add(new ItemStack(this)); - } @Override @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister par1IconRegister) + public void registerBlockIcons(IIconRegister par1IconRegister) { topTexture = par1IconRegister.registerIcon("buildcraft:autoWorkbench_top"); sideTexture = par1IconRegister.registerIcon("buildcraft:autoWorkbench_side"); diff --git a/common/buildcraft/factory/BlockFloodGate.java b/common/buildcraft/factory/BlockFloodGate.java index e78ff8bc..6cc5bf8f 100644 --- a/common/buildcraft/factory/BlockFloodGate.java +++ b/common/buildcraft/factory/BlockFloodGate.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.factory; @@ -13,33 +14,36 @@ import buildcraft.core.CreativeTabBuildCraft; import buildcraft.core.utils.Utils; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; + import java.util.ArrayList; + +import net.minecraft.block.Block; import net.minecraft.block.material.Material; -import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Icon; +import net.minecraft.util.IIcon; import net.minecraft.world.World; public class BlockFloodGate extends BlockBuildCraft { - private Icon textureTop; - private Icon textureBottom; - private Icon textureSide; + private IIcon textureTop; + private IIcon textureBottom; + private IIcon textureSide; - public BlockFloodGate(int i) { - super(i, Material.iron); + public BlockFloodGate() { + super(Material.iron); } @Override - public TileEntity createNewTileEntity(World var1) { + public TileEntity createNewTileEntity(World world, int metadata) { return new TileFloodGate(); } @Override - public Icon getIcon(int i, int j) { + public IIcon getIcon(int i, int j) { switch (i) { case 0: return textureBottom; @@ -51,14 +55,14 @@ public class BlockFloodGate extends BlockBuildCraft { } @Override - public void breakBlock(World world, int x, int y, int z, int par5, int par6) { + public void breakBlock(World world, int x, int y, int z, Block block, int par6) { Utils.preDestroyBlock(world, x, y, z); - super.breakBlock(world, x, y, z, par5, par6); + super.breakBlock(world, x, y, z, block, par6); } @Override public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer entityplayer, int par6, float par7, float par8, float par9) { - TileEntity tile = world.getBlockTileEntity(i, j, k); + TileEntity tile = world.getTileEntity(i, j, k); if (tile instanceof TileFloodGate) { TileFloodGate floodGate = (TileFloodGate) tile; @@ -81,23 +85,17 @@ public class BlockFloodGate extends BlockBuildCraft { } @Override - public void onNeighborBlockChange(World world, int x, int y, int z, int id) { - super.onNeighborBlockChange(world, x, y, z, id); - TileEntity tile = world.getBlockTileEntity(x, y, z); + public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { + super.onNeighborBlockChange(world, x, y, z, block); + TileEntity tile = world.getTileEntity(x, y, z); if (tile instanceof TileFloodGate) { - ((TileFloodGate) tile).onNeighborBlockChange(id); + ((TileFloodGate) tile).onNeighborBlockChange(block); } } - @SuppressWarnings({"unchecked", "rawtypes"}) - @Override - public void addCreativeItems(ArrayList itemList) { - itemList.add(new ItemStack(this)); - } - @Override @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister par1IconRegister) { + public void registerBlockIcons(IIconRegister par1IconRegister) { textureTop = par1IconRegister.registerIcon("buildcraft:floodgate_top"); textureBottom = par1IconRegister.registerIcon("buildcraft:floodgate_bottom"); textureSide = par1IconRegister.registerIcon("buildcraft:floodgate_side"); diff --git a/common/buildcraft/factory/BlockFrame.java b/common/buildcraft/factory/BlockFrame.java index 19a96c38..90503215 100644 --- a/common/buildcraft/factory/BlockFrame.java +++ b/common/buildcraft/factory/BlockFrame.java @@ -1,12 +1,11 @@ /** - * Copyright (c) SpaceToad, 2011 + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.factory; import buildcraft.BuildCraftCore; @@ -15,13 +14,16 @@ import buildcraft.core.IFramePipeConnection; import buildcraft.core.utils.Utils; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; + import java.util.List; import java.util.Random; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; -import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.MovingObjectPosition; @@ -31,8 +33,8 @@ import net.minecraft.world.World; public class BlockFrame extends Block implements IFramePipeConnection { - public BlockFrame(int i) { - super(i, Material.glass); + public BlockFrame() { + super(Material.glass); setHardness(0.5F); setTickRandomly(true); } @@ -44,7 +46,7 @@ public class BlockFrame extends Block implements IFramePipeConnection { int meta = world.getBlockMetadata(i, j, k); if (meta == 1 && random.nextInt(10) > 5) { - world.setBlock(i, j, k, 0); + world.setBlockToAir(i, j, k); } } @@ -59,8 +61,8 @@ public class BlockFrame extends Block implements IFramePipeConnection { } @Override - public int idDropped(int i, Random random, int j) { - return -1; + public Item getItemDropped(int i, Random random, int j) { + return null; } @Override @@ -183,18 +185,18 @@ public class BlockFrame extends Block implements IFramePipeConnection { @Override public boolean isPipeConnected(IBlockAccess blockAccess, int x1, int y1, int z1, int x2, int y2, int z2) { - return blockAccess.getBlockId(x2, y2, z2) == blockID; + return blockAccess.getBlock(x2, y2, z2) == this; } @SuppressWarnings({ "unchecked", "rawtypes" }) @Override - public void getSubBlocks(int id, CreativeTabs tab, List list) { + public void getSubBlocks(Item item, CreativeTabs tab, List list) { list.add(new ItemStack(this)); } @Override @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister par1IconRegister) + public void registerBlockIcons(IIconRegister par1IconRegister) { blockIcon = par1IconRegister.registerIcon("buildcraft:blockFrame"); } diff --git a/common/buildcraft/factory/BlockHopper.java b/common/buildcraft/factory/BlockHopper.java index 702989a0..c958c1be 100644 --- a/common/buildcraft/factory/BlockHopper.java +++ b/common/buildcraft/factory/BlockHopper.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.factory; import buildcraft.BuildCraftCore; @@ -10,23 +18,23 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import java.util.ArrayList; import net.minecraft.block.material.Material; -import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Icon; +import net.minecraft.util.IIcon; import net.minecraft.world.World; public class BlockHopper extends BlockBuildCraft { - private static Icon icon; + private static IIcon icon; - public BlockHopper(int blockId) { - super(blockId, Material.iron); + public BlockHopper() { + super(Material.iron); } @Override - public TileEntity createNewTileEntity(World var1) { + public TileEntity createNewTileEntity(World world, int metadata) { return new TileHopper(); } @@ -60,28 +68,22 @@ public class BlockHopper extends BlockBuildCraft { } } - if (!CoreProxy.proxy.isRenderWorld(world)) { + if (!world.isRemote) { entityplayer.openGui(BuildCraftFactory.instance, GuiIds.HOPPER, world, x, y, z); } return true; } - @SuppressWarnings({"unchecked", "rawtypes"}) - @Override - public void addCreativeItems(ArrayList itemList) { - itemList.add(new ItemStack(this)); - } - @Override @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister par1IconRegister) { + public void registerBlockIcons(IIconRegister par1IconRegister) { icon = par1IconRegister.registerIcon("buildcraft:hopperBottom"); } @Override @SideOnly(Side.CLIENT) - public Icon getIcon(int par1, int par2) { + public IIcon getIcon(int par1, int par2) { return icon; } } diff --git a/common/buildcraft/factory/BlockMiningWell.java b/common/buildcraft/factory/BlockMiningWell.java index dd80e671..ef8ef4f7 100644 --- a/common/buildcraft/factory/BlockMiningWell.java +++ b/common/buildcraft/factory/BlockMiningWell.java @@ -1,12 +1,11 @@ /** - * Copyright (c) SpaceToad, 2011 + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.factory; import buildcraft.BuildCraftFactory; @@ -15,30 +14,35 @@ import buildcraft.core.BlockBuildCraft; import buildcraft.core.utils.Utils; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; + import java.util.ArrayList; + +import net.minecraft.block.Block; import net.minecraft.block.material.Material; -import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Icon; +import net.minecraft.util.IIcon; import net.minecraft.world.World; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; public class BlockMiningWell extends BlockBuildCraft { - Icon textureFront, textureSides, textureBack, textureTop; + IIcon textureFront, textureSides, textureBack, textureTop; - public BlockMiningWell(int i) { - super(i, Material.ground); + public BlockMiningWell() { + super(Material.ground); setHardness(5F); setResistance(10F); - setStepSound(soundStoneFootstep); + + // TODO: set proper sound + //setStepSound(soundStoneFootstep); } @Override - public Icon getIcon(int i, int j) { + public IIcon getIcon(int i, int j) { if (j == 0 && i == 3) return textureFront; @@ -62,15 +66,15 @@ public class BlockMiningWell extends BlockBuildCraft { } @Override - public void breakBlock(World world, int x, int y, int z, int id, int meta) { - super.breakBlock(world, x, y, z, id, meta); + public void breakBlock(World world, int x, int y, int z, Block block, int meta) { + super.breakBlock(world, x, y, z, block, meta); removePipes(world, x, y, z); } public void removePipes(World world, int x, int y, int z) { for (int depth = y - 1; depth > 0; depth--) { - int pipeID = world.getBlockId(x, depth, z); - if (pipeID != BuildCraftFactory.plainPipeBlock.blockID) { + Block pipe = world.getBlock(x, depth, z); + if (pipe != BuildCraftFactory.plainPipeBlock) { break; } world.setBlockToAir(x, depth, z); @@ -78,19 +82,13 @@ public class BlockMiningWell extends BlockBuildCraft { } @Override - public TileEntity createNewTileEntity(World var1) { + public TileEntity createNewTileEntity(World world, int metadata) { return new TileMiningWell(); } - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - public void addCreativeItems(ArrayList itemList) { - itemList.add(new ItemStack(this)); - } - @Override @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister par1IconRegister) + public void registerBlockIcons(IIconRegister par1IconRegister) { textureFront = par1IconRegister.registerIcon("buildcraft:miningwell_front"); textureSides = par1IconRegister.registerIcon("buildcraft:miningwell_side"); diff --git a/common/buildcraft/factory/BlockPlainPipe.java b/common/buildcraft/factory/BlockPlainPipe.java index c49a6685..075e6b01 100644 --- a/common/buildcraft/factory/BlockPlainPipe.java +++ b/common/buildcraft/factory/BlockPlainPipe.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.factory; @@ -11,19 +12,22 @@ import buildcraft.core.CoreConstants; import buildcraft.core.IFramePipeConnection; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; + import java.util.List; import java.util.Random; + import net.minecraft.block.Block; import net.minecraft.block.material.Material; -import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.IBlockAccess; public class BlockPlainPipe extends Block implements IFramePipeConnection { - public BlockPlainPipe(int i) { - super(i, Material.glass); + public BlockPlainPipe() { + super(Material.glass); minX = CoreConstants.PIPE_MIN_POS; minY = 0.0; @@ -64,13 +68,13 @@ public class BlockPlainPipe extends Block implements IFramePipeConnection { @SuppressWarnings({ "unchecked", "rawtypes" }) @Override - public void getSubBlocks(int id, CreativeTabs tab, List list) { + public void getSubBlocks(Item item, CreativeTabs tab, List list) { list.add(new ItemStack(this)); } @Override @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister par1IconRegister) { + public void registerBlockIcons(IIconRegister par1IconRegister) { this.blockIcon = par1IconRegister.registerIcon("buildcraft:blockPlainPipe"); } } diff --git a/common/buildcraft/factory/BlockPump.java b/common/buildcraft/factory/BlockPump.java index e951ad48..1ba162d1 100644 --- a/common/buildcraft/factory/BlockPump.java +++ b/common/buildcraft/factory/BlockPump.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.factory; @@ -13,33 +14,36 @@ import buildcraft.core.CreativeTabBuildCraft; import buildcraft.core.utils.Utils; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; + import java.util.ArrayList; + +import net.minecraft.block.Block; import net.minecraft.block.material.Material; -import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Icon; +import net.minecraft.util.IIcon; import net.minecraft.world.World; public class BlockPump extends BlockBuildCraft { - private Icon textureTop; - private Icon textureBottom; - private Icon textureSide; + private IIcon textureTop; + private IIcon textureBottom; + private IIcon textureSide; - public BlockPump(int i) { - super(i, Material.iron); + public BlockPump() { + super(Material.iron); } @Override - public TileEntity createNewTileEntity(World var1) { + public TileEntity createNewTileEntity(World world, int metadata) { return new TilePump(); } @Override - public Icon getIcon(int i, int j) { + public IIcon getIcon(int i, int j) { switch (i) { case 0: return textureBottom; @@ -51,14 +55,14 @@ public class BlockPump extends BlockBuildCraft { } @Override - public void breakBlock(World world, int x, int y, int z, int par5, int par6) { + public void breakBlock(World world, int x, int y, int z, Block block, int par6) { Utils.preDestroyBlock(world, x, y, z); - super.breakBlock(world, x, y, z, par5, par6); + super.breakBlock(world, x, y, z, block, par6); } @Override public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer entityplayer, int par6, float par7, float par8, float par9) { - TileEntity tile = world.getBlockTileEntity(i, j, k); + TileEntity tile = world.getTileEntity(i, j, k); if (tile instanceof TilePump) { TilePump pump = (TilePump) tile; @@ -82,23 +86,17 @@ public class BlockPump extends BlockBuildCraft { } @Override - public void onNeighborBlockChange(World world, int x, int y, int z, int id) { - super.onNeighborBlockChange(world, x, y, z, id); - TileEntity tile = world.getBlockTileEntity(x, y, z); + public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { + super.onNeighborBlockChange(world, x, y, z, block); + TileEntity tile = world.getTileEntity(x, y, z); if (tile instanceof TilePump) { - ((TilePump) tile).onNeighborBlockChange(id); + ((TilePump) tile).onNeighborBlockChange(block); } } - @SuppressWarnings({"unchecked", "rawtypes"}) - @Override - public void addCreativeItems(ArrayList itemList) { - itemList.add(new ItemStack(this)); - } - @Override @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister par1IconRegister) { + public void registerBlockIcons(IIconRegister par1IconRegister) { textureTop = par1IconRegister.registerIcon("buildcraft:pump_top"); textureBottom = par1IconRegister.registerIcon("buildcraft:pump_bottom"); textureSide = par1IconRegister.registerIcon("buildcraft:pump_side"); diff --git a/common/buildcraft/factory/BlockQuarry.java b/common/buildcraft/factory/BlockQuarry.java index 08eb9c12..520f7721 100644 --- a/common/buildcraft/factory/BlockQuarry.java +++ b/common/buildcraft/factory/BlockQuarry.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.factory; @@ -16,31 +17,35 @@ import buildcraft.core.proxy.CoreProxy; import buildcraft.core.utils.Utils; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; + import java.util.ArrayList; + +import net.minecraft.block.Block; import net.minecraft.block.material.Material; -import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Icon; +import net.minecraft.util.IIcon; import net.minecraft.util.MathHelper; import net.minecraft.world.World; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; public class BlockQuarry extends BlockBuildCraft { - Icon textureTop; - Icon textureFront; - Icon textureSide; + IIcon textureTop; + IIcon textureFront; + IIcon textureSide; - public BlockQuarry(int i) { - super(i, Material.iron); + public BlockQuarry() { + super(Material.iron); setHardness(10F); setResistance(10F); - setStepSound(soundAnvilFootstep); + // TODO: set proper sound + //setStepSound(soundAnvilFootstep); } @Override @@ -51,13 +56,13 @@ public class BlockQuarry extends BlockBuildCraft { world.setBlockMetadataWithNotify(i, j, k, orientation.getOpposite().ordinal(), 1); if (entityliving instanceof EntityPlayer) { - TileQuarry tq = (TileQuarry) world.getBlockTileEntity(i, j, k); + TileQuarry tq = (TileQuarry) world.getTileEntity(i, j, k); tq.placedBy = (EntityPlayer) entityliving; } } @Override - public Icon getIcon(int i, int j) { + public IIcon getIcon(int i, int j) { // If no metadata is set, then this is an icon. if (j == 0 && i == 3) return textureFront; @@ -74,7 +79,7 @@ public class BlockQuarry extends BlockBuildCraft { } @Override - public TileEntity createNewTileEntity(World var1) { + public TileEntity createNewTileEntity(World world, int metadata) { return new TileQuarry(); } @@ -83,9 +88,9 @@ public class BlockQuarry extends BlockBuildCraft { if (!world.checkChunksExist(i - width2, j - width2, k - width2, i + width2, j + width2, k + width2)) return; - int blockID = world.getBlockId(i, j, k); + Block block = world.getBlock(i, j, k); - if (blockID != BuildCraftFactory.frameBlock.blockID) + if (block != BuildCraftFactory.frameBlock) return; int meta = world.getBlockMetadata(i, j, k); @@ -116,26 +121,26 @@ public class BlockQuarry extends BlockBuildCraft { } private void markFrameForDecay(World world, int x, int y, int z) { - if (world.getBlockId(x, y, z) == BuildCraftFactory.frameBlock.blockID) { + if (world.getBlock(x, y, z) == BuildCraftFactory.frameBlock) { world.setBlockMetadataWithNotify(x, y, z, 1, 0); } } @Override - public ArrayList getBlockDropped(World world, int x, int y, int z, int metadata, int fortune) { + public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) { if (BuildCraftFactory.quarryOneTimeUse) { return new ArrayList(); } - return super.getBlockDropped(world, x, y, z, metadata, fortune); + return super.getDrops(world, x, y, z, metadata, fortune); } @Override - public void breakBlock(World world, int i, int j, int k, int par5, int par6) { - - if (!CoreProxy.proxy.isSimulating(world)) + public void breakBlock(World world, int i, int j, int k, Block block, int par6) { + if (world.isRemote) { return; + } - TileEntity tile = world.getBlockTileEntity(i, j, k); + TileEntity tile = world.getTileEntity(i, j, k); if (tile instanceof TileQuarry) { TileQuarry quarry = (TileQuarry) tile; Box box = quarry.box; @@ -170,40 +175,12 @@ public class BlockQuarry extends BlockBuildCraft { Utils.preDestroyBlock(world, i, j, k); - // byte width = 1; - // int width2 = width + 1; - // - // if (world.checkChunksExist(i - width2, j - width2, k - width2, i + width2, j + width2, k + width2)) { - // - // boolean frameFound = false; - // for (int z = -width; z <= width; ++z) { - // - // for (int y = -width; y <= width; ++y) { - // - // for (int x = -width; x <= width; ++x) { - // - // int blockID = world.getBlockId(i + z, j + y, k + x); - // - // if (blockID == BuildCraftFactory.frameBlock.blockID) { - // searchFrames(world, i + z, j + y, k + x); - // frameFound = true; - // break; - // } - // } - // if (frameFound) - // break; - // } - // if (frameFound) - // break; - // } - // } - - super.breakBlock(world, i, j, k, par5, par6); + super.breakBlock(world, i, j, k, block, par6); } @Override public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer entityplayer, int par6, float par7, float par8, float par9) { - TileQuarry tile = (TileQuarry) world.getBlockTileEntity(i, j, k); + TileQuarry tile = (TileQuarry) world.getTileEntity(i, j, k); // Drop through if the player is sneaking if (entityplayer.isSneaking()) @@ -222,15 +199,9 @@ public class BlockQuarry extends BlockBuildCraft { return false; } - @SuppressWarnings({"unchecked", "rawtypes"}) - @Override - public void addCreativeItems(ArrayList itemList) { - itemList.add(new ItemStack(this)); - } - @Override @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister par1IconRegister) { + public void registerBlockIcons(IIconRegister par1IconRegister) { textureSide = par1IconRegister.registerIcon("buildcraft:quarry_side"); textureTop = par1IconRegister.registerIcon("buildcraft:quarry_top"); textureFront = par1IconRegister.registerIcon("buildcraft:quarry_front"); diff --git a/common/buildcraft/factory/BlockRefinery.java b/common/buildcraft/factory/BlockRefinery.java index c8d7682d..ea86fc96 100644 --- a/common/buildcraft/factory/BlockRefinery.java +++ b/common/buildcraft/factory/BlockRefinery.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.factory; @@ -17,30 +18,33 @@ import buildcraft.core.fluids.FluidUtils; import buildcraft.core.utils.Utils; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; + import java.util.ArrayList; + import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; -import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Icon; +import net.minecraft.util.IIcon; import net.minecraft.world.World; -import net.minecraftforge.common.ForgeDirection; -import static net.minecraftforge.common.ForgeDirection.EAST; -import static net.minecraftforge.common.ForgeDirection.NORTH; -import static net.minecraftforge.common.ForgeDirection.SOUTH; -import static net.minecraftforge.common.ForgeDirection.WEST; +import net.minecraftforge.common.util.ForgeDirection; +import static net.minecraftforge.common.util.ForgeDirection.EAST; +import static net.minecraftforge.common.util.ForgeDirection.NORTH; +import static net.minecraftforge.common.util.ForgeDirection.SOUTH; +import static net.minecraftforge.common.util.ForgeDirection.WEST; import net.minecraftforge.fluids.FluidContainerRegistry; public class BlockRefinery extends BlockContainer { - private static Icon icon; + private static IIcon icon; - public BlockRefinery(int i) { - super(i, Material.iron); + public BlockRefinery() { + super(Material.iron); setHardness(5F); setCreativeTab(CreativeTabBuildCraft.MACHINES.get()); @@ -66,7 +70,7 @@ public class BlockRefinery extends BlockContainer { } @Override - public TileEntity createNewTileEntity(World var1) { + public TileEntity createNewTileEntity(World world, int metadata) { return new TileRefinery(); } @@ -104,7 +108,7 @@ public class BlockRefinery extends BlockContainer { @Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { - TileEntity tile = world.getBlockTileEntity(x, y, z); + TileEntity tile = world.getTileEntity(x, y, z); if (!(tile instanceof TileRefinery)) return false; @@ -117,7 +121,7 @@ public class BlockRefinery extends BlockContainer { return true; } - if (current != null && current.itemID != Item.bucketEmpty.itemID) { + if (current != null && current.getItem() != Items.bucket) { if (!world.isRemote) { if (FluidUtils.handleRightClick((TileRefinery) tile, ForgeDirection.getOrientation(side), player, true, false)) return true; @@ -132,22 +136,16 @@ public class BlockRefinery extends BlockContainer { return true; } - - @SuppressWarnings({"unchecked", "rawtypes"}) - @Override - public void addCreativeItems(ArrayList itemList) { - itemList.add(new ItemStack(this)); - } - + @Override @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister par1IconRegister) { + public void registerBlockIcons(IIconRegister par1IconRegister) { icon = par1IconRegister.registerIcon("buildcraft:refineryBack"); } @Override @SideOnly(Side.CLIENT) - public Icon getIcon(int par1, int par2) { + public IIcon getIcon(int par1, int par2) { return icon; } } diff --git a/common/buildcraft/factory/BlockTank.java b/common/buildcraft/factory/BlockTank.java index 265e102a..8d480746 100644 --- a/common/buildcraft/factory/BlockTank.java +++ b/common/buildcraft/factory/BlockTank.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.factory; @@ -16,26 +17,26 @@ import cpw.mods.fml.relauncher.SideOnly; import java.util.ArrayList; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; -import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Icon; +import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidStack; public class BlockTank extends BlockContainer { - private Icon textureStackedSide; - private Icon textureBottomSide; - private Icon textureTop; + private IIcon textureStackedSide; + private IIcon textureBottomSide; + private IIcon textureTop; - public BlockTank(int i) { - super(i, Material.glass); + public BlockTank() { + super(Material.glass); setBlockBounds(0.125F, 0F, 0.125F, 0.875F, 1F, 0.875F); setHardness(0.5F); setCreativeTab(CreativeTabBuildCraft.MACHINES.get()); @@ -51,18 +52,14 @@ public class BlockTank extends BlockContainer { return false; } - public boolean isACube() { - return false; - } - @Override - public TileEntity createNewTileEntity(World var1) { + public TileEntity createNewTileEntity(World world, int metadata) { return new TileTank(); } @Override @SideOnly(Side.CLIENT) - public Icon getIcon(int par1, int par2) { + public IIcon getIcon(int par1, int par2) { switch (par1) { case 0: case 1: @@ -74,28 +71,28 @@ public class BlockTank extends BlockContainer { @SuppressWarnings({"all"}) @Override - public Icon getBlockTexture(IBlockAccess iblockaccess, int i, int j, int k, int l) { + public IIcon getIcon(IBlockAccess iblockaccess, int i, int j, int k, int l) { switch (l) { case 0: case 1: return textureTop; default: - if (iblockaccess.getBlockId(i, j - 1, k) == blockID) + if (iblockaccess.getBlock(i, j - 1, k) == this) { return textureStackedSide; - else + } else { return textureBottomSide; + } } } @Override public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer entityplayer, int par6, float par7, float par8, float par9) { - ItemStack current = entityplayer.inventory.getCurrentItem(); + if (current != null) { - FluidStack liquid = FluidContainerRegistry.getFluidForFilledItem(current); - TileTank tank = (TileTank) world.getBlockTileEntity(i, j, k); + TileTank tank = (TileTank) world.getTileEntity(i, j, k); // Handle filled containers if (liquid != null) { @@ -109,8 +106,8 @@ public class BlockTank extends BlockContainer { // Handle empty containers } else { - FluidStack available = tank.getTankInfo(ForgeDirection.UNKNOWN)[0].fluid; + if (available != null) { ItemStack filled = FluidContainerRegistry.fillFluidContainer(available, current); @@ -129,7 +126,9 @@ public class BlockTank extends BlockContainer { entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, filled); } } + tank.drain(ForgeDirection.UNKNOWN, liquid.amount, true); + return true; } } @@ -141,20 +140,16 @@ public class BlockTank extends BlockContainer { @Override public boolean shouldSideBeRendered(IBlockAccess world, int x, int y, int z, int side) { - if (side <= 1) - return world.getBlockId(x, y, z) != blockID; - return super.shouldSideBeRendered(world, x, y, z, side); - } - - @SuppressWarnings({"unchecked", "rawtypes"}) - @Override - public void addCreativeItems(ArrayList itemList) { - itemList.add(new ItemStack(this)); + if (side <= 1) { + return world.getBlock(x, y, z) != this; + } else { + return super.shouldSideBeRendered(world, x, y, z, side); + } } @Override @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister par1IconRegister) { + public void registerBlockIcons(IIconRegister par1IconRegister) { textureStackedSide = par1IconRegister.registerIcon("buildcraft:tank_stacked_side"); textureBottomSide = par1IconRegister.registerIcon("buildcraft:tank_bottom_side"); textureTop = par1IconRegister.registerIcon("buildcraft:tank_top"); @@ -162,11 +157,13 @@ public class BlockTank extends BlockContainer { @Override public int getLightValue(IBlockAccess world, int x, int y, int z) { - TileEntity tile = world.getBlockTileEntity(x, y, z); + TileEntity tile = world.getTileEntity(x, y, z); + if (tile instanceof TileTank) { TileTank tank = (TileTank) tile; return tank.getFluidLightLevel(); } + return super.getLightValue(world, x, y, z); } } diff --git a/common/buildcraft/factory/BptBlockAutoWorkbench.java b/common/buildcraft/factory/BptBlockAutoWorkbench.java index 4d43674c..1790af22 100644 --- a/common/buildcraft/factory/BptBlockAutoWorkbench.java +++ b/common/buildcraft/factory/BptBlockAutoWorkbench.java @@ -1,12 +1,11 @@ -/** - * Copyright (c) SpaceToad, 2011 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * - * BuildCraft is distributed under the terms of the Minecraft Mod Public + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.factory; import buildcraft.api.blueprints.BptBlock; @@ -33,7 +32,7 @@ public class BptBlockAutoWorkbench extends BptBlock { @Override public void initializeFromWorld(BptSlotInfo bptSlot, IBptContext context, int x, int y, int z) { - IInventory inventory = (IInventory) context.world().getBlockTileEntity(x, y, z); + IInventory inventory = (IInventory) context.world().getTileEntity(x, y, z); BptBlockUtils.initializeInventoryContents(bptSlot, context, inventory); } @@ -42,7 +41,7 @@ public class BptBlockAutoWorkbench extends BptBlock { public void buildBlock(BptSlotInfo slot, IBptContext context) { super.buildBlock(slot, context); - IInventory inventory = (IInventory) context.world().getBlockTileEntity(slot.x, slot.y, slot.z); + IInventory inventory = (IInventory) context.world().getTileEntity(slot.x, slot.y, slot.z); BptBlockUtils.buildInventoryContents(slot, context, inventory); } diff --git a/common/buildcraft/factory/BptBlockFrame.java b/common/buildcraft/factory/BptBlockFrame.java index 6f8c0e15..a0cb6c3d 100644 --- a/common/buildcraft/factory/BptBlockFrame.java +++ b/common/buildcraft/factory/BptBlockFrame.java @@ -1,12 +1,11 @@ -/** - * Copyright (c) SpaceToad, 2011 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * - * BuildCraft is distributed under the terms of the Minecraft Mod Public + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.factory; import buildcraft.api.blueprints.BptBlock; diff --git a/common/buildcraft/factory/BptBlockRefinery.java b/common/buildcraft/factory/BptBlockRefinery.java index 4b320c07..6135396b 100644 --- a/common/buildcraft/factory/BptBlockRefinery.java +++ b/common/buildcraft/factory/BptBlockRefinery.java @@ -1,17 +1,17 @@ /** - * BuildCraft is open-source. It is distributed under the terms of the - * BuildCraft Open Source License. It grants rights to read, modify, compile - * or run the code. It does *NOT* grant the right to redistribute this software - * or its modifications in any form, binary or source, except if expressively - * granted by the copyright holder. + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.factory; import buildcraft.api.blueprints.BptBlock; import buildcraft.api.blueprints.BptSlotInfo; import buildcraft.api.blueprints.IBptContext; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; @Deprecated public class BptBlockRefinery extends BptBlock { @@ -27,7 +27,7 @@ public class BptBlockRefinery extends BptBlock { @Override public void initializeFromWorld(BptSlotInfo slot, IBptContext context, int x, int y, int z) { - TileRefinery refinery = (TileRefinery) context.world().getBlockTileEntity(x, y, z); + TileRefinery refinery = (TileRefinery) context.world().getTileEntity(x, y, z); // slot.cpt.setInteger("filter0", refinery.getFilter(0)); // slot.cpt.setInteger("filter1", refinery.getFilter(1)); @@ -37,7 +37,7 @@ public class BptBlockRefinery extends BptBlock { public void buildBlock(BptSlotInfo slot, IBptContext context) { super.buildBlock(slot, context); - TileRefinery refinery = (TileRefinery) context.world().getBlockTileEntity(slot.x, slot.y, slot.z); + TileRefinery refinery = (TileRefinery) context.world().getTileEntity(slot.x, slot.y, slot.z); int filter0 = slot.cpt.getInteger("filter0"); int filter1 = slot.cpt.getInteger("filter1"); diff --git a/common/buildcraft/factory/BptBlockTank.java b/common/buildcraft/factory/BptBlockTank.java index 4ba90ca4..7f971d98 100644 --- a/common/buildcraft/factory/BptBlockTank.java +++ b/common/buildcraft/factory/BptBlockTank.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.factory; import buildcraft.api.blueprints.BptBlock; @@ -18,7 +26,7 @@ public class BptBlockTank extends BptBlock { @Override public void buildBlock(BptSlotInfo slot, IBptContext context) { - context.world().setBlock(slot.x, slot.y, slot.z, slot.blockId, slot.meta,1); + //context.world().setBlock(slot.x, slot.y, slot.z, slot.blockId, slot.meta,1); } } diff --git a/common/buildcraft/factory/EntityMechanicalArm.java b/common/buildcraft/factory/EntityMechanicalArm.java index 682373cf..c9141ee8 100644 --- a/common/buildcraft/factory/EntityMechanicalArm.java +++ b/common/buildcraft/factory/EntityMechanicalArm.java @@ -1,12 +1,11 @@ /** - * Copyright (c) SpaceToad, 2011 + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.factory; import buildcraft.core.EntityBlock; @@ -99,7 +98,7 @@ public class EntityMechanicalArm extends Entity { } private void findAndJoinQuarry() { - TileEntity te = worldObj.getBlockTileEntity((int) posX, (int) posY, (int) posZ); + TileEntity te = worldObj.getTileEntity((int) posX, (int) posY, (int) posZ); if (te != null && te instanceof TileQuarry) { parent = (TileQuarry) te; parent.setArm(this); diff --git a/common/buildcraft/factory/FactoryProxy.java b/common/buildcraft/factory/FactoryProxy.java index f150464b..fe27b477 100644 --- a/common/buildcraft/factory/FactoryProxy.java +++ b/common/buildcraft/factory/FactoryProxy.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.factory; import buildcraft.core.EntityBlock; diff --git a/common/buildcraft/factory/FactoryProxyClient.java b/common/buildcraft/factory/FactoryProxyClient.java index a988c1f5..19e54624 100644 --- a/common/buildcraft/factory/FactoryProxyClient.java +++ b/common/buildcraft/factory/FactoryProxyClient.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.factory; import buildcraft.BuildCraftFactory; @@ -13,14 +21,14 @@ import buildcraft.factory.render.RenderTank; import cpw.mods.fml.client.registry.ClientRegistry; import cpw.mods.fml.client.registry.RenderingRegistry; import java.lang.reflect.Method; -import net.minecraft.util.Icon; +import net.minecraft.util.IIcon; import net.minecraft.world.World; public class FactoryProxyClient extends FactoryProxy { - public static Icon pumpTexture; - public static Icon drillTexture; - public static Icon drillHeadTexture; + public static IIcon pumpTexture; + public static IIcon drillTexture; + public static IIcon drillHeadTexture; @Override public void initializeTileEntities() { diff --git a/common/buildcraft/factory/GuiHandler.java b/common/buildcraft/factory/GuiHandler.java index ae8be321..3d5f8a73 100644 --- a/common/buildcraft/factory/GuiHandler.java +++ b/common/buildcraft/factory/GuiHandler.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.factory; import buildcraft.core.GuiIds; @@ -20,7 +28,7 @@ public class GuiHandler implements IGuiHandler { if (!world.blockExists(x, y, z)) return null; - TileEntity tile = world.getBlockTileEntity(x, y, z); + TileEntity tile = world.getTileEntity(x, y, z); switch (ID) { @@ -50,7 +58,7 @@ public class GuiHandler implements IGuiHandler { if (!world.blockExists(x, y, z)) return null; - TileEntity tile = world.getBlockTileEntity(x, y, z); + TileEntity tile = world.getTileEntity(x, y, z); switch (ID) { diff --git a/common/buildcraft/factory/PumpDimensionList.java b/common/buildcraft/factory/PumpDimensionList.java index d8e5da4d..5a9aa236 100644 --- a/common/buildcraft/factory/PumpDimensionList.java +++ b/common/buildcraft/factory/PumpDimensionList.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.factory; import java.util.ArrayList; diff --git a/common/buildcraft/factory/TileAutoWorkbench.java b/common/buildcraft/factory/TileAutoWorkbench.java index 2dfc0171..48c7163a 100644 --- a/common/buildcraft/factory/TileAutoWorkbench.java +++ b/common/buildcraft/factory/TileAutoWorkbench.java @@ -1,12 +1,15 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.factory; +import com.mojang.authlib.GameProfile; + import buildcraft.core.TileBuildCraft; import buildcraft.core.inventory.InvUtils; import buildcraft.core.inventory.InventoryConcatenator; @@ -27,9 +30,9 @@ import net.minecraft.inventory.SlotCrafting; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.ChatMessageComponent; import net.minecraft.util.ChunkCoordinates; -import net.minecraftforge.common.ForgeDirection; +import net.minecraft.util.IChatComponent; +import net.minecraftforge.common.util.ForgeDirection; public class TileAutoWorkbench extends TileBuildCraft implements ISidedInventory { @@ -62,16 +65,16 @@ public class TileAutoWorkbench extends TileBuildCraft implements ISidedInventory private final class InternalPlayer extends EntityPlayer { public InternalPlayer() { - super(TileAutoWorkbench.this.worldObj, "[BuildCraft]"); + super(TileAutoWorkbench.this.worldObj, new GameProfile(null, "[BuildCraft]")); posX = TileAutoWorkbench.this.xCoord; posY = TileAutoWorkbench.this.yCoord + 1; posZ = TileAutoWorkbench.this.zCoord; } @Override - public void sendChatToPlayer(ChatMessageComponent var1) { + public void addChatMessage(IChatComponent var1) { } - + @Override public boolean canCommandSenderUseCommand(int var1, String var2) { return false; @@ -81,6 +84,8 @@ public class TileAutoWorkbench extends TileBuildCraft implements ISidedInventory public ChunkCoordinates getPlayerCoordinates() { return null; } + + } @Override @@ -109,7 +114,7 @@ public class TileAutoWorkbench extends TileBuildCraft implements ISidedInventory } @Override - public String getInvName() { + public String getInventoryName() { return ""; } @@ -120,7 +125,7 @@ public class TileAutoWorkbench extends TileBuildCraft implements ISidedInventory @Override public boolean isUseableByPlayer(EntityPlayer player) { - return worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) == this && player.getDistanceSq(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D) <= 64.0D; + return worldObj.getTileEntity(xCoord, yCoord, zCoord) == this && player.getDistanceSq(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D) <= 64.0D; } @Override @@ -183,7 +188,7 @@ public class TileAutoWorkbench extends TileBuildCraft implements ISidedInventory @Override public void updateEntity() { super.updateEntity(); - if (CoreProxy.proxy.isRenderWorld(worldObj)) { + if (worldObj.isRemote) { return; } @@ -269,16 +274,11 @@ public class TileAutoWorkbench extends TileBuildCraft implements ISidedInventory } @Override - public void openChest() { + public void openInventory() { } @Override - public void closeChest() { - } - - @Override - public boolean isInvNameLocalized() { - return false; + public void closeInventory() { } @Override @@ -326,4 +326,9 @@ public class TileAutoWorkbench extends TileBuildCraft implements ISidedInventory } return minStackSize <= 1; } + + @Override + public boolean hasCustomInventoryName() { + return false; + } } \ No newline at end of file diff --git a/common/buildcraft/factory/TileFloodGate.java b/common/buildcraft/factory/TileFloodGate.java index 7cb99338..57cfa131 100644 --- a/common/buildcraft/factory/TileFloodGate.java +++ b/common/buildcraft/factory/TileFloodGate.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.factory; @@ -15,13 +16,16 @@ import buildcraft.core.fluids.Tank; import buildcraft.core.proxy.CoreProxy; import buildcraft.core.utils.BlockUtil; import buildcraft.core.utils.Utils; + import java.util.Deque; import java.util.HashSet; import java.util.LinkedList; import java.util.Set; import java.util.TreeMap; + +import net.minecraft.block.Block; import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidRegistry; @@ -59,7 +63,7 @@ public class TileFloodGate extends TileBuildCraft implements IFluidHandler { public void updateEntity() { super.updateEntity(); - if (CoreProxy.proxy.isRenderWorld(worldObj)) + if (worldObj.isRemote) return; if (powered) @@ -95,9 +99,9 @@ public class TileFloodGate extends TileBuildCraft implements IFluidHandler { } private boolean placeFluid(int x, int y, int z, Fluid fluid) { - int blockId = worldObj.getBlockId(x, y, z); - if (canPlaceFluidAt(blockId, x, y, z)) { - boolean placed = worldObj.setBlock(x, y, z, FluidUtils.getFluidBlockId(fluid, true)); + Block block = worldObj.getBlock(x, y, z); + if (canPlaceFluidAt(block, x, y, z)) { + boolean placed = worldObj.setBlock(x, y, z, FluidUtils.getFluidBlock(fluid, true)); if (placed) { queueAdjacent(x, y, z); expandQueue(); @@ -178,21 +182,21 @@ public class TileFloodGate extends TileBuildCraft implements IFluidHandler { if ((x - xCoord) * (x - xCoord) + (z - zCoord) * (z - zCoord) > 64 * 64) return; - int blockId = worldObj.getBlockId(x, y, z); - if (BlockUtil.getFluid(blockId) == tank.getFluidType()) { + Block block = worldObj.getBlock(x, y, z); + if (BlockUtil.getFluid(block) == tank.getFluidType()) { fluidsFound.add(index); } - if (canPlaceFluidAt(blockId, x, y, z)) { + if (canPlaceFluidAt(block, x, y, z)) { getLayerQueue(y).addLast(index); } } } - private boolean canPlaceFluidAt(int blockId, int x, int y, int z) { - return BlockUtil.isSoftBlock(blockId, worldObj, x, y, z) && !BlockUtil.isFullFluidBlock(blockId, worldObj, x, y, z); + private boolean canPlaceFluidAt(Block block, int x, int y, int z) { + return BlockUtil.isSoftBlock(block, worldObj, x, y, z) && !BlockUtil.isFullFluidBlock(block, worldObj, x, y, z); } - public void onNeighborBlockChange(int id) { + public void onNeighborBlockChange(Block block) { boolean p = worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord); if (powered != p) { powered = p; diff --git a/common/buildcraft/factory/TileHopper.java b/common/buildcraft/factory/TileHopper.java index c375bd06..70dceb37 100644 --- a/common/buildcraft/factory/TileHopper.java +++ b/common/buildcraft/factory/TileHopper.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.factory; import net.minecraft.entity.player.EntityPlayer; @@ -5,7 +13,7 @@ import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; import buildcraft.core.TileBuildCraft; import buildcraft.core.inventory.ITransactor; import buildcraft.core.inventory.SimpleInventory; @@ -34,10 +42,10 @@ public class TileHopper extends TileBuildCraft implements IInventory { @Override public void updateEntity() { super.updateEntity(); - if (CoreProxy.proxy.isRenderWorld(worldObj) || worldObj.getTotalWorldTime() % 2 != 0) + if (worldObj.isRemote || worldObj.getTotalWorldTime() % 2 != 0) return; - TileEntity tile = this.worldObj.getBlockTileEntity(xCoord, yCoord - 1, zCoord); + TileEntity tile = this.getWorldObj().getTileEntity(xCoord, yCoord - 1, zCoord); if (tile == null) return; @@ -89,8 +97,8 @@ public class TileHopper extends TileBuildCraft implements IInventory { } @Override - public String getInvName() { - return _inventory.getInvName(); + public String getInventoryName() { + return _inventory.getInventoryName(); } @Override @@ -100,19 +108,24 @@ public class TileHopper extends TileBuildCraft implements IInventory { @Override public boolean isUseableByPlayer(EntityPlayer entityPlayer) { - return worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) == this && entityPlayer.getDistanceSq(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D) <= 64.0D; + return worldObj.getTileEntity(xCoord, yCoord, zCoord) == this && entityPlayer.getDistanceSq(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D) <= 64.0D; } @Override - public void openChest() { + public void openInventory() { } @Override - public void closeChest() { + public void closeInventory() { } @Override public boolean isItemValidForSlot(int i, ItemStack itemstack) { return true; } + + @Override + public boolean hasCustomInventoryName() { + return false; + } } diff --git a/common/buildcraft/factory/TileMiningWell.java b/common/buildcraft/factory/TileMiningWell.java index 03c8b3fd..59adaa8a 100644 --- a/common/buildcraft/factory/TileMiningWell.java +++ b/common/buildcraft/factory/TileMiningWell.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.factory; @@ -22,7 +23,7 @@ import java.util.List; import net.minecraft.entity.item.EntityItem; import net.minecraft.item.ItemStack; import net.minecraft.world.World; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; public class TileMiningWell extends TileBuildCraft implements IMachine, IPowerReceptor { @@ -51,7 +52,7 @@ public class TileMiningWell extends TileBuildCraft implements IMachine, IPowerRe int depth = yCoord - 1; - while (world.getBlockId(xCoord, depth, zCoord) == BuildCraftFactory.plainPipeBlock.blockID) { + while (world.getBlock(xCoord, depth, zCoord) == BuildCraftFactory.plainPipeBlock) { depth = depth - 1; } @@ -64,7 +65,7 @@ public class TileMiningWell extends TileBuildCraft implements IMachine, IPowerRe List stacks = BlockUtil.getItemStackFromBlock(worldObj, xCoord, depth, zCoord); - world.setBlock(xCoord, depth, zCoord, BuildCraftFactory.plainPipeBlock.blockID); + world.setBlock(xCoord, depth, zCoord, BuildCraftFactory.plainPipeBlock); if (wasAir) return; diff --git a/common/buildcraft/factory/TilePump.java b/common/buildcraft/factory/TilePump.java index 2baa9b3b..47f606a1 100644 --- a/common/buildcraft/factory/TilePump.java +++ b/common/buildcraft/factory/TilePump.java @@ -1,13 +1,15 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.factory; import buildcraft.BuildCraftCore; +import buildcraft.BuildCraftEnergy; import buildcraft.BuildCraftFactory; import buildcraft.api.core.SafeTimeTracker; import buildcraft.api.gates.IAction; @@ -29,6 +31,8 @@ import buildcraft.core.network.PacketUpdate; import buildcraft.core.proxy.CoreProxy; import buildcraft.core.utils.BlockUtil; import buildcraft.core.utils.Utils; +import io.netty.buffer.ByteBuf; + import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; @@ -37,10 +41,12 @@ import java.util.HashSet; import java.util.LinkedList; import java.util.Set; import java.util.TreeMap; + +import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidRegistry; @@ -50,7 +56,7 @@ import net.minecraftforge.fluids.IFluidHandler; public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor, IFluidHandler { - public static int REBUID_DELAY = 512; + public static final int REBUID_DELAY = 512; public static int MAX_LIQUID = FluidContainerRegistry.BUCKET_VOLUME * 16; EntityBlock tube; private TreeMap> pumpLayerQueues = new TreeMap>(); @@ -59,7 +65,7 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor int aimY = 0; private PowerHandler powerHandler; private TileBuffer[] tileBuffer = null; - private SafeTimeTracker timer = new SafeTimeTracker(); + private SafeTimeTracker timer = new SafeTimeTracker(REBUID_DELAY); private int tick = Utils.RANDOM.nextInt(); private int numFluidBlocksFound = 0; private boolean powered = false; @@ -81,19 +87,23 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor if (powered) { pumpLayerQueues.clear(); destroyTube(); - } else + } else { createTube(); + } - if (worldObj.isRemote) + if (worldObj.isRemote) { return; + } pushToConsumers(); - if(powered) + if (powered) { return; + } - if(tube == null) + if (tube == null) { return; + } if (tube.posY - aimY > 0.01) { tubeY = tube.posY - 0.01; @@ -103,17 +113,17 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor } tick++; - if (tick % 16 != 0) + + if (tick % 16 != 0) { return; + } BlockIndex index = getNextIndexToPump(false); FluidStack fluidToPump = index != null ? BlockUtil.drainBlock(worldObj, index.x, index.y, index.z, false) : null; if (fluidToPump != null) { if (isFluidAllowed(fluidToPump.getFluid()) && tank.fill(fluidToPump, false) == fluidToPump.amount) { - if (powerHandler.useEnergy(10, 10, true) == 10) { - if (fluidToPump.getFluid() != FluidRegistry.WATER || BuildCraftCore.consumeWaterSources || numFluidBlocksFound < 9) { index = getNextIndexToPump(true); BlockUtil.drainBlock(worldObj, index.x, index.y, index.z, true); @@ -125,7 +135,6 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor } else { if (tick % 128 == 0) { // TODO: improve that decision - rebuildQueue(); if (getNextIndexToPump(false) == null) { @@ -142,29 +151,37 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor } } - public void onNeighborBlockChange(int id) { + public void onNeighborBlockChange(Block block) { boolean p = worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord); + if (powered != p) { powered = p; - if(!worldObj.isRemote) + + if(!worldObj.isRemote) { sendNetworkUpdate(); + } } } private boolean isBlocked(int x, int y, int z) { - Material mat = worldObj.getBlockMaterial(x, y, z); + Material mat = worldObj.getBlock(x, y, z).getMaterial(); + return mat.blocksMovement(); } private void pushToConsumers() { - if (tileBuffer == null) + if (tileBuffer == null) { tileBuffer = TileBuffer.makeBuffer(worldObj, xCoord, yCoord, zCoord, false); + } + FluidUtils.pushFluidToConsumers(tank, 400, tileBuffer); } private TileEntity getTile(ForgeDirection side) { - if (tileBuffer == null) + if (tileBuffer == null) { tileBuffer = TileBuffer.makeBuffer(worldObj, xCoord, yCoord, zCoord, false); + } + return tileBuffer[side.ordinal()].getTile(); } @@ -188,8 +205,9 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor worldObj.spawnEntityInWorld(tube); - if (!worldObj.isRemote) + if (!worldObj.isRemote) { sendNetworkUpdate(); + } } } @@ -204,33 +222,39 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor private BlockIndex getNextIndexToPump(boolean remove) { if (pumpLayerQueues.isEmpty()) { - if (timer.markTimeIfDelay(worldObj, REBUID_DELAY)) { + if (timer.markTimeIfDelay(worldObj)) { rebuildQueue(); } + return null; } Deque topLayer = pumpLayerQueues.lastEntry().getValue(); if (topLayer != null) { - if (topLayer.isEmpty()) + if (topLayer.isEmpty()) { pumpLayerQueues.pollLastEntry(); + } + if (remove) { BlockIndex index = topLayer.pollLast(); return index; + } else { + return topLayer.peekLast(); } - return topLayer.peekLast(); + } else { + return null; } - - return null; } private Deque getLayerQueue(int layer) { Deque pumpQueue = pumpLayerQueues.get(layer); + if (pumpQueue == null) { pumpQueue = new LinkedList(); pumpLayerQueues.put(layer, pumpQueue); } + return pumpQueue; } @@ -239,13 +263,16 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor pumpLayerQueues.clear(); int x = xCoord; int y = aimY; - int z = zCoord; - Fluid pumpingFluid = BlockUtil.getFluid(worldObj.getBlockId(x, y, z)); - if (pumpingFluid == null) + int z = zCoord; + Fluid pumpingFluid = BlockUtil.getFluid(worldObj.getBlock(x, y, z)); + + if (pumpingFluid == null) { return; + } - if (pumpingFluid != tank.getAcceptedFluid() && tank.getAcceptedFluid() != null) + if (pumpingFluid != tank.getAcceptedFluid() && tank.getAcceptedFluid() != null) { return; + } Set visitedBlocks = new HashSet(); Deque fluidsFound = new LinkedList(); @@ -265,8 +292,11 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor queueForPumping(index.x, index.y, index.z + 1, visitedBlocks, fluidsFound, pumpingFluid); queueForPumping(index.x, index.y, index.z - 1, visitedBlocks, fluidsFound, pumpingFluid); - if (pumpingFluid == FluidRegistry.WATER && !BuildCraftCore.consumeWaterSources && numFluidBlocksFound >= 9) + if (pumpingFluid == FluidRegistry.WATER + && !BuildCraftCore.consumeWaterSources + && numFluidBlocksFound >= 9) { return; + } // if (System.nanoTime() > timeoutTime) // return; @@ -277,14 +307,17 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor public void queueForPumping(int x, int y, int z, Set visitedBlocks, Deque fluidsFound, Fluid pumpingFluid) { BlockIndex index = new BlockIndex(x, y, z); if (visitedBlocks.add(index)) { - if ((x - xCoord) * (x - xCoord) + (z - zCoord) * (z - zCoord) > 64 * 64) + if ((x - xCoord) * (x - xCoord) + (z - zCoord) * (z - zCoord) > 64 * 64) { return; + } - int blockId = worldObj.getBlockId(x, y, z); - if (BlockUtil.getFluid(blockId) == pumpingFluid) { + Block block = worldObj.getBlock(x, y, z); + + if (BlockUtil.getFluid(block) == pumpingFluid) { fluidsFound.add(index); } - if (canDrainBlock(blockId, x, y, z, pumpingFluid)) { + + if (canDrainBlock(block, x, y, z, pumpingFluid)) { getLayerQueue(y).add(index); numFluidBlocksFound++; } @@ -292,25 +325,31 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor } private boolean isPumpableFluid(int x, int y, int z) { - Fluid fluid = BlockUtil.getFluid(worldObj.getBlockId(x, y, z)); - if (fluid == null) + Fluid fluid = BlockUtil.getFluid(worldObj.getBlock(x, y, z)); + + if (fluid == null) { return false; - if (!isFluidAllowed(fluid)) + } else if (!isFluidAllowed(fluid)) { return false; - if (tank.getAcceptedFluid() != null && tank.getAcceptedFluid() != fluid) + } else if (tank.getAcceptedFluid() != null && tank.getAcceptedFluid() != fluid) { return false; - return true; + } else { + return true; + } } - private boolean canDrainBlock(int blockId, int x, int y, int z, Fluid fluid) { - if (!isFluidAllowed(fluid)) + private boolean canDrainBlock(Block block, int x, int y, int z, Fluid fluid) { + if (!isFluidAllowed(fluid)) { return false; + } - FluidStack fluidStack = BlockUtil.drainBlock(blockId, worldObj, x, y, z, false); - if (fluidStack == null || fluidStack.amount <= 0) + FluidStack fluidStack = BlockUtil.drainBlock(block, worldObj, x, y, z, false); + + if (fluidStack == null || fluidStack.amount <= 0) { return false; - - return fluidStack.getFluid() == fluid; + } else { + return fluidStack.getFluid() == fluid; + } } private boolean isFluidAllowed(Fluid fluid) { @@ -356,9 +395,9 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor if (next != null) { return isPumpableFluid(next.x, next.y, next.z); + } else { + return false; } - - return false; } @Override @@ -374,10 +413,10 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor public PacketPayload getPacketPayload() { PacketPayloadStream payload = new PacketPayloadStream(new PacketPayloadStream.StreamWriter() { @Override - public void writeData(DataOutputStream data) throws IOException { - data.writeInt(aimY); - data.writeFloat((float) tubeY); - data.writeBoolean(powered); + public void writeData(ByteBuf buf) { + buf.writeInt(aimY); + buf.writeFloat((float) tubeY); + buf.writeBoolean(powered); } }); @@ -387,7 +426,7 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor @Override public void handleUpdatePacket(PacketUpdate packet) throws IOException { PacketPayloadStream payload = (PacketPayloadStream) packet.payload; - DataInputStream data = payload.stream; + ByteBuf data = payload.stream; aimY = data.readInt(); tubeY = data.readFloat(); powered = data.readBoolean(); @@ -458,11 +497,13 @@ public class TilePump extends TileBuildCraft implements IMachine, IPowerReceptor @Override public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { - if (resource == null) + if (resource == null) { return null; - if (!resource.isFluidEqual(tank.getFluid())) + } else if (!resource.isFluidEqual(tank.getFluid())) { return null; - return drain(from, resource.amount, doDrain); + } else { + return drain(from, resource.amount, doDrain); + } } @Override diff --git a/common/buildcraft/factory/TileQuarry.java b/common/buildcraft/factory/TileQuarry.java index c30dd403..6818cf1d 100644 --- a/common/buildcraft/factory/TileQuarry.java +++ b/common/buildcraft/factory/TileQuarry.java @@ -1,32 +1,49 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.factory; +import java.util.LinkedList; +import java.util.List; +import java.util.ListIterator; +import java.util.Set; +import net.minecraft.block.Block; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.ChatComponentText; +import net.minecraft.world.ChunkCoordIntPair; +import net.minecraftforge.common.ForgeChunkManager; +import net.minecraftforge.common.ForgeChunkManager.Ticket; +import net.minecraftforge.common.ForgeChunkManager.Type; +import net.minecraftforge.common.util.ForgeDirection; import buildcraft.BuildCraftCore; import buildcraft.BuildCraftFactory; -import buildcraft.builders.blueprints.Blueprint; -import buildcraft.builders.blueprints.BlueprintBuilder; -import buildcraft.builders.blueprints.BlueprintBuilder.SchematicBuilder; import buildcraft.api.core.IAreaProvider; import buildcraft.api.core.LaserKind; import buildcraft.api.gates.IAction; import buildcraft.api.power.IPowerReceptor; import buildcraft.api.power.PowerHandler; import buildcraft.api.power.PowerHandler.PowerReceiver; +import buildcraft.builders.blueprints.Blueprint; +import buildcraft.builders.blueprints.BlueprintBuilder; +import buildcraft.builders.blueprints.BlueprintBuilder.SchematicBuilder; import buildcraft.core.Box; import buildcraft.core.CoreConstants; import buildcraft.core.DefaultAreaProvider; import buildcraft.core.IBuilderInventory; import buildcraft.core.IMachine; import buildcraft.core.TileBuildCraft; -import buildcraft.core.network.PacketUpdate; import buildcraft.core.network.NetworkData; +import buildcraft.core.network.PacketUpdate; import buildcraft.core.proxy.CoreProxy; import buildcraft.core.robots.EntityRobotBuilder; import buildcraft.core.utils.BlockUtil; @@ -35,27 +52,6 @@ import buildcraft.core.utils.Utils; import com.google.common.collect.Lists; import com.google.common.collect.Sets; -import cpw.mods.fml.common.network.PacketDispatcher; -import cpw.mods.fml.common.network.Player; - -import java.util.LinkedList; -import java.util.List; -import java.util.ListIterator; -import java.util.Set; - -import net.minecraft.entity.item.EntityItem; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.network.packet.Packet3Chat; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.ChatMessageComponent; -import net.minecraft.world.ChunkCoordIntPair; -import net.minecraftforge.common.ForgeChunkManager; -import net.minecraftforge.common.ForgeChunkManager.Ticket; -import net.minecraftforge.common.ForgeChunkManager.Type; -import net.minecraftforge.common.ForgeDirection; - public class TileQuarry extends TileBuildCraft implements IMachine, IPowerReceptor, IBuilderInventory { public @NetworkData @@ -145,12 +141,15 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept @Override public void updateEntity() { super.updateEntity(); - if (!isAlive && CoreProxy.proxy.isSimulating(worldObj)) { + + if (!isAlive && !worldObj.isRemote) { return; } - if (!CoreProxy.proxy.isSimulating(worldObj) && isAlive) { + + if (isAlive && worldObj.isRemote) { return; } + if (inProcess) { double energyToUse = 2 + powerHandler.getEnergyStored() / 500; @@ -161,16 +160,17 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept } } - if (CoreProxy.proxy.isSimulating(worldObj) && inProcess) { + if (!worldObj.isRemote && inProcess) { sendNetworkUpdate(); } - if (inProcess || !isDigging) + + if (inProcess || !isDigging) { return; + } createUtilsIfNeeded(); if (blueprintBuilder != null) { - builderDone = !blueprintIterator.hasNext(); if (!builderDone) { buildFrame(); @@ -178,13 +178,11 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept } else if (builder != null && builder.done()) { killBuilder(); } - } if (builder == null) { dig(); } - } private void killBuilder() { @@ -203,8 +201,10 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept float mj = 25 * BuildCraftFactory.miningMultiplier; powerHandler.configure(50 * BuildCraftFactory.miningMultiplier, 100 * BuildCraftFactory.miningMultiplier, mj, MAX_ENERGY * BuildCraftFactory.miningMultiplier); - if (powerHandler.useEnergy(mj, mj, true) != mj) + + if (powerHandler.useEnergy(mj, mj, true) != mj) { return; + } if (builder == null) { builder = new EntityRobotBuilder(worldObj, box); @@ -225,11 +225,12 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept powerHandler.configure(100 * BuildCraftFactory.miningMultiplier, 500 * BuildCraftFactory.miningMultiplier, BuildCraftFactory.MINING_MJ_COST_PER_BLOCK, MAX_ENERGY * BuildCraftFactory.miningMultiplier); float mj = BuildCraftFactory.MINING_MJ_COST_PER_BLOCK * BuildCraftFactory.miningMultiplier; - if (powerHandler.useEnergy(mj, mj, true) != mj) + + if (powerHandler.useEnergy(mj, mj, true) != mj) { return; + } if (!findTarget(true)) { - // I believe the issue is box going null becuase of bad chunkloader positioning if (arm != null && box != null) { setTarget(box.xMin + 1, yCoord + 2, box.zMin + 1); @@ -248,8 +249,9 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept private final LinkedList visitList = Lists.newLinkedList(); public boolean findTarget(boolean doSet) { - if (worldObj.isRemote) + if (worldObj.isRemote) { return false; + } boolean columnVisitListIsUpdated = false; @@ -261,15 +263,16 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept if (!doSet) return !visitList.isEmpty(); - if (visitList.isEmpty()) + if (visitList.isEmpty()) { return false; + } int[] nextTarget = visitList.removeFirst(); if (!columnVisitListIsUpdated) { // nextTarget may not be accurate, at least search the target column for changes for (int y = nextTarget[1] + 1; y < yCoord + 3; y++) { - int blockID = worldObj.getBlockId(nextTarget[0], y, nextTarget[2]); - if (BlockUtil.isAnObstructingBlock(blockID, worldObj, nextTarget[0], y, nextTarget[2]) || !BlockUtil.isSoftBlock(blockID, worldObj, nextTarget[0], y, nextTarget[2])) { + Block block = worldObj.getBlock(nextTarget[0], y, nextTarget[2]); + if (BlockUtil.isAnObstructingBlock(block, worldObj, nextTarget[0], y, nextTarget[2]) || !BlockUtil.isSoftBlock(block, worldObj, nextTarget[0], y, nextTarget[2])) { createColumnVisitList(); columnVisitListIsUpdated = true; nextTarget = null; @@ -277,12 +280,10 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept } } } - if (columnVisitListIsUpdated && nextTarget == null && !visitList.isEmpty()) - { + + if (columnVisitListIsUpdated && nextTarget == null && !visitList.isEmpty()) { nextTarget = visitList.removeFirst(); - } - else if (columnVisitListIsUpdated && nextTarget == null) - { + } else if (columnVisitListIsUpdated && nextTarget == null) { return false; } @@ -299,6 +300,7 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept Integer[][] columnHeights = new Integer[blueprintBuilder.blueprint.sizeX - 2][blueprintBuilder.blueprint.sizeZ - 2]; boolean[][] blockedColumns = new boolean[blueprintBuilder.blueprint.sizeX - 2][blueprintBuilder.blueprint.sizeZ - 2]; + for (int searchY = yCoord + 3; searchY >= 0; --searchY) { int startX, endX, incX; @@ -330,29 +332,31 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept Integer height = columnHeights[searchX][searchZ]; int bx = box.xMin + searchX + 1, by = searchY, bz = box.zMin + searchZ + 1; - if (height == null) + if (height == null) { columnHeights[searchX][searchZ] = height = worldObj.getHeightValue(bx, bz); + } - if (height > 0 && height < by && worldObj.provider.dimensionId != -1) - { + if (height > 0 && height < by && worldObj.provider.dimensionId != -1) { continue; } - int blockID = worldObj.getBlockId(bx, by, bz); + Block block = worldObj.getBlock(bx, by, bz); - if (!BlockUtil.canChangeBlock(blockID, worldObj, bx, by, bz)) { + if (!BlockUtil.canChangeBlock(block, worldObj, bx, by, bz)) { blockedColumns[searchX][searchZ] = true; - } else if (!BlockUtil.isSoftBlock(blockID, worldObj, bx, by, bz)) { + } else if (!BlockUtil.isSoftBlock(block, worldObj, bx, by, bz)) { visitList.add(new int[]{bx, by, bz}); } - if (height == 0 && !worldObj.isAirBlock(bx, by, bz)) - { + + if (height == 0 && !worldObj.isAirBlock(bx, by, bz)) { columnHeights[searchX][searchZ] = by; } // Stop at two planes - generally any obstructions will have been found and will force a recompute prior to this - if (visitList.size() > blueprintBuilder.blueprint.sizeZ * blueprintBuilder.blueprint.sizeX * 2) + + if (visitList.size() > blueprintBuilder.blueprint.sizeZ * blueprintBuilder.blueprint.sizeX * 2) { return; + } } } } @@ -426,7 +430,7 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept int j = targetY - 1; int k = targetZ; - int blockId = worldObj.getBlockId(i, j, k); + Block block = worldObj.getBlock(i, j, k); if (isQuarriableBlock(i, j, k)) { @@ -442,7 +446,8 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept } } - worldObj.playAuxSFXAtEntity(null, 2001, i, j, k, blockId + (worldObj.getBlockMetadata(i, j, k) << 12)); + // FIXME: fix sound here + //worldObj.playAuxSFXAtEntity(null, 2001, i, j, k, blockId + (worldObj.getBlockMetadata(i, j, k) << 12)); worldObj.setBlockToAir(i, j, k); } @@ -496,8 +501,8 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept } private boolean isQuarriableBlock(int bx, int by, int bz) { - int blockID = worldObj.getBlockId(bx, by, bz); - return BlockUtil.canChangeBlock(blockID, worldObj, bx, by, bz) && !BlockUtil.isSoftBlock(blockID, worldObj, bx, by, bz); + Block block = worldObj.getBlock(bx, by, bz); + return BlockUtil.canChangeBlock(block, worldObj, bx, by, bz) && !BlockUtil.isSoftBlock(block, worldObj, bx, by, bz); } @Override @@ -539,10 +544,12 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept } if (chunkTicket == null) { isAlive = false; - if (placedBy != null && CoreProxy.proxy.isSimulating(worldObj)) { - PacketDispatcher.sendPacketToPlayer( - new Packet3Chat(ChatMessageComponent.createFromText(String.format("[BUILDCRAFT] The quarry at %d, %d, %d will not work because there are no more chunkloaders available", - xCoord, yCoord, zCoord))), (Player) placedBy); + + if (placedBy != null && !worldObj.isRemote) { + placedBy.addChatMessage(new ChatComponentText( + String.format( + "[BUILDCRAFT] The quarry at %d, %d, %d will not work because there are no more chunkloaders available", + xCoord, yCoord, zCoord))); } sendNetworkUpdate(); return; @@ -569,12 +576,14 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept if (xSize < 3 || zSize < 3 || ((xSize * zSize) >> 8) >= chunkTicket.getMaxChunkListDepth()) { if (placedBy != null) { - PacketDispatcher.sendPacketToPlayer( - new Packet3Chat(ChatMessageComponent.createFromText(String.format("Quarry size is outside of chunkloading bounds or too small %d %d (%d)", xSize, zSize, - chunkTicket.getMaxChunkListDepth()))), (Player) placedBy); + placedBy.addChatMessage(new ChatComponentText( + String.format( + "Quarry size is outside of chunkloading bounds or too small %d %d (%d)", + xSize, zSize, + chunkTicket.getMaxChunkListDepth()))); } - a = new DefaultAreaProvider(xCoord, yCoord, zCoord, xCoord + 10, yCoord + 4, zCoord + 10); + a = new DefaultAreaProvider(xCoord, yCoord, zCoord, xCoord + 10, yCoord + 4, zCoord + 10); useDefault = true; } @@ -626,22 +635,21 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept for (int it = 0; it < 2; it++) { for (int i = 0; i < blueprint.sizeX; ++i) { - blueprint.setSchematic(worldObj, i, it * (box.sizeY() - 1), 0, BuildCraftFactory.frameBlock.blockID, 0); - blueprint.setSchematic(worldObj, i, it * (box.sizeY() - 1), blueprint.sizeZ - 1, BuildCraftFactory.frameBlock.blockID, 0); + blueprint.setSchematic(worldObj, i, it * (box.sizeY() - 1), 0, BuildCraftFactory.frameBlock, 0); + blueprint.setSchematic(worldObj, i, it * (box.sizeY() - 1), blueprint.sizeZ - 1, BuildCraftFactory.frameBlock, 0); } for (int k = 0; k < blueprint.sizeZ; ++k) { - blueprint.setSchematic(worldObj, 0, it * (box.sizeY() - 1), k, BuildCraftFactory.frameBlock.blockID, 0); - blueprint.setSchematic(worldObj, blueprint.sizeX - 1, it * (box.sizeY() - 1), k, BuildCraftFactory.frameBlock.blockID, 0); - + blueprint.setSchematic(worldObj, 0, it * (box.sizeY() - 1), k, BuildCraftFactory.frameBlock, 0); + blueprint.setSchematic(worldObj, blueprint.sizeX - 1, it * (box.sizeY() - 1), k, BuildCraftFactory.frameBlock, 0); } } for (int h = 1; h < box.sizeY(); ++h) { - blueprint.setSchematic(worldObj, 0, h, 0, BuildCraftFactory.frameBlock.blockID, 0); - blueprint.setSchematic(worldObj, 0, h, blueprint.sizeZ - 1, BuildCraftFactory.frameBlock.blockID, 0); - blueprint.setSchematic(worldObj, blueprint.sizeX - 1, h, 0, BuildCraftFactory.frameBlock.blockID, 0); - blueprint.setSchematic(worldObj, blueprint.sizeX - 1, h, blueprint.sizeZ - 1, BuildCraftFactory.frameBlock.blockID, 0); + blueprint.setSchematic(worldObj, 0, h, 0, BuildCraftFactory.frameBlock, 0); + blueprint.setSchematic(worldObj, 0, h, blueprint.sizeZ - 1, BuildCraftFactory.frameBlock, 0); + blueprint.setSchematic(worldObj, blueprint.sizeX - 1, h, 0, BuildCraftFactory.frameBlock, 0); + blueprint.setSchematic(worldObj, blueprint.sizeX - 1, h, blueprint.sizeZ - 1, BuildCraftFactory.frameBlock, 0); } blueprintBuilder = new BlueprintBuilder(blueprint, worldObj, box.xMin, yCoord, box.zMin, ForgeDirection.NORTH); @@ -669,7 +677,7 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept public void initialize() { super.initialize(); - if (CoreProxy.proxy.isSimulating(this.worldObj) && !box.initialized) { + if (!this.getWorldObj().isRemote && !box.initialized) { setBoundaries(false); } @@ -724,7 +732,7 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept } @Override - public String getInvName() { + public String getInventoryName() { return ""; } @@ -744,11 +752,11 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept } @Override - public void openChest() { + public void openInventory() { } @Override - public void closeChest() { + public void closeInventory() { } @Override @@ -851,11 +859,19 @@ public class TileQuarry extends TileBuildCraft implements IMachine, IPowerRecept chunks.add(chunk); } } + if (placedBy != null) { - PacketDispatcher.sendPacketToPlayer( - new Packet3Chat(ChatMessageComponent.createFromText(String.format("[BUILDCRAFT] The quarry at %d %d %d will keep %d chunks loaded", xCoord, yCoord, zCoord, chunks.size()))), - (Player) placedBy); + placedBy.addChatMessage(new ChatComponentText( + String.format( + "[BUILDCRAFT] The quarry at %d %d %d will keep %d chunks loaded", + xCoord, yCoord, zCoord, chunks.size()))); } + sendNetworkUpdate(); } + + @Override + public boolean hasCustomInventoryName() { + return false; + } } diff --git a/common/buildcraft/factory/TileRefinery.java b/common/buildcraft/factory/TileRefinery.java index 37a9e0b1..9886521a 100644 --- a/common/buildcraft/factory/TileRefinery.java +++ b/common/buildcraft/factory/TileRefinery.java @@ -1,13 +1,15 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.factory; import buildcraft.BuildCraftCore; +import buildcraft.BuildCraftFactory; import buildcraft.api.core.SafeTimeTracker; import buildcraft.api.gates.IAction; import buildcraft.api.power.IPowerReceptor; @@ -24,16 +26,19 @@ import buildcraft.core.network.PacketPayload; import buildcraft.core.network.PacketPayloadStream; import buildcraft.core.network.PacketUpdate; import buildcraft.core.proxy.CoreProxy; +import io.netty.buffer.ByteBuf; + import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.ICrafting; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidRegistry; @@ -85,7 +90,7 @@ public class TileRefinery extends TileBuildCraft implements IFluidHandler, IPowe } @Override - public String getInvName() { + public String getInventoryName() { return null; } @@ -101,7 +106,7 @@ public class TileRefinery extends TileBuildCraft implements IFluidHandler, IPowe @Override public boolean isUseableByPlayer(EntityPlayer entityplayer) { - return worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) == this; + return worldObj.getTileEntity(xCoord, yCoord, zCoord) == this; } @Override @@ -120,7 +125,7 @@ public class TileRefinery extends TileBuildCraft implements IFluidHandler, IPowe @Override public void updateEntity() { - if (CoreProxy.proxy.isRenderWorld(worldObj)) { + if (worldObj.isRemote) { simpleAnimationIterate(); return; } @@ -279,11 +284,11 @@ public class TileRefinery extends TileBuildCraft implements IFluidHandler, IPowe } @Override - public void openChest() { + public void openInventory() { } @Override - public void closeChest() { + public void closeInventory() { } public void resetFilters() { @@ -359,7 +364,7 @@ public class TileRefinery extends TileBuildCraft implements IFluidHandler, IPowe public PacketPayload getPacketPayload() { PacketPayload payload = new PacketPayloadStream(new PacketPayloadStream.StreamWriter() { @Override - public void writeData(DataOutputStream data) throws IOException { + public void writeData(ByteBuf data) { data.writeFloat(animationSpeed); tankManager.writeData(data); } @@ -369,7 +374,7 @@ public class TileRefinery extends TileBuildCraft implements IFluidHandler, IPowe @Override public void handleUpdatePacket(PacketUpdate packet) throws IOException { - DataInputStream stream = ((PacketPayloadStream) packet.payload).stream; + ByteBuf stream = ((PacketPayloadStream) packet.payload).stream; animationSpeed = stream.readFloat(); tankManager.readData(stream); } @@ -383,4 +388,9 @@ public class TileRefinery extends TileBuildCraft implements IFluidHandler, IPowe public boolean canDrain(ForgeDirection from, Fluid fluid) { return true; } + + @Override + public boolean hasCustomInventoryName() { + return false; + } } diff --git a/common/buildcraft/factory/TileTank.java b/common/buildcraft/factory/TileTank.java index ffc08e27..eb66cdb3 100644 --- a/common/buildcraft/factory/TileTank.java +++ b/common/buildcraft/factory/TileTank.java @@ -1,13 +1,15 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.factory; import buildcraft.BuildCraftCore; +import buildcraft.BuildCraftFactory; import buildcraft.api.core.SafeTimeTracker; import buildcraft.core.TileBuildCraft; import buildcraft.core.fluids.Tank; @@ -16,13 +18,16 @@ import buildcraft.core.network.PacketPayload; import buildcraft.core.network.PacketPayloadStream; import buildcraft.core.network.PacketUpdate; import buildcraft.core.proxy.CoreProxy; +import io.netty.buffer.ByteBuf; + import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; + import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.EnumSkyBlock; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidStack; @@ -41,7 +46,7 @@ public class TileTank extends TileBuildCraft implements IFluidHandler { /* UPDATING */ @Override public void updateEntity() { - if (CoreProxy.proxy.isRenderWorld(worldObj)) { + if (worldObj.isRemote) { int lightValue = getFluidLightLevel(); if (prevLightValue != lightValue) { prevLightValue = lightValue; @@ -66,7 +71,7 @@ public class TileTank extends TileBuildCraft implements IFluidHandler { public PacketPayload getPacketPayload() { PacketPayload payload = new PacketPayloadStream(new PacketPayloadStream.StreamWriter() { @Override - public void writeData(DataOutputStream data) throws IOException { + public void writeData(ByteBuf data) { tankManager.writeData(data); } }); @@ -75,7 +80,7 @@ public class TileTank extends TileBuildCraft implements IFluidHandler { @Override public void handleUpdatePacket(PacketUpdate packet) throws IOException { - DataInputStream stream = ((PacketPayloadStream) packet.payload).stream; + ByteBuf stream = ((PacketPayloadStream) packet.payload).stream; tankManager.readData(stream); } @@ -129,7 +134,7 @@ public class TileTank extends TileBuildCraft implements IFluidHandler { } public static TileTank getTankBelow(TileTank tile) { - TileEntity below = tile.worldObj.getBlockTileEntity(tile.xCoord, tile.yCoord - 1, tile.zCoord); + TileEntity below = tile.getWorldObj().getTileEntity(tile.xCoord, tile.yCoord - 1, tile.zCoord); if (below instanceof TileTank) { return (TileTank) below; } else { @@ -138,7 +143,7 @@ public class TileTank extends TileBuildCraft implements IFluidHandler { } public static TileTank getTankAbove(TileTank tile) { - TileEntity above = tile.worldObj.getBlockTileEntity(tile.xCoord, tile.yCoord + 1, tile.zCoord); + TileEntity above = tile.getWorldObj().getTileEntity(tile.xCoord, tile.yCoord + 1, tile.zCoord); if (above instanceof TileTank) { return (TileTank) above; } else { diff --git a/common/buildcraft/factory/gui/ContainerAutoWorkbench.java b/common/buildcraft/factory/gui/ContainerAutoWorkbench.java index 27c407e3..a6f60c6d 100644 --- a/common/buildcraft/factory/gui/ContainerAutoWorkbench.java +++ b/common/buildcraft/factory/gui/ContainerAutoWorkbench.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.factory.gui; @@ -39,8 +40,8 @@ public class ContainerAutoWorkbench extends BuildCraftContainer { @Override public void setInventorySlotContents(int slot, ItemStack stack) { super.setInventorySlotContents(slot, stack); - if (stack != null && tile.isLast() && CoreProxy.proxy.isRenderWorld(tile.worldObj)) { - InvUtils.addItemToolTip(stack, "tip", EnumChatFormatting.YELLOW + StringUtils.localize("gui.clickcraft")); + if (stack != null && tile.isLast() && tile.getWorldObj().isRemote) { + InvUtils.addItemToolTip(stack, EnumChatFormatting.YELLOW + StringUtils.localize("gui.clickcraft")); } } }; diff --git a/common/buildcraft/factory/gui/ContainerHopper.java b/common/buildcraft/factory/gui/ContainerHopper.java index 701761ee..2826295c 100644 --- a/common/buildcraft/factory/gui/ContainerHopper.java +++ b/common/buildcraft/factory/gui/ContainerHopper.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.factory.gui; import buildcraft.core.gui.BuildCraftContainer; diff --git a/common/buildcraft/factory/gui/ContainerRefinery.java b/common/buildcraft/factory/gui/ContainerRefinery.java index 52cc1af3..7822c635 100644 --- a/common/buildcraft/factory/gui/ContainerRefinery.java +++ b/common/buildcraft/factory/gui/ContainerRefinery.java @@ -1,20 +1,25 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.factory.gui; +import buildcraft.BuildCraftFactory; import buildcraft.core.gui.BuildCraftContainer; import buildcraft.core.network.PacketIds; import buildcraft.core.network.PacketPayloadStream; import buildcraft.core.network.PacketUpdate; import buildcraft.core.proxy.CoreProxy; import buildcraft.factory.TileRefinery; +import io.netty.buffer.ByteBuf; + import java.io.DataOutputStream; import java.io.IOException; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.ICrafting; @@ -51,16 +56,15 @@ public class ContainerRefinery extends BuildCraftContainer { refinery.setFilter(slot, filter); - if (CoreProxy.proxy.isRenderWorld(refinery.worldObj)) { + if (refinery.getWorldObj().isRemote) { PacketPayloadStream payload = new PacketPayloadStream(new PacketPayloadStream.StreamWriter() { @Override - public void writeData(DataOutputStream data) throws IOException { + public void writeData(ByteBuf data) { data.writeByte(slot); data.writeShort(filter != null ? filter.getID() : -1); } }); - CoreProxy.proxy.sendToServer(new PacketUpdate(PacketIds.REFINERY_FILTER_SET, refinery.xCoord, refinery.yCoord, refinery.zCoord, payload) - .getPacket()); + BuildCraftFactory.instance.sendToServer(new PacketUpdate(PacketIds.REFINERY_FILTER_SET, refinery.xCoord, refinery.yCoord, refinery.zCoord, payload)); } } diff --git a/common/buildcraft/factory/gui/GuiAutoCrafting.java b/common/buildcraft/factory/gui/GuiAutoCrafting.java index e45a52f3..ae6b8c96 100644 --- a/common/buildcraft/factory/gui/GuiAutoCrafting.java +++ b/common/buildcraft/factory/gui/GuiAutoCrafting.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.factory.gui; @@ -37,8 +38,8 @@ public class GuiAutoCrafting extends GuiBuildCraft { @Override protected void drawGuiContainerForegroundLayer(int par1, int par2) { String title = StringUtils.localize("tile.autoWorkbenchBlock"); - fontRenderer.drawString(title, getCenteredOffset(title), 6, 0x404040); - fontRenderer.drawString(StringUtils.localize("gui.inventory"), 8, (ySize - 96) + 2, 0x404040); + fontRendererObj.drawString(title, getCenteredOffset(title), 6, 0x404040); + fontRendererObj.drawString(StringUtils.localize("gui.inventory"), 8, (ySize - 96) + 2, 0x404040); } @Override diff --git a/common/buildcraft/factory/gui/GuiHopper.java b/common/buildcraft/factory/gui/GuiHopper.java index 2ab5c7c5..c96e8fa6 100644 --- a/common/buildcraft/factory/gui/GuiHopper.java +++ b/common/buildcraft/factory/gui/GuiHopper.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.factory.gui; import buildcraft.core.DefaultProps; diff --git a/common/buildcraft/factory/gui/GuiRefinery.java b/common/buildcraft/factory/gui/GuiRefinery.java index e82e88bf..0625791a 100644 --- a/common/buildcraft/factory/gui/GuiRefinery.java +++ b/common/buildcraft/factory/gui/GuiRefinery.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.factory.gui; @@ -45,10 +46,10 @@ public class GuiRefinery extends GuiAdvancedInterface { @Override protected void drawGuiContainerForegroundLayer(int par1, int par2) { String title = StringUtils.localize("tile.refineryBlock"); - fontRenderer.drawString(title, getCenteredOffset(title), 6, 0x404040); - fontRenderer.drawString("->", 63, 59, 0x404040); - fontRenderer.drawString("<-", 106, 59, 0x404040); - fontRenderer.drawString(StringUtils.localize("gui.inventory"), 8, (ySize - 96) + 2, 0x404040); + fontRendererObj.drawString(title, getCenteredOffset(title), 6, 0x404040); + fontRendererObj.drawString("->", 63, 59, 0x404040); + fontRendererObj.drawString("<-", 106, 59, 0x404040); + fontRendererObj.drawString(StringUtils.localize("gui.inventory"), 8, (ySize - 96) + 2, 0x404040); drawForegroundSelection(par1, par2); } diff --git a/common/buildcraft/factory/network/PacketHandlerFactory.java b/common/buildcraft/factory/network/PacketHandlerFactory.java index bf9d7dd0..af51ce8c 100644 --- a/common/buildcraft/factory/network/PacketHandlerFactory.java +++ b/common/buildcraft/factory/network/PacketHandlerFactory.java @@ -1,37 +1,52 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.factory.network; +import buildcraft.core.network.BuildCraftChannelHandler; +import buildcraft.core.network.BuildCraftPacket; import buildcraft.core.network.PacketIds; import buildcraft.core.network.PacketPayload; import buildcraft.core.network.PacketPayloadStream; import buildcraft.core.network.PacketUpdate; +import buildcraft.core.proxy.CoreProxy; +import buildcraft.core.utils.Utils; import buildcraft.factory.TileRefinery; -import cpw.mods.fml.common.network.IPacketHandler; -import cpw.mods.fml.common.network.Player; +import io.netty.buffer.ByteBuf; +import io.netty.channel.ChannelHandlerContext; + import java.io.ByteArrayInputStream; import java.io.DataInputStream; import java.io.IOException; + +import cpw.mods.fml.common.network.NetworkRegistry; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.network.INetworkManager; -import net.minecraft.network.packet.Packet250CustomPayload; +import net.minecraft.network.INetHandler; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import net.minecraftforge.fluids.FluidRegistry; -public class PacketHandlerFactory implements IPacketHandler { +public class PacketHandlerFactory extends BuildCraftChannelHandler { @Override - public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player) { - - DataInputStream data = new DataInputStream(new ByteArrayInputStream(packet.data)); + public void decodeInto(ChannelHandlerContext ctx, ByteBuf data, BuildCraftPacket packet) { + super.decodeInto(ctx, data, packet); + try { - int packetID = data.read(); - PacketUpdate packetU = new PacketUpdate(); + INetHandler netHandler = ctx.channel().attr(NetworkRegistry.NET_HANDLER).get(); + EntityPlayer player = Utils.getPlayerFromNetHandler(netHandler); + + int packetID = packet.getID(); switch (packetID) { case PacketIds.REFINERY_FILTER_SET: - packetU.readData(data); - onRefinerySelect((EntityPlayer) player, packetU); + onRefinerySelect(player, (PacketUpdate) packet); break; } @@ -46,7 +61,7 @@ public class PacketHandlerFactory implements IPacketHandler { if (!world.blockExists(x, y, z)) return null; - TileEntity tile = world.getBlockTileEntity(x, y, z); + TileEntity tile = world.getTileEntity(x, y, z); if (!(tile instanceof TileRefinery)) return null; @@ -59,7 +74,7 @@ public class PacketHandlerFactory implements IPacketHandler { if (tile == null || packet.payload == null) return; - DataInputStream stream = ((PacketPayloadStream)packet.payload).stream; + ByteBuf stream = ((PacketPayloadStream)packet.payload).stream; tile.setFilter(stream.readByte(), FluidRegistry.getFluid(stream.readShort())); } diff --git a/common/buildcraft/factory/render/ModelFrustum.java b/common/buildcraft/factory/render/ModelFrustum.java index e55cb8dc..976f0af4 100644 --- a/common/buildcraft/factory/render/ModelFrustum.java +++ b/common/buildcraft/factory/render/ModelFrustum.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.factory.render; import net.minecraft.client.model.ModelRenderer; diff --git a/common/buildcraft/factory/render/RenderHopper.java b/common/buildcraft/factory/render/RenderHopper.java index 12f5a64c..7aff042a 100644 --- a/common/buildcraft/factory/render/RenderHopper.java +++ b/common/buildcraft/factory/render/RenderHopper.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.factory.render; import buildcraft.BuildCraftCore; @@ -7,7 +15,7 @@ import buildcraft.core.IInventoryRenderer; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.tileentity.TileEntityRenderer; +import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; @@ -35,7 +43,7 @@ public class RenderHopper extends TileEntitySpecialRenderer implements IInventor bottom.rotationPointX = 8F; bottom.rotationPointY = 8F; bottom.rotationPointZ = 8F; - setTileEntityRenderer(TileEntityRenderer.instance); + field_147501_a = TileEntityRendererDispatcher.instance; } @Override diff --git a/common/buildcraft/factory/render/RenderRefinery.java b/common/buildcraft/factory/render/RenderRefinery.java index b1bce960..4873fb3a 100644 --- a/common/buildcraft/factory/render/RenderRefinery.java +++ b/common/buildcraft/factory/render/RenderRefinery.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.factory.render; @@ -15,11 +16,12 @@ import buildcraft.core.render.RenderUtils; import buildcraft.factory.TileRefinery; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; -import net.minecraft.client.renderer.tileentity.TileEntityRenderer; +import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fluids.FluidStack; + import org.lwjgl.opengl.GL11; public class RenderRefinery extends TileEntitySpecialRenderer implements IInventoryRenderer { @@ -51,7 +53,7 @@ public class RenderRefinery extends TileEntitySpecialRenderer implements IInvent } - setTileEntityRenderer(TileEntityRenderer.instance); + field_147501_a = TileEntityRendererDispatcher.instance; } public RenderRefinery(String baseTexture) { @@ -95,7 +97,7 @@ public class RenderRefinery extends TileEntitySpecialRenderer implements IInvent anim = tile.getAnimationStage(); angle = 0; - switch (tile.worldObj.getBlockMetadata(tile.xCoord, tile.yCoord, tile.zCoord)) { + switch (tile.getWorldObj().getBlockMetadata(tile.xCoord, tile.yCoord, tile.zCoord)) { case 2: angle = 90; break; @@ -184,7 +186,7 @@ public class RenderRefinery extends TileEntitySpecialRenderer implements IInvent GL11.glScalef(0.5F, 1, 0.5F); if (liquid1 != null && liquid1.amount > 0) { - int[] list1 = FluidRenderer.getFluidDisplayLists(liquid1, tile.worldObj, false); + int[] list1 = FluidRenderer.getFluidDisplayLists(liquid1, tile.getWorldObj(), false); if (list1 != null) { bindTexture(FluidRenderer.getFluidSheet(liquid1)); @@ -194,7 +196,7 @@ public class RenderRefinery extends TileEntitySpecialRenderer implements IInvent } if (liquid2 != null && liquid2.amount > 0) { - int[] list2 = FluidRenderer.getFluidDisplayLists(liquid2, tile.worldObj, false); + int[] list2 = FluidRenderer.getFluidDisplayLists(liquid2, tile.getWorldObj(), false); if (list2 != null) { GL11.glPushMatrix(); @@ -208,7 +210,7 @@ public class RenderRefinery extends TileEntitySpecialRenderer implements IInvent if (liquidResult != null && liquidResult.amount > 0) { - int[] list3 = FluidRenderer.getFluidDisplayLists(liquidResult, tile.worldObj, false); + int[] list3 = FluidRenderer.getFluidDisplayLists(liquidResult, tile.getWorldObj(), false); if (list3 != null) { GL11.glPushMatrix(); diff --git a/common/buildcraft/factory/render/RenderTank.java b/common/buildcraft/factory/render/RenderTank.java index 896dadcf..f44d32d5 100644 --- a/common/buildcraft/factory/render/RenderTank.java +++ b/common/buildcraft/factory/render/RenderTank.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.factory.render; @@ -28,7 +29,7 @@ public class RenderTank extends TileEntitySpecialRenderer { return; } - int[] displayList = FluidRenderer.getFluidDisplayLists(liquid, tileentity.worldObj, false); + int[] displayList = FluidRenderer.getFluidDisplayLists(liquid, tileentity.getWorldObj(), false); if (displayList == null) { return; } diff --git a/common/buildcraft/silicon/BlockLaser.java b/common/buildcraft/silicon/BlockLaser.java index b0eb8320..7f392a23 100644 --- a/common/buildcraft/silicon/BlockLaser.java +++ b/common/buildcraft/silicon/BlockLaser.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.silicon; @@ -13,20 +14,20 @@ import cpw.mods.fml.relauncher.SideOnly; import java.util.ArrayList; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; -import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Icon; +import net.minecraft.util.IIcon; import net.minecraft.world.World; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; public class BlockLaser extends BlockContainer { @SideOnly(Side.CLIENT) - private Icon textureTop, textureBottom, textureSide; + private IIcon textureTop, textureBottom, textureSide; - public BlockLaser(int i) { - super(i, Material.iron); + public BlockLaser() { + super(Material.iron); setHardness(10F); setCreativeTab(CreativeTabBuildCraft.MACHINES.get()); } @@ -51,12 +52,12 @@ public class BlockLaser extends BlockContainer { } @Override - public TileEntity createNewTileEntity(World world) { + public TileEntity createNewTileEntity(World world, int metadata) { return new TileLaser(); } @Override - public Icon getIcon(int i, int j) { + public IIcon getIcon(int i, int j) { if (i == ForgeDirection.values()[j].getOpposite().ordinal()) return textureBottom; else if (i == j) @@ -77,15 +78,9 @@ public class BlockLaser extends BlockContainer { return meta; } - @SuppressWarnings({"unchecked", "rawtypes"}) - @Override - public void addCreativeItems(ArrayList itemList) { - itemList.add(new ItemStack(this)); - } - @Override @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister par1IconRegister) { + public void registerBlockIcons(IIconRegister par1IconRegister) { textureTop = par1IconRegister.registerIcon("buildcraft:laser_top"); textureBottom = par1IconRegister.registerIcon("buildcraft:laser_bottom"); textureSide = par1IconRegister.registerIcon("buildcraft:laser_side"); diff --git a/common/buildcraft/silicon/BlockLaserTable.java b/common/buildcraft/silicon/BlockLaserTable.java index 18b0f1c1..6cdf68c4 100644 --- a/common/buildcraft/silicon/BlockLaserTable.java +++ b/common/buildcraft/silicon/BlockLaserTable.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.silicon; import buildcraft.BuildCraftSilicon; @@ -6,24 +14,28 @@ import buildcraft.core.proxy.CoreProxy; import buildcraft.core.utils.Utils; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; + import java.util.List; + +import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; -import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Icon; +import net.minecraft.util.IIcon; import net.minecraft.world.World; public class BlockLaserTable extends BlockContainer { @SideOnly(Side.CLIENT) - private Icon[][] icons; + private IIcon[][] icons; - public BlockLaserTable(int i) { - super(i, Material.iron); + public BlockLaserTable() { + super(Material.iron); setBlockBounds(0, 0, 0, 1, 9F / 16F, 1); setHardness(10F); @@ -50,7 +62,7 @@ public class BlockLaserTable extends BlockContainer { if (entityplayer.isSneaking()) return false; - if (!CoreProxy.proxy.isRenderWorld(world)) { + if (!world.isRemote) { int meta = world.getBlockMetadata(i, j, k); entityplayer.openGui(BuildCraftSilicon.instance, meta, world, i, j, k); } @@ -58,13 +70,13 @@ public class BlockLaserTable extends BlockContainer { } @Override - public void breakBlock(World world, int x, int y, int z, int par5, int par6) { + public void breakBlock(World world, int x, int y, int z, Block block, int par6) { Utils.preDestroyBlock(world, x, y, z); - super.breakBlock(world, x, y, z, par5, par6); + super.breakBlock(world, x, y, z, block, par6); } @Override - public Icon getIcon(int side, int meta) { + public IIcon getIcon(int side, int meta) { int s = side > 1 ? 2 : side; return icons[meta][s]; } @@ -83,7 +95,7 @@ public class BlockLaserTable extends BlockContainer { } @Override - public TileEntity createNewTileEntity(World var1) { + public TileEntity createNewTileEntity(World world, int metadata) { return null; } @@ -95,7 +107,7 @@ public class BlockLaserTable extends BlockContainer { @SuppressWarnings({"rawtypes", "unchecked"}) @Override @SideOnly(Side.CLIENT) - public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List) { + public void getSubBlocks(Item item, CreativeTabs par2CreativeTabs, List par3List) { par3List.add(new ItemStack(this, 1, 0)); par3List.add(new ItemStack(this, 1, 1)); par3List.add(new ItemStack(this, 1, 2)); @@ -103,11 +115,11 @@ public class BlockLaserTable extends BlockContainer { @Override @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister par1IconRegister) { - icons = new Icon[3][]; - icons[0] = new Icon[3]; - icons[1] = new Icon[3]; - icons[2] = new Icon[3]; + public void registerBlockIcons(IIconRegister par1IconRegister) { + icons = new IIcon[3][]; + icons[0] = new IIcon[3]; + icons[1] = new IIcon[3]; + icons[2] = new IIcon[3]; icons[0][0] = par1IconRegister.registerIcon("buildcraft:assemblytable_bottom"); icons[0][1] = par1IconRegister.registerIcon("buildcraft:assemblytable_top"); diff --git a/common/buildcraft/silicon/GuiHandler.java b/common/buildcraft/silicon/GuiHandler.java index 618f81e4..dc6bbc18 100644 --- a/common/buildcraft/silicon/GuiHandler.java +++ b/common/buildcraft/silicon/GuiHandler.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.silicon; import buildcraft.silicon.gui.ContainerAdvancedCraftingTable; @@ -19,7 +27,7 @@ public class GuiHandler implements IGuiHandler { if (!world.blockExists(x, y, z)) return null; - TileEntity tile = world.getBlockTileEntity(x, y, z); + TileEntity tile = world.getTileEntity(x, y, z); switch (ID) { @@ -48,7 +56,7 @@ public class GuiHandler implements IGuiHandler { if (!world.blockExists(x, y, z)) return null; - TileEntity tile = world.getBlockTileEntity(x, y, z); + TileEntity tile = world.getTileEntity(x, y, z); switch (ID) { diff --git a/common/buildcraft/silicon/ItemLaserTable.java b/common/buildcraft/silicon/ItemLaserTable.java index 07dae233..85192e0b 100644 --- a/common/buildcraft/silicon/ItemLaserTable.java +++ b/common/buildcraft/silicon/ItemLaserTable.java @@ -1,12 +1,22 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.silicon; import buildcraft.core.ItemBlockBuildCraft; +import net.minecraft.block.Block; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; public class ItemLaserTable extends ItemBlockBuildCraft { - public ItemLaserTable(int par1) { - super(par1); + public ItemLaserTable(Block block) { + super(block); setMaxDamage(0); setHasSubtypes(true); } diff --git a/common/buildcraft/silicon/ItemRedstoneChipset.java b/common/buildcraft/silicon/ItemRedstoneChipset.java index 448a3d58..ed6162bb 100644 --- a/common/buildcraft/silicon/ItemRedstoneChipset.java +++ b/common/buildcraft/silicon/ItemRedstoneChipset.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.silicon; import buildcraft.BuildCraftSilicon; @@ -5,12 +13,15 @@ import buildcraft.core.ItemBuildCraft; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; + import java.util.List; import java.util.Locale; -import net.minecraft.client.renderer.texture.IconRegister; + +import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.util.Icon; +import net.minecraft.util.IIcon; public class ItemRedstoneChipset extends ItemBuildCraft { @@ -24,7 +35,7 @@ public class ItemRedstoneChipset extends ItemBuildCraft { QUARTZ, COMP; public static final Chipset[] VALUES = values(); - private Icon icon; + private IIcon icon; public String getChipsetName() { return "redstone_" + name().toLowerCase(Locale.ENGLISH) + "_chipset"; @@ -45,14 +56,14 @@ public class ItemRedstoneChipset extends ItemBuildCraft { } } - public ItemRedstoneChipset(int i) { - super(i); + public ItemRedstoneChipset() { + super(); setHasSubtypes(true); setMaxDamage(0); } @Override - public Icon getIconFromDamage(int damage) { + public IIcon getIconFromDamage(int damage) { return Chipset.fromOrdinal(damage).icon; } @@ -64,7 +75,7 @@ public class ItemRedstoneChipset extends ItemBuildCraft { @SuppressWarnings({"rawtypes", "unchecked"}) @Override @SideOnly(Side.CLIENT) - public void getSubItems(int id, CreativeTabs tab, List itemList) { + public void getSubItems(Item item, CreativeTabs tab, List itemList) { for (Chipset chipset : Chipset.VALUES) { itemList.add(chipset.getStack()); } @@ -72,7 +83,7 @@ public class ItemRedstoneChipset extends ItemBuildCraft { @Override @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister par1IconRegister) { + public void registerIcons(IIconRegister par1IconRegister) { for (Chipset chipset : Chipset.VALUES) { chipset.icon = par1IconRegister.registerIcon("buildcraft:" + chipset.getChipsetName()); } diff --git a/common/buildcraft/silicon/SiliconProxy.java b/common/buildcraft/silicon/SiliconProxy.java index e1e39c5b..64825a33 100644 --- a/common/buildcraft/silicon/SiliconProxy.java +++ b/common/buildcraft/silicon/SiliconProxy.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.silicon; import cpw.mods.fml.common.SidedProxy; diff --git a/common/buildcraft/silicon/SiliconProxyClient.java b/common/buildcraft/silicon/SiliconProxyClient.java index 47b1a81a..2a0c7785 100644 --- a/common/buildcraft/silicon/SiliconProxyClient.java +++ b/common/buildcraft/silicon/SiliconProxyClient.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.silicon; import cpw.mods.fml.client.registry.RenderingRegistry; diff --git a/common/buildcraft/silicon/SiliconRenderBlock.java b/common/buildcraft/silicon/SiliconRenderBlock.java index fcb1f0f8..f3a44055 100644 --- a/common/buildcraft/silicon/SiliconRenderBlock.java +++ b/common/buildcraft/silicon/SiliconRenderBlock.java @@ -1,12 +1,11 @@ /** - * Copyright (c) SpaceToad, 2011 + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.silicon; import buildcraft.core.CoreConstants; @@ -15,7 +14,7 @@ import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; import net.minecraft.world.IBlockAccess; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; import org.lwjgl.opengl.GL11; public class SiliconRenderBlock implements ISimpleBlockRenderingHandler { @@ -25,7 +24,7 @@ public class SiliconRenderBlock implements ISimpleBlockRenderingHandler { } @Override - public boolean shouldRender3DInInventory() { + public boolean shouldRender3DInInventory(int modelId) { return true; } @@ -168,23 +167,4 @@ public class SiliconRenderBlock implements ISimpleBlockRenderingHandler { renderblocks.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(5, i)); tessellator.draw(); } - - /* - * @Override public GuiScreen handleGUI(int i) { switch (Utils.intToPacketId(i)) { case AssemblyTableGUI: return new GuiAssemblyTable( - * ModLoader.getMinecraftInstance().thePlayer.inventory, new TileAssemblyTable()); default: return null; } } - */ - - /* - * @Override public void handlePacket(Packet230ModLoader packet) { switch (PacketIds.values()[packet.packetType]) { case AssemblyTableSelect: GuiScreen - * screen = ModLoader.getMinecraftInstance().currentScreen; - * - * if (screen instanceof GuiAssemblyTable) { GuiAssemblyTable gui = (GuiAssemblyTable) screen; SelectionMessage message = new SelectionMessage(); - * - * TileAssemblyTable.selectionMessageWrapper.updateFromPacket(message, packet); - * - * gui.handleSelectionMessage (message); } - * - * break; } } - */ - } diff --git a/common/buildcraft/silicon/TileAdvancedCraftingTable.java b/common/buildcraft/silicon/TileAdvancedCraftingTable.java index 4f3eb7b0..2f56f12c 100644 --- a/common/buildcraft/silicon/TileAdvancedCraftingTable.java +++ b/common/buildcraft/silicon/TileAdvancedCraftingTable.java @@ -1,7 +1,16 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.silicon; import buildcraft.api.power.ILaserTarget; import buildcraft.BuildCraftCore; +import buildcraft.BuildCraftSilicon; import buildcraft.api.gates.IAction; import buildcraft.api.gates.IActionReceptor; import buildcraft.core.IMachine; @@ -23,9 +32,14 @@ import buildcraft.core.triggers.ActionMachineControl; import buildcraft.core.utils.CraftingHelper; import buildcraft.core.utils.StringUtils; import buildcraft.core.utils.Utils; + import com.google.common.collect.Lists; +import com.mojang.authlib.GameProfile; + +import java.util.Arrays; import java.util.EnumSet; import java.util.List; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; @@ -37,16 +51,15 @@ import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ChatMessageComponent; import net.minecraft.util.ChunkCoordinates; -import net.minecraftforge.common.ForgeDirection; -import static net.minecraftforge.common.ForgeDirection.DOWN; -import static net.minecraftforge.common.ForgeDirection.EAST; -import static net.minecraftforge.common.ForgeDirection.NORTH; -import static net.minecraftforge.common.ForgeDirection.SOUTH; -import static net.minecraftforge.common.ForgeDirection.WEST; +import net.minecraft.util.IChatComponent; +import net.minecraftforge.common.util.ForgeDirection; +import static net.minecraftforge.common.util.ForgeDirection.DOWN; +import static net.minecraftforge.common.util.ForgeDirection.EAST; +import static net.minecraftforge.common.util.ForgeDirection.NORTH; +import static net.minecraftforge.common.util.ForgeDirection.SOUTH; +import static net.minecraftforge.common.util.ForgeDirection.WEST; import net.minecraftforge.oredict.OreDictionary; -import org.bouncycastle.util.Arrays; public class TileAdvancedCraftingTable extends TileLaserTableBase implements IInventory, ILaserTarget, IMachine, IActionReceptor, ISidedInventory { @@ -62,7 +75,7 @@ public class TileAdvancedCraftingTable extends TileLaserTableBase implements IIn public int[] oreIDs = new int[9]; - public CraftingGrid() { + public CraftingGrid() { super(9, "CraftingSlots", 1); Arrays.fill(oreIDs, -1); } @@ -70,7 +83,7 @@ public class TileAdvancedCraftingTable extends TileLaserTableBase implements IIn @Override public void setInventorySlotContents(int slotId, ItemStack itemstack) { super.setInventorySlotContents(slotId, itemstack); - if (TileAdvancedCraftingTable.this.worldObj == null || !TileAdvancedCraftingTable.this.worldObj.isRemote) + if (TileAdvancedCraftingTable.this.getWorldObj() == null || !TileAdvancedCraftingTable.this.getWorldObj().isRemote) oreIDs[slotId] = itemstack == null ? -1 : OreDictionary.getOreID(itemstack); } } @@ -136,14 +149,14 @@ public class TileAdvancedCraftingTable extends TileLaserTableBase implements IIn private final class InternalPlayer extends EntityPlayer { public InternalPlayer() { - super(TileAdvancedCraftingTable.this.worldObj, "[BuildCraft]"); + super(TileAdvancedCraftingTable.this.getWorldObj(), new GameProfile(null, "[BuildCraft]")); posX = TileAdvancedCraftingTable.this.xCoord; posY = TileAdvancedCraftingTable.this.yCoord + 1; posZ = TileAdvancedCraftingTable.this.zCoord; } @Override - public void sendChatToPlayer(ChatMessageComponent var1) { + public void addChatMessage(IChatComponent var1) { } @Override @@ -204,13 +217,13 @@ public class TileAdvancedCraftingTable extends TileLaserTableBase implements IIn } @Override - public String getInvName() { + public String getInventoryName() { return StringUtils.localize("tile.assemblyWorkbenchBlock"); } @Override - public void onInventoryChanged() { - super.onInventoryChanged(); + public void markDirty() { + super.markDirty(); craftable = craftResult.getStackInSlot(0) != null; } @@ -237,7 +250,7 @@ public class TileAdvancedCraftingTable extends TileLaserTableBase implements IIn craftSlot = new SlotCrafting(internalPlayer, internalInventoryCrafting, craftResult, 0, 0, 0); updateRecipe(); } - if (!CoreProxy.proxy.isSimulating(worldObj)) + if (!!worldObj.isRemote) return; if (lastMode == ActionMachineControl.Mode.Off) return; @@ -364,9 +377,9 @@ public class TileAdvancedCraftingTable extends TileLaserTableBase implements IIn public void updateCraftingMatrix(int slot, ItemStack stack) { craftingSlots.setInventorySlotContents(slot, stack); updateRecipe(); - if (CoreProxy.proxy.isRenderWorld(worldObj)) { + if (worldObj.isRemote) { PacketSlotChange packet = new PacketSlotChange(PacketIds.ADVANCED_WORKBENCH_SETSLOT, xCoord, yCoord, zCoord, slot, stack); - CoreProxy.proxy.sendToServer(packet.getPacket()); + BuildCraftSilicon.instance.sendToServer(packet); } } @@ -379,7 +392,7 @@ public class TileAdvancedCraftingTable extends TileLaserTableBase implements IIn currentRecipe = CraftingHelper.findMatchingRecipe(internalInventoryCrafting, worldObj); } internalInventoryCrafting.recipeUpdate(false); - onInventoryChanged(); + markDirty(); } private void updateRecipeOutputDisplay() { @@ -394,7 +407,7 @@ public class TileAdvancedCraftingTable extends TileLaserTableBase implements IIn internalInventoryCrafting.recipeUpdate(false); } craftResult.setInventorySlotContents(0, resultStack); - onInventoryChanged(); + markDirty(); } private ItemStack getRecipeOutput() { @@ -437,12 +450,6 @@ public class TileAdvancedCraftingTable extends TileLaserTableBase implements IIn return action == BuildCraftCore.actionOn || action == BuildCraftCore.actionOff; } - @Override - public boolean isInvNameLocalized() { - // TODO Auto-generated method stub - return false; - } - @Override public int[] getAccessibleSlotsFromSide(int side) { return SLOTS; @@ -471,4 +478,9 @@ public class TileAdvancedCraftingTable extends TileLaserTableBase implements IIn lastMode = ActionMachineControl.Mode.Off; } } + + @Override + public boolean hasCustomInventoryName() { + return false; + } } diff --git a/common/buildcraft/silicon/TileAssemblyTable.java b/common/buildcraft/silicon/TileAssemblyTable.java index c4862e44..85c5716c 100644 --- a/common/buildcraft/silicon/TileAssemblyTable.java +++ b/common/buildcraft/silicon/TileAssemblyTable.java @@ -1,5 +1,14 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.silicon; +import buildcraft.BuildCraftSilicon; import buildcraft.core.recipes.AssemblyRecipeManager; import buildcraft.api.gates.IAction; import buildcraft.core.DefaultProps; @@ -11,17 +20,19 @@ import buildcraft.core.utils.Utils; import buildcraft.core.recipes.AssemblyRecipeManager.AssemblyRecipe; import buildcraft.core.utils.StringUtils; import cpw.mods.fml.common.FMLCommonHandler; + import java.util.LinkedHashSet; import java.util.LinkedList; import java.util.List; import java.util.Set; + import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; public class TileAssemblyTable extends TileLaserTableBase implements IMachine, IInventory { @@ -38,7 +49,7 @@ public class TileAssemblyTable extends TileLaserTableBase implements IMachine, I nbt.setBoolean("s", select); NBTTagCompound itemNBT = new NBTTagCompound(); stack.writeToNBT(itemNBT); - nbt.setCompoundTag("i", itemNBT); + nbt.setTag("i", itemNBT); return nbt; } @@ -118,7 +129,7 @@ public class TileAssemblyTable extends TileLaserTableBase implements IMachine, I } @Override - public String getInvName() { + public String getInventoryName() { return StringUtils.localize("tile.assemblyTableBlock"); } @@ -126,15 +137,15 @@ public class TileAssemblyTable extends TileLaserTableBase implements IMachine, I public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); - NBTTagList list = nbt.getTagList("planned"); + NBTTagList list = nbt.getTagList("planned", Utils.NBTTag_Types.NBTTagCompound.ordinal()); for (int i = 0; i < list.tagCount(); ++i) { - NBTTagCompound cpt = (NBTTagCompound) list.tagAt(i); + NBTTagCompound cpt = list.getCompoundTagAt(i); ItemStack stack = ItemStack.loadItemStackFromNBT(cpt); for (AssemblyRecipe r : AssemblyRecipeManager.INSTANCE.getRecipes()) { - if (r.output.itemID == stack.itemID && r.output.getItemDamage() == stack.getItemDamage()) { + if (r.output.getItem() == stack.getItem() && r.output.getItemDamage() == stack.getItemDamage()) { plannedOutput.add(r); break; } @@ -145,7 +156,7 @@ public class TileAssemblyTable extends TileLaserTableBase implements IMachine, I ItemStack stack = ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("recipe")); for (AssemblyRecipe r : plannedOutput) { - if (r.output.itemID == stack.itemID && r.output.getItemDamage() == stack.getItemDamage()) { + if (r.output.getItem() == stack.getItem() && r.output.getItemDamage() == stack.getItemDamage()) { setCurrentRecipe(r); break; } @@ -272,7 +283,7 @@ public class TileAssemblyTable extends TileLaserTableBase implements IMachine, I packet.posY = yCoord; packet.posZ = zCoord; // FIXME: This needs to be switched over to new synch system. - CoreProxy.proxy.sendToPlayers(packet.getPacket(), worldObj, (int) player.posX, (int) player.posY, (int) player.posZ, + BuildCraftSilicon.instance.sendToPlayers(packet, worldObj, (int) player.posX, (int) player.posY, (int) player.posZ, DefaultProps.NETWORK_UPDATE_RANGE); } } @@ -302,14 +313,13 @@ public class TileAssemblyTable extends TileLaserTableBase implements IMachine, I return currentRecipe != null; } - @Override - public boolean isInvNameLocalized() { - // TODO Auto-generated method stub - return false; - } - @Override public boolean isItemValidForSlot(int slot, ItemStack stack) { return true; } + + @Override + public boolean hasCustomInventoryName() { + return false; + } } diff --git a/common/buildcraft/silicon/TileIntegrationTable.java b/common/buildcraft/silicon/TileIntegrationTable.java index 55876291..c9cdb4f7 100644 --- a/common/buildcraft/silicon/TileIntegrationTable.java +++ b/common/buildcraft/silicon/TileIntegrationTable.java @@ -1,7 +1,7 @@ -/* - * Copyright (c) SpaceToad, 2011-2012 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * + * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt @@ -20,12 +20,8 @@ import buildcraft.core.utils.Utils; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; -/** - * - * @author CovertJaguar - */ public class TileIntegrationTable extends TileLaserTableBase implements ISidedInventory { public static final int SLOT_INPUT_A = 0; @@ -167,7 +163,12 @@ public class TileIntegrationTable extends TileLaserTableBase implements ISidedIn } @Override - public String getInvName() { + public String getInventoryName() { return StringUtils.localize("tile.integrationTableBlock"); } + + @Override + public boolean hasCustomInventoryName() { + return false; + } } diff --git a/common/buildcraft/silicon/TileLaser.java b/common/buildcraft/silicon/TileLaser.java index 735d7336..ec5ef581 100644 --- a/common/buildcraft/silicon/TileLaser.java +++ b/common/buildcraft/silicon/TileLaser.java @@ -1,14 +1,18 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.silicon; import buildcraft.api.power.ILaserTarget; import buildcraft.BuildCraftCore; +import buildcraft.BuildCraftFactory; +import buildcraft.BuildCraftMod; +import buildcraft.BuildCraftSilicon; import buildcraft.api.core.Position; import buildcraft.api.core.SafeTimeTracker; import buildcraft.api.gates.IAction; @@ -22,11 +26,13 @@ import buildcraft.core.IMachine; import buildcraft.core.TileBuildCraft; import buildcraft.core.proxy.CoreProxy; import buildcraft.core.triggers.ActionMachineControl; + import java.util.LinkedList; import java.util.List; + import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; public class TileLaser extends TileBuildCraft implements IPowerReceptor, IActionReceptor, IMachine { @@ -54,7 +60,7 @@ public class TileLaser extends TileBuildCraft implements IPowerReceptor, IAction public void updateEntity() { super.updateEntity(); - if (!CoreProxy.proxy.isSimulating(worldObj)) + if (!!worldObj.isRemote) return; // If a gate disabled us, remove laser and do nothing. @@ -166,7 +172,7 @@ public class TileLaser extends TileBuildCraft implements IPowerReceptor, IAction for (int y = minY; y <= maxY; ++y) { for (int z = minZ; z <= maxZ; ++z) { - TileEntity tile = worldObj.getBlockTileEntity(x, y, z); + TileEntity tile = worldObj.getTileEntity(x, y, z); if (tile instanceof ILaserTarget) { ILaserTarget table = (ILaserTarget) tile; diff --git a/common/buildcraft/silicon/TileLaserTableBase.java b/common/buildcraft/silicon/TileLaserTableBase.java index 8266cca3..84dd7cf4 100644 --- a/common/buildcraft/silicon/TileLaserTableBase.java +++ b/common/buildcraft/silicon/TileLaserTableBase.java @@ -1,7 +1,7 @@ -/* - * Copyright (c) SpaceToad, 2011-2012 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * + * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt @@ -18,10 +18,6 @@ import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -/** - * - * @author CovertJaguar - */ public abstract class TileLaserTableBase extends TileBuildCraft implements ILaserTarget, IInventory { public double clientRequiredEnergy = 0; @@ -128,15 +124,15 @@ public abstract class TileLaserTableBase extends TileBuildCraft implements ILase @Override public boolean isUseableByPlayer(EntityPlayer player) { - return worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) == this && !isInvalid(); + return worldObj.getTileEntity(xCoord, yCoord, zCoord) == this && !isInvalid(); } @Override - public void openChest() { + public void openInventory() { } @Override - public void closeChest() { + public void closeInventory() { } @Override diff --git a/common/buildcraft/silicon/gui/ContainerAdvancedCraftingTable.java b/common/buildcraft/silicon/gui/ContainerAdvancedCraftingTable.java index db312d76..68c4a14b 100644 --- a/common/buildcraft/silicon/gui/ContainerAdvancedCraftingTable.java +++ b/common/buildcraft/silicon/gui/ContainerAdvancedCraftingTable.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.silicon.gui; import buildcraft.core.gui.BuildCraftContainer; diff --git a/common/buildcraft/silicon/gui/ContainerAssemblyTable.java b/common/buildcraft/silicon/gui/ContainerAssemblyTable.java index 61c60eb6..cf43bf6c 100644 --- a/common/buildcraft/silicon/gui/ContainerAssemblyTable.java +++ b/common/buildcraft/silicon/gui/ContainerAssemblyTable.java @@ -1,12 +1,11 @@ /** - * Copyright (c) SpaceToad, 2011 + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.silicon.gui; import buildcraft.core.gui.BuildCraftContainer; diff --git a/common/buildcraft/silicon/gui/ContainerIntegrationTable.java b/common/buildcraft/silicon/gui/ContainerIntegrationTable.java index 3bd6c70d..8de3b69e 100644 --- a/common/buildcraft/silicon/gui/ContainerIntegrationTable.java +++ b/common/buildcraft/silicon/gui/ContainerIntegrationTable.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.silicon.gui; import buildcraft.core.gui.BuildCraftContainer; diff --git a/common/buildcraft/silicon/gui/GuiAdvancedCraftingTable.java b/common/buildcraft/silicon/gui/GuiAdvancedCraftingTable.java index c0ca8eac..aa931e1b 100644 --- a/common/buildcraft/silicon/gui/GuiAdvancedCraftingTable.java +++ b/common/buildcraft/silicon/gui/GuiAdvancedCraftingTable.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.silicon.gui; import buildcraft.core.DefaultProps; diff --git a/common/buildcraft/silicon/gui/GuiAssemblyTable.java b/common/buildcraft/silicon/gui/GuiAssemblyTable.java index 66695b6c..b69f7943 100644 --- a/common/buildcraft/silicon/gui/GuiAssemblyTable.java +++ b/common/buildcraft/silicon/gui/GuiAssemblyTable.java @@ -1,13 +1,15 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.silicon.gui; import buildcraft.BuildCraftCore; +import buildcraft.BuildCraftSilicon; import buildcraft.core.CoreIconProvider; import buildcraft.core.DefaultProps; import buildcraft.core.gui.AdvancedSlot; @@ -60,13 +62,13 @@ public class GuiAssemblyTable extends GuiAdvancedInterface { if (!isFullyOpened()) return; - fontRenderer.drawStringWithShadow(StringUtils.localize("gui.energy"), x + 22, y + 8, headerColour); - fontRenderer.drawStringWithShadow(StringUtils.localize("gui.assemblyCurrentRequired") + ":", x + 22, y + 20, subheaderColour); - fontRenderer.drawString(String.format("%2.1f MJ", table.clientRequiredEnergy), x + 22, y + 32, textColour); - fontRenderer.drawStringWithShadow(StringUtils.localize("gui.stored") + ":", x + 22, y + 44, subheaderColour); - fontRenderer.drawString(String.format("%2.1f MJ", table.getEnergy()), x + 22, y + 56, textColour); - fontRenderer.drawStringWithShadow(StringUtils.localize("gui.assemblyRate") + ":", x + 22, y + 68, subheaderColour); - fontRenderer.drawString(String.format("%3.2f MJ/t", table.getRecentEnergyAverage() / 100.0f), x + 22, y + 80, textColour); + fontRendererObj.drawStringWithShadow(StringUtils.localize("gui.energy"), x + 22, y + 8, headerColour); + fontRendererObj.drawStringWithShadow(StringUtils.localize("gui.assemblyCurrentRequired") + ":", x + 22, y + 20, subheaderColour); + fontRendererObj.drawString(String.format("%2.1f MJ", table.clientRequiredEnergy), x + 22, y + 32, textColour); + fontRendererObj.drawStringWithShadow(StringUtils.localize("gui.stored") + ":", x + 22, y + 44, subheaderColour); + fontRendererObj.drawString(String.format("%2.1f MJ", table.getEnergy()), x + 22, y + 56, textColour); + fontRendererObj.drawStringWithShadow(StringUtils.localize("gui.assemblyRate") + ":", x + 22, y + 68, subheaderColour); + fontRendererObj.drawString(String.format("%3.2f MJ/t", table.getRecentEnergyAverage() / 100.0f), x + 22, y + 80, textColour); } @@ -115,9 +117,9 @@ public class GuiAssemblyTable extends GuiAdvancedInterface { updateRecipes(); // Request current selection from server - if (CoreProxy.proxy.isRenderWorld(assemblyTable.worldObj)) { - CoreProxy.proxy.sendToServer(new PacketCoordinates(PacketIds.SELECTION_ASSEMBLY_GET, assemblyTable.xCoord, assemblyTable.yCoord, - assemblyTable.zCoord).getPacket()); + if (assemblyTable.getWorldObj().isRemote) { + BuildCraftSilicon.instance.sendToServer(new PacketCoordinates(PacketIds.SELECTION_ASSEMBLY_GET, assemblyTable.xCoord, assemblyTable.yCoord, + assemblyTable.zCoord)); } } @@ -138,8 +140,8 @@ public class GuiAssemblyTable extends GuiAdvancedInterface { protected void drawGuiContainerForegroundLayer(int par1, int par2) { super.drawGuiContainerForegroundLayer(par1, par2); String title = StringUtils.localize("tile.assemblyTableBlock"); - fontRenderer.drawString(title, getCenteredOffset(title), 15, 0x404040); - fontRenderer.drawString(StringUtils.localize("gui.inventory"), 8, ySize - 97, 0x404040); + fontRendererObj.drawString(title, getCenteredOffset(title), 15, 0x404040); + fontRendererObj.drawString(StringUtils.localize("gui.inventory"), 8, ySize - 97, 0x404040); drawForegroundSelection(par1, par2); } @@ -197,14 +199,11 @@ public class GuiAssemblyTable extends GuiAdvancedInterface { message.stack = slot.recipe.output; - if (CoreProxy.proxy.isRenderWorld(table.worldObj)) { - + if (table.getWorldObj().isRemote) { PacketNBT packet = new PacketNBT(PacketIds.SELECTION_ASSEMBLY, message.getNBT(), table.xCoord, table.yCoord, table.zCoord); - - CoreProxy.proxy.sendToServer(packet.getPacket()); + BuildCraftSilicon.instance.sendToServer(packet); } } - } @Override diff --git a/common/buildcraft/silicon/gui/GuiIntegrationTable.java b/common/buildcraft/silicon/gui/GuiIntegrationTable.java index 66d52d87..5c4680eb 100644 --- a/common/buildcraft/silicon/gui/GuiIntegrationTable.java +++ b/common/buildcraft/silicon/gui/GuiIntegrationTable.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.silicon.gui; import buildcraft.core.DefaultProps; diff --git a/common/buildcraft/silicon/gui/GuiLaserTable.java b/common/buildcraft/silicon/gui/GuiLaserTable.java index 4eb18d89..6ca1b8f1 100644 --- a/common/buildcraft/silicon/gui/GuiLaserTable.java +++ b/common/buildcraft/silicon/gui/GuiLaserTable.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.silicon.gui; import buildcraft.BuildCraftCore; @@ -39,13 +47,13 @@ public abstract class GuiLaserTable extends GuiBuildCraft { if (!isFullyOpened()) return; - fontRenderer.drawStringWithShadow(StringUtils.localize("gui.energy"), x + 22, y + 8, headerColour); - fontRenderer.drawStringWithShadow(StringUtils.localize("gui.assemblyCurrentRequired") + ":", x + 22, y + 20, subheaderColour); - fontRenderer.drawString(String.format("%2.1f MJ", table.clientRequiredEnergy), x + 22, y + 32, textColour); - fontRenderer.drawStringWithShadow(StringUtils.localize("gui.stored") + ":", x + 22, y + 44, subheaderColour); - fontRenderer.drawString(String.format("%2.1f MJ", table.getEnergy()), x + 22, y + 56, textColour); - fontRenderer.drawStringWithShadow(StringUtils.localize("gui.assemblyRate") + ":", x + 22, y + 68, subheaderColour); - fontRenderer.drawString(String.format("%3.2f MJ/t", table.getRecentEnergyAverage() / 100.0f), x + 22, y + 80, textColour); + fontRendererObj.drawStringWithShadow(StringUtils.localize("gui.energy"), x + 22, y + 8, headerColour); + fontRendererObj.drawStringWithShadow(StringUtils.localize("gui.assemblyCurrentRequired") + ":", x + 22, y + 20, subheaderColour); + fontRendererObj.drawString(String.format("%2.1f MJ", table.clientRequiredEnergy), x + 22, y + 32, textColour); + fontRendererObj.drawStringWithShadow(StringUtils.localize("gui.stored") + ":", x + 22, y + 44, subheaderColour); + fontRendererObj.drawString(String.format("%2.1f MJ", table.getEnergy()), x + 22, y + 56, textColour); + fontRendererObj.drawStringWithShadow(StringUtils.localize("gui.assemblyRate") + ":", x + 22, y + 68, subheaderColour); + fontRendererObj.drawString(String.format("%3.2f MJ/t", table.getRecentEnergyAverage() / 100.0f), x + 22, y + 80, textColour); } @@ -64,9 +72,9 @@ public abstract class GuiLaserTable extends GuiBuildCraft { @Override protected void drawGuiContainerForegroundLayer(int par1, int par2) { super.drawGuiContainerForegroundLayer(par1, par2); - String title = table.getInvName(); - fontRenderer.drawString(title, getCenteredOffset(title), 6, 0x404040); - fontRenderer.drawString(StringUtils.localize("gui.inventory"), 8, ySize - 97, 0x404040); + String title = table.getInventoryName(); + fontRendererObj.drawString(title, getCenteredOffset(title), 6, 0x404040); + fontRendererObj.drawString(StringUtils.localize("gui.inventory"), 8, ySize - 97, 0x404040); } @Override diff --git a/common/buildcraft/silicon/network/PacketHandlerSilicon.java b/common/buildcraft/silicon/network/PacketHandlerSilicon.java index 6faa57db..515a5176 100644 --- a/common/buildcraft/silicon/network/PacketHandlerSilicon.java +++ b/common/buildcraft/silicon/network/PacketHandlerSilicon.java @@ -1,53 +1,63 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.silicon.network; +import buildcraft.core.network.BuildCraftChannelHandler; +import buildcraft.core.network.BuildCraftPacket; import buildcraft.core.network.PacketCoordinates; import buildcraft.core.network.PacketIds; import buildcraft.core.network.PacketNBT; import buildcraft.core.network.PacketSlotChange; +import buildcraft.core.proxy.CoreProxy; +import buildcraft.core.utils.Utils; import buildcraft.silicon.TileAdvancedCraftingTable; import buildcraft.silicon.TileAssemblyTable; import buildcraft.silicon.TileAssemblyTable.SelectionMessage; import buildcraft.silicon.gui.ContainerAssemblyTable; -import cpw.mods.fml.common.network.IPacketHandler; -import cpw.mods.fml.common.network.Player; +import io.netty.buffer.ByteBuf; +import io.netty.channel.ChannelHandlerContext; + import java.io.ByteArrayInputStream; import java.io.DataInputStream; + +import cpw.mods.fml.common.network.NetworkRegistry; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; -import net.minecraft.network.INetworkManager; -import net.minecraft.network.packet.Packet250CustomPayload; +import net.minecraft.network.INetHandler; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; -public class PacketHandlerSilicon implements IPacketHandler { +public class PacketHandlerSilicon extends BuildCraftChannelHandler { @Override - public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player) { - - DataInputStream data = new DataInputStream(new ByteArrayInputStream(packet.data)); + public void decodeInto(ChannelHandlerContext ctx, ByteBuf data, BuildCraftPacket packet) { + super.decodeInto(ctx, data, packet); + try { - int packetID = data.read(); + INetHandler netHandler = ctx.channel().attr(NetworkRegistry.NET_HANDLER).get(); + + EntityPlayer player = Utils.getPlayerFromNetHandler(netHandler); + + int packetID = packet.getID(); + switch (packetID) { - case PacketIds.SELECTION_ASSEMBLY_SEND: - PacketNBT packetT = new PacketNBT(); - packetT.readData(data); - onSelectionUpdate((EntityPlayer) player, packetT); + case PacketIds.SELECTION_ASSEMBLY_SEND: + onSelectionUpdate(player, (PacketNBT) packet); break; - case PacketIds.SELECTION_ASSEMBLY: - PacketNBT packetA = new PacketNBT(); - packetA.readData(data); - onAssemblySelect((EntityPlayer) player, packetA); + onAssemblySelect(player, (PacketNBT) packet); break; case PacketIds.SELECTION_ASSEMBLY_GET: - PacketCoordinates packetC = new PacketCoordinates(); - packetC.readData(data); - onAssemblyGetSelection((EntityPlayer) player, packetC); + onAssemblyGetSelection(player, (PacketCoordinates) packet); break; case PacketIds.ADVANCED_WORKBENCH_SETSLOT: - PacketSlotChange packet1 = new PacketSlotChange(); - packet1.readData(data); - onAdvancedWorkbenchSet((EntityPlayer) player, packet1); + onAdvancedWorkbenchSet(player, (PacketSlotChange) packet); break; } @@ -73,7 +83,7 @@ public class PacketHandlerSilicon implements IPacketHandler { if (!world.blockExists(x, y, z)) return null; - TileEntity tile = world.getBlockTileEntity(x, y, z); + TileEntity tile = world.getTileEntity(x, y, z); if (!(tile instanceof TileAssemblyTable)) return null; @@ -85,7 +95,7 @@ public class PacketHandlerSilicon implements IPacketHandler { if (!world.blockExists(x, y, z)) return null; - TileEntity tile = world.getBlockTileEntity(x, y, z); + TileEntity tile = world.getTileEntity(x, y, z); if (!(tile instanceof TileAdvancedCraftingTable)) return null; diff --git a/common/buildcraft/silicon/recipes/GateExpansionRecipe.java b/common/buildcraft/silicon/recipes/GateExpansionRecipe.java index aeb91b7d..6f601d8a 100644 --- a/common/buildcraft/silicon/recipes/GateExpansionRecipe.java +++ b/common/buildcraft/silicon/recipes/GateExpansionRecipe.java @@ -1,7 +1,7 @@ -/* - * Copyright (c) SpaceToad, 2011-2012 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * + * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt @@ -14,10 +14,6 @@ import buildcraft.core.inventory.StackHelper; import buildcraft.transport.gates.ItemGate; import net.minecraft.item.ItemStack; -/** - * - * @author CovertJaguar - */ public class GateExpansionRecipe implements IIntegrationRecipe { private final IGateExpansion expansion; diff --git a/common/buildcraft/silicon/recipes/GateLogicSwapRecipe.java b/common/buildcraft/silicon/recipes/GateLogicSwapRecipe.java index 6fbe3afe..dba84c10 100644 --- a/common/buildcraft/silicon/recipes/GateLogicSwapRecipe.java +++ b/common/buildcraft/silicon/recipes/GateLogicSwapRecipe.java @@ -1,7 +1,7 @@ -/* - * Copyright (c) SpaceToad, 2011-2012 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * + * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt @@ -16,10 +16,6 @@ import buildcraft.transport.gates.GateDefinition.GateMaterial; import buildcraft.transport.gates.ItemGate; import net.minecraft.item.ItemStack; -/** - * - * @author CovertJaguar - */ public class GateLogicSwapRecipe implements IIntegrationRecipe { private final GateMaterial material; diff --git a/common/buildcraft/transport/BlockFilteredBuffer.java b/common/buildcraft/transport/BlockFilteredBuffer.java index 9e1188c5..e31b2a6c 100644 --- a/common/buildcraft/transport/BlockFilteredBuffer.java +++ b/common/buildcraft/transport/BlockFilteredBuffer.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.transport; @@ -16,28 +17,24 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import java.util.ArrayList; import net.minecraft.block.material.Material; -import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Icon; +import net.minecraft.util.IIcon; import net.minecraft.world.World; -/** - * - * @author SandGrainOne - */ public class BlockFilteredBuffer extends BlockBuildCraft { - private static Icon blockTexture; + private static IIcon blockTexture; - public BlockFilteredBuffer(int blockId) { - super(blockId, Material.iron); + public BlockFilteredBuffer() { + super(Material.iron); setHardness(5F); } @Override - public TileEntity createNewTileEntity(World var1) { + public TileEntity createNewTileEntity(World world, int metadata) { return new TileFilteredBuffer(); } @@ -57,28 +54,22 @@ public class BlockFilteredBuffer extends BlockBuildCraft { } } - if (!CoreProxy.proxy.isRenderWorld(world)) { + if (!world.isRemote) { entityplayer.openGui(BuildCraftTransport.instance, GuiIds.FILTERED_BUFFER, world, x, y, z); } return true; } - @SuppressWarnings({"unchecked", "rawtypes"}) - @Override - public void addCreativeItems(ArrayList itemList) { - itemList.add(new ItemStack(this)); - } - @Override @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister par1IconRegister) { + public void registerBlockIcons(IIconRegister par1IconRegister) { blockTexture = par1IconRegister.registerIcon("buildcraft:filteredBuffer_all"); } @Override @SideOnly(Side.CLIENT) - public Icon getIcon(int i, int j) { + public IIcon getIcon(int i, int j) { return blockTexture; } } diff --git a/common/buildcraft/transport/BlockGenericPipe.java b/common/buildcraft/transport/BlockGenericPipe.java index ac754a18..d49538ec 100644 --- a/common/buildcraft/transport/BlockGenericPipe.java +++ b/common/buildcraft/transport/BlockGenericPipe.java @@ -8,10 +8,8 @@ */ package buildcraft.transport; -import buildcraft.api.transport.PipeWire; -import buildcraft.transport.gates.ItemGate; - import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Locale; @@ -20,47 +18,46 @@ import java.util.Random; import net.minecraft.block.Block; import net.minecraft.block.material.Material; +import net.minecraft.client.Minecraft; import net.minecraft.client.particle.EffectRenderer; import net.minecraft.client.particle.EntityDiggingFX; -import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.Icon; +import net.minecraft.util.IIcon; import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.Vec3; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; import buildcraft.BuildCraftTransport; import buildcraft.api.gates.GateExpansions; import buildcraft.api.gates.IGateExpansion; import buildcraft.api.tools.IToolWrench; +import buildcraft.api.transport.PipeWire; import buildcraft.core.BlockBuildCraft; import buildcraft.core.BlockIndex; import buildcraft.core.CoreConstants; import buildcraft.core.ItemRobot; -import buildcraft.core.proxy.CoreProxy; import buildcraft.core.robots.AIDocked; import buildcraft.core.robots.EntityRobot; import buildcraft.core.utils.BCLog; -import buildcraft.core.utils.Utils; import buildcraft.core.utils.MatrixTranformations; +import buildcraft.core.utils.Utils; import buildcraft.transport.gates.GateDefinition; import buildcraft.transport.gates.GateFactory; +import buildcraft.transport.gates.ItemGate; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import java.util.Arrays; - -import net.minecraft.client.Minecraft; - public class BlockGenericPipe extends BlockBuildCraft { static enum Part { @@ -94,8 +91,8 @@ public class BlockGenericPipe extends BlockBuildCraft { private int renderMask = 0; /* Defined subprograms ************************************************* */ - public BlockGenericPipe(int i) { - super(i, Material.glass); + public BlockGenericPipe() { + super(Material.glass); setRenderAllSides(); setCreativeTab(null); } @@ -116,7 +113,7 @@ public class BlockGenericPipe extends BlockBuildCraft { } @Override - public boolean canBeReplacedByLeaves(World world, int x, int y, int z) { + public boolean canBeReplacedByLeaves(IBlockAccess world, int x, int y, int z) { return false; } @@ -148,15 +145,18 @@ public class BlockGenericPipe extends BlockBuildCraft { } @Override - public boolean isBlockSolidOnSide(World world, int x, int y, int z, ForgeDirection side) { - TileEntity tile = world.getBlockTileEntity(x, y, z); + public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) { + TileEntity tile = world.getTileEntity(x, y, z); + if (tile instanceof ISolidSideTile) { return ((ISolidSideTile) tile).isSolidOnSide(side); } + return false; } - public boolean isACube() { + @Override + public boolean isNormalCube() { return false; } @@ -166,7 +166,7 @@ public class BlockGenericPipe extends BlockBuildCraft { setBlockBounds(CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS); super.addCollisionBoxesToList(world, i, j, k, axisalignedbb, arraylist, par7Entity); - TileEntity tile1 = world.getBlockTileEntity(i, j, k); + TileEntity tile1 = world.getTileEntity(i, j, k); if (tile1 instanceof TileGenericPipe) { TileGenericPipe tileG = (TileGenericPipe) tile1; @@ -288,7 +288,7 @@ public class BlockGenericPipe extends BlockBuildCraft { } private RaytraceResult doRayTrace(World world, int x, int y, int z, Vec3 origin, Vec3 direction) { - TileEntity pipeTileEntity = world.getBlockTileEntity(x, y, z); + TileEntity pipeTileEntity = world.getTileEntity(x, y, z); TileGenericPipe tileG = null; if (pipeTileEntity instanceof TileGenericPipe) @@ -518,7 +518,7 @@ public class BlockGenericPipe extends BlockBuildCraft { pipe.onBlockRemoval(); } - World world = pipe.container.worldObj; + World world = pipe.container.getWorldObj(); if (world == null) return; @@ -533,20 +533,20 @@ public class BlockGenericPipe extends BlockBuildCraft { } pipeRemoved.put(new BlockIndex(x, y, z), pipe); - world.removeBlockTileEntity(x, y, z); + world.removeTileEntity(x, y, z); } @Override - public void breakBlock(World world, int x, int y, int z, int par5, int par6) { + public void breakBlock(World world, int x, int y, int z, Block block, int par6) { Utils.preDestroyBlock(world, x, y, z); removePipe(getPipe(world, x, y, z)); - super.breakBlock(world, x, y, z, par5, par6); + super.breakBlock(world, x, y, z, block, par6); } @Override - public ArrayList getBlockDropped(World world, int x, int y, int z, int metadata, int fortune) { + public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) { - if (CoreProxy.proxy.isRenderWorld(world)) + if (world.isRemote) return null; ArrayList list = new ArrayList(); @@ -560,9 +560,9 @@ public class BlockGenericPipe extends BlockBuildCraft { } if (pipe != null) { - if (pipe.itemID > 0) { + if (pipe.item != null) { pipe.dropContents(); - list.add(new ItemStack(pipe.itemID, 1, damageDropped(metadata))); + list.add(new ItemStack(pipe.item, 1, damageDropped(metadata))); } } } @@ -570,14 +570,14 @@ public class BlockGenericPipe extends BlockBuildCraft { } @Override - public TileEntity createNewTileEntity(World var1) { + public TileEntity createNewTileEntity(World world, int metadata) { return new TileGenericPipe(); } @Override public void dropBlockAsItemWithChance(World world, int i, int j, int k, int l, float f, int dmg) { - if (CoreProxy.proxy.isRenderWorld(world)) + if (world.isRemote) return; int i1 = quantityDropped(world.rand); @@ -593,23 +593,23 @@ public class BlockGenericPipe extends BlockBuildCraft { } if (pipe != null) { - int k1 = pipe.itemID; + Item k1 = pipe.item; - if (k1 > 0) { + if (k1 != null) { pipe.dropContents(); - dropBlockAsItem_do(world, i, j, k, new ItemStack(k1, 1, damageDropped(l))); + dropBlockAsItem(world, i, j, k, new ItemStack(k1, 1, damageDropped(l))); } } } } @Override - public int idDropped(int meta, Random rand, int dmg) { - // Returns 0 to be safe - the id does not depend on the meta - return 0; + public Item getItemDropped(int meta, Random rand, int dmg) { + // Returns null to be safe - the id does not depend on the meta + return null; } - @SideOnly(Side.CLIENT) + /*@SideOnly(Side.CLIENT) @Override public int idPicked(World world, int i, int j, int k) { Pipe pipe = getPipe(world, i, j, k); @@ -618,7 +618,7 @@ public class BlockGenericPipe extends BlockBuildCraft { return 0; else return pipe.itemID; - } + }*/ @SideOnly(Side.CLIENT) @Override @@ -641,8 +641,8 @@ public class BlockGenericPipe extends BlockBuildCraft { /* Wrappers ************************************************************ */ @Override - public void onNeighborBlockChange(World world, int x, int y, int z, int id) { - super.onNeighborBlockChange(world, x, y, z, id); + public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { + super.onNeighborBlockChange(world, x, y, z, block); Pipe pipe = getPipe(world, x, y, z); @@ -678,7 +678,7 @@ public class BlockGenericPipe extends BlockBuildCraft { public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float xOffset, float yOffset, float zOffset) { super.onBlockActivated(world, x, y, z, player, side, xOffset, yOffset, zOffset); - world.notifyBlocksOfNeighborChange(x, y, z, BuildCraftTransport.genericPipeBlock.blockID); + world.notifyBlocksOfNeighborChange(x, y, z, BuildCraftTransport.genericPipeBlock); Pipe pipe = getPipe(world, x, y, z); @@ -692,7 +692,7 @@ public class BlockGenericPipe extends BlockBuildCraft { return true; } else if (currentItem == null) { // Fall through the end of the test - } else if (currentItem.itemID == Item.sign.itemID) + } else if (currentItem.getItem() == Items.sign) // Sign will be placed anyway, so lets show the sign gui return false; else if (currentItem.getItem() instanceof ItemPipe) @@ -734,7 +734,7 @@ public class BlockGenericPipe extends BlockBuildCraft { return true; } } else if (currentItem.getItem () instanceof ItemRobot) { - if (CoreProxy.proxy.isSimulating(world)) { + if (!world.isRemote) { RaytraceResult rayTraceResult = doRayTrace(world, x, y, z, player); @@ -742,9 +742,9 @@ public class BlockGenericPipe extends BlockBuildCraft { EntityRobot robot = ((ItemRobot) currentItem.getItem()) .createRobot(world); - float px = x + 0.5F + (float) rayTraceResult.sideHit.offsetX * 0.5F; - float py = y + 0.5F + (float) rayTraceResult.sideHit.offsetY * 0.5F; - float pz = z + 0.5F + (float) rayTraceResult.sideHit.offsetZ * 0.5F; + float px = x + 0.5F + rayTraceResult.sideHit.offsetX * 0.5F; + float py = y + 0.5F + rayTraceResult.sideHit.offsetY * 0.5F; + float pz = z + 0.5F + rayTraceResult.sideHit.offsetZ * 0.5F; robot.setPosition(px, py, pz); robot.setDockingStation(pipe.container, @@ -808,7 +808,7 @@ public class BlockGenericPipe extends BlockBuildCraft { private boolean stripGate(Pipe pipe) { if (pipe.hasGate()) { - if (!CoreProxy.proxy.isRenderWorld(pipe.container.worldObj)) { + if (!pipe.container.getWorldObj().isRemote) { pipe.gate.dropGate(); } pipe.resetGate(); @@ -839,7 +839,7 @@ public class BlockGenericPipe extends BlockBuildCraft { private boolean stripWire(Pipe pipe, PipeWire color) { if (pipe.wireSet[color.ordinal()]) { - if (!CoreProxy.proxy.isRenderWorld(pipe.container.worldObj)) { + if (!pipe.container.getWorldObj().isRemote) { dropWire(color, pipe); } pipe.wireSet[color.ordinal()] = false; @@ -866,7 +866,7 @@ public class BlockGenericPipe extends BlockBuildCraft { private boolean addFacade(EntityPlayer player, Pipe pipe, ForgeDirection side) { ItemStack stack = player.getCurrentEquippedItem(); - if (pipe.container.addFacade(side, ItemFacade.getBlockId(stack), ItemFacade.getMetaData(stack))) { + if (pipe.container.addFacade(side, ItemFacade.getBlock(stack), ItemFacade.getMetaData(stack))) { if (!player.capabilities.isCreativeMode) { stack.stackSize--; } @@ -968,8 +968,8 @@ public class BlockGenericPipe extends BlockBuildCraft { @SuppressWarnings({"all"}) @SideOnly(Side.CLIENT) @Override - public Icon getBlockTexture(IBlockAccess iblockaccess, int x, int y, int z, int side) { - TileEntity tile = iblockaccess.getBlockTileEntity(x, y, z); + public IIcon getIcon(IBlockAccess iblockaccess, int x, int y, int z, int side) { + TileEntity tile = iblockaccess.getTileEntity(x, y, z); if (!(tile instanceof TileGenericPipe)) return null; if (((TileGenericPipe) tile).renderState.textureArray != null) @@ -1034,18 +1034,18 @@ public class BlockGenericPipe extends BlockBuildCraft { } /* Registration ******************************************************** */ - public static Map> pipes = new HashMap>(); + public static Map> pipes = new HashMap>(); static long lastRemovedDate = -1; public static Map pipeRemoved = new HashMap(); - public static ItemPipe registerPipe(int key, Class clas) { - ItemPipe item = new ItemPipe(key); + public static ItemPipe registerPipe(Class clas) { + ItemPipe item = new ItemPipe(); item.setUnlocalizedName("buildcraftPipe." + clas.getSimpleName().toLowerCase(Locale.ENGLISH)); GameRegistry.registerItem(item, item.getUnlocalizedName()); - pipes.put(item.itemID, clas); + pipes.put(item, clas); - Pipe dummyPipe = createPipe(item.itemID); + Pipe dummyPipe = createPipe(item); if (dummyPipe != null) { item.setPipeIconIndex(dummyPipe.getIconIndexForItem()); TransportProxy.proxy.setIconProviderFromPipe(item, dummyPipe); @@ -1057,12 +1057,12 @@ public class BlockGenericPipe extends BlockBuildCraft { return pipes.containsKey(key); } - public static Pipe createPipe(int key) { + public static Pipe createPipe(Item key) { try { Class pipe = pipes.get(key); if (pipe != null) - return pipe.getConstructor(int.class).newInstance(key); + return pipe.getConstructor(Item.class).newInstance(key); else { BCLog.logger.warning("Detected pipe with unknown key (" + key + "). Did you remove a buildcraft addon?"); } @@ -1074,14 +1074,14 @@ public class BlockGenericPipe extends BlockBuildCraft { return null; } - public static boolean placePipe(Pipe pipe, World world, int i, int j, int k, int blockId, int meta) { + public static boolean placePipe(Pipe pipe, World world, int i, int j, int k, Block block, int meta) { if (world.isRemote) return true; - boolean placed = world.setBlock(i, j, k, blockId, meta, 3); + boolean placed = world.setBlock(i, j, k, block, meta, 3); if (placed) { - TileGenericPipe tile = (TileGenericPipe) world.getBlockTileEntity(i, j, k); + TileGenericPipe tile = (TileGenericPipe) world.getTileEntity(i, j, k); tile.initialize(pipe); tile.sendUpdateToClient(); } @@ -1091,7 +1091,7 @@ public class BlockGenericPipe extends BlockBuildCraft { public static Pipe getPipe(IBlockAccess blockAccess, int i, int j, int k) { - TileEntity tile = blockAccess.getBlockTileEntity(i, j, k); + TileEntity tile = blockAccess.getTileEntity(i, j, k); if (!(tile instanceof TileGenericPipe) || tile.isInvalid()) return null; @@ -1109,13 +1109,13 @@ public class BlockGenericPipe extends BlockBuildCraft { @Override @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister iconRegister) { + public void registerBlockIcons(IIconRegister iconRegister) { if (!skippedFirstIconRegister) { skippedFirstIconRegister = true; return; } BuildCraftTransport.instance.wireIconProvider.registerIcons(iconRegister); - for (int i : pipes.keySet()) { + for (Item i : pipes.keySet()) { Pipe dummyPipe = createPipe(i); if (dummyPipe != null) { dummyPipe.getIconProvider().registerIcons(iconRegister); @@ -1138,7 +1138,7 @@ public class BlockGenericPipe extends BlockBuildCraft { @Override @SideOnly(Side.CLIENT) - public Icon getIcon(int par1, int par2) { + public IIcon getIcon(int par1, int par2) { return BuildCraftTransport.instance.pipeIconProvider.getIcon(PipeIconProvider.TYPE.Stripes.ordinal()); } @@ -1155,7 +1155,7 @@ public class BlockGenericPipe extends BlockBuildCraft { */ @SideOnly(Side.CLIENT) @Override - public boolean addBlockHitEffects(World worldObj, MovingObjectPosition target, EffectRenderer effectRenderer) { + public boolean addHitEffects(World worldObj, MovingObjectPosition target, EffectRenderer effectRenderer) { int x = target.blockX; int y = target.blockY; int z = target.blockZ; @@ -1164,7 +1164,7 @@ public class BlockGenericPipe extends BlockBuildCraft { if (pipe == null) return false; - Icon icon = pipe.getIconProvider().getIcon(pipe.getIconIndexForItem()); + IIcon icon = pipe.getIconProvider().getIcon(pipe.getIconIndexForItem()); int sideHit = target.sideHit; @@ -1220,12 +1220,12 @@ public class BlockGenericPipe extends BlockBuildCraft { */ @SideOnly(Side.CLIENT) @Override - public boolean addBlockDestroyEffects(World worldObj, int x, int y, int z, int meta, EffectRenderer effectRenderer) { + public boolean addDestroyEffects(World worldObj, int x, int y, int z, int meta, EffectRenderer effectRenderer) { Pipe pipe = getPipe(worldObj, x, y, z); if (pipe == null) return false; - Icon icon = pipe.getIconProvider().getIcon(pipe.getIconIndexForItem()); + IIcon icon = pipe.getIconProvider().getIcon(pipe.getIconIndexForItem()); byte its = 4; for (int i = 0; i < its; ++i) { diff --git a/common/buildcraft/transport/Gate.java b/common/buildcraft/transport/Gate.java index 109b0436..87dbb6ee 100644 --- a/common/buildcraft/transport/Gate.java +++ b/common/buildcraft/transport/Gate.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.transport; import buildcraft.api.transport.PipeWire; @@ -35,7 +43,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; public final class Gate { @@ -147,8 +155,8 @@ public final class Gate { // GUI public void openGui(EntityPlayer player) { - if (!CoreProxy.proxy.isRenderWorld(player.worldObj)) { - player.openGui(BuildCraftTransport.instance, GuiIds.GATES, pipe.container.worldObj, pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord); + if (!player.worldObj.isRemote) { + player.openGui(BuildCraftTransport.instance, GuiIds.GATES, pipe.container.getWorldObj(), pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord); } } diff --git a/common/buildcraft/transport/GuiHandler.java b/common/buildcraft/transport/GuiHandler.java index fd9158a0..ca1df888 100644 --- a/common/buildcraft/transport/GuiHandler.java +++ b/common/buildcraft/transport/GuiHandler.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.transport; import buildcraft.core.GuiIds; @@ -29,7 +37,7 @@ public class GuiHandler implements IGuiHandler { if (!world.blockExists(x, y, z)) return null; - TileEntity tile = world.getBlockTileEntity(x, y, z); + TileEntity tile = world.getTileEntity(x, y, z); if (tile instanceof TileFilteredBuffer) { TileFilteredBuffer filteredBuffer = (TileFilteredBuffer) tile; @@ -73,7 +81,7 @@ public class GuiHandler implements IGuiHandler { if (!world.blockExists(x, y, z)) return null; - TileEntity tile = world.getBlockTileEntity(x, y, z); + TileEntity tile = world.getTileEntity(x, y, z); if (tile instanceof TileFilteredBuffer) { TileFilteredBuffer filteredBuffer = (TileFilteredBuffer) tile; diff --git a/common/buildcraft/transport/IItemTravelingHook.java b/common/buildcraft/transport/IItemTravelingHook.java index 51abbad6..5449fddc 100644 --- a/common/buildcraft/transport/IItemTravelingHook.java +++ b/common/buildcraft/transport/IItemTravelingHook.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.transport; import net.minecraft.tileentity.TileEntity; diff --git a/common/buildcraft/transport/IPipeConnectionForced.java b/common/buildcraft/transport/IPipeConnectionForced.java index 209e5c31..330a583c 100644 --- a/common/buildcraft/transport/IPipeConnectionForced.java +++ b/common/buildcraft/transport/IPipeConnectionForced.java @@ -1,6 +1,14 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.transport; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; public interface IPipeConnectionForced { diff --git a/common/buildcraft/transport/IPipeTransportFluidsHook.java b/common/buildcraft/transport/IPipeTransportFluidsHook.java index 0d12c212..a8f1ee03 100644 --- a/common/buildcraft/transport/IPipeTransportFluidsHook.java +++ b/common/buildcraft/transport/IPipeTransportFluidsHook.java @@ -1,15 +1,14 @@ /** - * Copyright (c) SpaceToad, 2011 + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.transport; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; public interface IPipeTransportFluidsHook { diff --git a/common/buildcraft/transport/IPipeTransportItemsHook.java b/common/buildcraft/transport/IPipeTransportItemsHook.java index 3be90a42..7e087983 100644 --- a/common/buildcraft/transport/IPipeTransportItemsHook.java +++ b/common/buildcraft/transport/IPipeTransportItemsHook.java @@ -1,15 +1,16 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.transport; import buildcraft.api.core.Position; import java.util.LinkedList; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; /** * @deprecated This has been replaced by the Pipe Event system. diff --git a/common/buildcraft/transport/IPipeTransportPowerHook.java b/common/buildcraft/transport/IPipeTransportPowerHook.java index 898019ca..af7a1fae 100644 --- a/common/buildcraft/transport/IPipeTransportPowerHook.java +++ b/common/buildcraft/transport/IPipeTransportPowerHook.java @@ -1,15 +1,14 @@ /** - * Copyright (c) SpaceToad, 2011 + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.transport; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; public interface IPipeTransportPowerHook { diff --git a/common/buildcraft/transport/IPipeTrigger.java b/common/buildcraft/transport/IPipeTrigger.java index 50368edb..4e09294a 100644 --- a/common/buildcraft/transport/IPipeTrigger.java +++ b/common/buildcraft/transport/IPipeTrigger.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.transport; diff --git a/common/buildcraft/transport/ISolidSideTile.java b/common/buildcraft/transport/ISolidSideTile.java index 81cef096..7ab82d45 100644 --- a/common/buildcraft/transport/ISolidSideTile.java +++ b/common/buildcraft/transport/ISolidSideTile.java @@ -1,6 +1,14 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.transport; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; public interface ISolidSideTile { public boolean isSolidOnSide(ForgeDirection side); diff --git a/common/buildcraft/transport/ItemFacade.java b/common/buildcraft/transport/ItemFacade.java index 7c19f782..bdccd182 100644 --- a/common/buildcraft/transport/ItemFacade.java +++ b/common/buildcraft/transport/ItemFacade.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.transport; import buildcraft.BuildCraftTransport; @@ -6,19 +14,25 @@ import buildcraft.api.recipes.BuildcraftRecipes; import buildcraft.core.CreativeTabBuildCraft; import buildcraft.core.ItemBuildCraft; import buildcraft.core.proxy.CoreProxy; + import com.google.common.base.Strings; import com.google.common.collect.Sets; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; + import java.lang.reflect.Field; import java.lang.reflect.Modifier; +import java.util.ArrayList; import java.util.LinkedList; import java.util.List; import java.util.Set; + import net.minecraft.block.Block; -import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -26,36 +40,37 @@ import net.minecraft.item.crafting.IRecipe; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; public class ItemFacade extends ItemBuildCraft { public final static LinkedList allFacades = new LinkedList(); - public ItemFacade(int i) { - super(i); + public ItemFacade() { + super(); setHasSubtypes(true); setMaxDamage(0); setCreativeTab(CreativeTabBuildCraft.FACADES.get()); } - @Override + //TODO: how to control name of items? + /*@Override public String getItemDisplayName(ItemStack itemstack) { String name = super.getItemDisplayName(itemstack); - int decodedBlockId = ItemFacade.getBlockId(itemstack); + Block decodedBlock = ItemFacade.getBlock(itemstack); int decodedMeta = ItemFacade.getMetaData(itemstack); - if (decodedBlockId < Block.blocksList.length && Block.blocksList[decodedBlockId] != null && Block.blocksList[decodedBlockId].getRenderType() == 31) { + if (decodedBlock != null && decodedBlock.getRenderType() == 31) { decodedMeta &= 0x3; } - ItemStack newStack = new ItemStack(decodedBlockId, 1, decodedMeta); - if (Item.itemsList[decodedBlockId] != null) { + ItemStack newStack = new ItemStack(decodedBlock, 1, decodedMeta); + if (Item.getItemFromBlock(decodedBlock) != null) { name += ": " + CoreProxy.proxy.getItemDisplayName(newStack); } else { - name += " < BROKEN (" + decodedBlockId + ":" + decodedMeta + " )>"; + name += " < BROKEN (" + decodedBlock.getLocalizedName() + ":" + decodedMeta + " )>"; } return name; - } + }*/ @Override public String getUnlocalizedName(ItemStack itemstack) { @@ -65,7 +80,7 @@ public class ItemFacade extends ItemBuildCraft { @SuppressWarnings({"unchecked", "rawtypes"}) @Override @SideOnly(Side.CLIENT) - public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List itemList) { + public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) { // Do not call super, that would add a 0:0 facade for (ItemStack stack : allFacades) { itemList.add(stack.copy()); @@ -79,12 +94,12 @@ public class ItemFacade extends ItemBuildCraft { Position pos = new Position(x, y, z, ForgeDirection.getOrientation(side)); pos.moveForwards(1.0); - TileEntity tile = worldObj.getBlockTileEntity((int) pos.x, (int) pos.y, (int) pos.z); + TileEntity tile = worldObj.getTileEntity((int) pos.x, (int) pos.y, (int) pos.z); if (!(tile instanceof TileGenericPipe)) return false; TileGenericPipe pipeTile = (TileGenericPipe) tile; - if (pipeTile.addFacade(ForgeDirection.getOrientation(side).getOpposite(), ItemFacade.getBlockId(stack), ItemFacade.getMetaData(stack))) { + if (pipeTile.addFacade(ForgeDirection.getOrientation(side).getOpposite(), ItemFacade.getBlock(stack), ItemFacade.getMetaData(stack))) { if (!player.capabilities.isCreativeMode) { stack.stackSize--; } @@ -94,36 +109,42 @@ public class ItemFacade extends ItemBuildCraft { } public static void initialize() { - for (Field f : Block.class.getDeclaredFields()) { - if (Modifier.isStatic(f.getModifiers()) && Block.class.isAssignableFrom(f.getType())) { - Block b; - try { - b = (Block) f.get(null); - } catch (Exception e) { + for (Object o : Block.blockRegistry) { + Block b = (Block) o; + + if (!(b == Blocks.glass)) { + if (b == Blocks.bedrock + || b == Blocks.grass + || b == Blocks.leaves + || b == Blocks.sponge + || b == Blocks.chest + || b == Blocks.redstone_lamp + || b == Blocks.lit_redstone_lamp + || b == Blocks.lit_pumpkin) { continue; } - - if (!(b.blockID == 20)) { //Explicitly allow glass - if (b.blockID == 7 //Bedrock - || b.blockID == 2 //Grass block - || b.blockID == 18 //Oak leaves - || b.blockID == 19 //Sponge - || b.blockID == 95 //Locked chest - || b.blockID == Block.redstoneLampIdle.blockID - || b.blockID == Block.redstoneLampActive.blockID - || b.blockID == Block.pumpkinLantern.blockID) { - continue; - } - if (!b.isOpaqueCube() || b.hasTileEntity(0) || !b.renderAsNormalBlock()) { - continue; - } + + if (!b.isOpaqueCube() + || b.hasTileEntity(0) + || !b.renderAsNormalBlock() + || b.getRenderType() != 0) { + continue; } - ItemStack base = new ItemStack(b, 1); + } + + Item item = Item.getItemFromBlock(b); + + if (item != null) { + ItemStack base = new ItemStack(item, 1); + if (base.getHasSubtypes()) { Set names = Sets.newHashSet(); + for (int meta = 0; meta <= 15; meta++) { - ItemStack is = new ItemStack(b, 1, meta); - if (!Strings.isNullOrEmpty(is.getUnlocalizedName()) && names.add(is.getUnlocalizedName())) { + ItemStack is = new ItemStack(item, 1, meta); + + if (!Strings.isNullOrEmpty(is.getUnlocalizedName()) + && names.add(is.getUnlocalizedName())) { ItemFacade.addFacade(is); } } @@ -135,25 +156,29 @@ public class ItemFacade extends ItemBuildCraft { } public static int getMetaData(ItemStack stack) { - if (stack.hasTagCompound() && stack.getTagCompound().hasKey("meta")) + if (stack.hasTagCompound() && stack.getTagCompound().hasKey("meta")) { return stack.getTagCompound().getInteger("meta"); - return stack.getItemDamage() & 0x0000F; + } else { + return stack.getItemDamage() & 0x0000F; + } } - public static int getBlockId(ItemStack stack) { - if (stack.hasTagCompound() && stack.getTagCompound().hasKey("id")) - return stack.getTagCompound().getInteger("id"); - return ((stack.getItemDamage() & 0xFFF0) >>> 4); + public static Block getBlock(ItemStack stack) { + if (stack.hasTagCompound() && stack.getTagCompound().hasKey("id")) { + return (Block) Block.blockRegistry.getObjectById(stack.getTagCompound().getInteger("id")); + } else { + return (Block) Block.blockRegistry.getObjectById((stack.getItemDamage() & 0xFFF0) >>> 4); + } } @Override - public boolean shouldPassSneakingClickToBlock(World worldObj, int x, int y, int z) { + public boolean doesSneakBypassUse(World world, int x, int y, int z, EntityPlayer player) { // Simply send shift click to the pipe / mod block. return true; } public static void addFacade(ItemStack itemStack) { - ItemStack facade = getStack(itemStack.itemID, itemStack.getItemDamage()); + ItemStack facade = getStack(Block.getBlockFromItem(itemStack.getItem()), itemStack.getItemDamage()); allFacades.add(facade); ItemStack facade6 = facade.copy(); @@ -161,19 +186,24 @@ public class ItemFacade extends ItemBuildCraft { // 3 Structurepipes + this block makes 6 facades BuildcraftRecipes.assemblyTable.addRecipe(8000, facade6, new ItemStack(BuildCraftTransport.pipeStructureCobblestone, 3), itemStack); - if (itemStack.itemID < Block.blocksList.length && Block.blocksList[itemStack.itemID] != null) { - Block bl = Block.blocksList[itemStack.itemID]; + + Block bl = Block.getBlockFromItem(itemStack.getItem()); - // Special handling for logs - if (bl.getRenderType() == 31) { - ItemStack rotLog1 = getStack(itemStack.itemID, itemStack.getItemDamage() | 4); - ItemStack rotLog2 = getStack(itemStack.itemID, itemStack.getItemDamage() | 8); - allFacades.add(rotLog1); - allFacades.add(rotLog2); - } - } + // Special handling for logs + if (bl != null && bl.getRenderType() == 31) { + ItemStack rotLog1 = getStack( + Block.getBlockFromItem(itemStack.getItem()), + itemStack.getItemDamage() | 4); + ItemStack rotLog2 = getStack( + Block.getBlockFromItem(itemStack.getItem()), + itemStack.getItemDamage() | 8); + allFacades.add(rotLog1); + allFacades.add(rotLog2); + } } - private static final ItemStack NO_MATCH = new ItemStack(0, 0, 0); + + private static final Block NULL_BLOCK = null; + private static final ItemStack NO_MATCH = new ItemStack(NULL_BLOCK, 0, 0); public class FacadeRecipe implements IRecipe { @@ -182,15 +212,15 @@ public class ItemFacade extends ItemBuildCraft { ItemStack slotmatch = null; for (int i = 0; i < inventorycrafting.getSizeInventory(); i++) { ItemStack slot = inventorycrafting.getStackInSlot(i); - if (slot != null && slot.itemID == ItemFacade.this.itemID && slotmatch == null) { + if (slot != null && slot.getItem() == ItemFacade.this && slotmatch == null) { slotmatch = slot; } else if (slot != null) { slotmatch = NO_MATCH; } } if (slotmatch != null && slotmatch != NO_MATCH) { - int blockId = ItemFacade.getBlockId(slotmatch); - return blockId < Block.blocksList.length && Block.blocksList[blockId] != null && Block.blocksList[blockId].getRenderType() == 31; + Block block = ItemFacade.getBlock(slotmatch); + return block != null && block.getRenderType() == 31; } return false; @@ -201,27 +231,25 @@ public class ItemFacade extends ItemBuildCraft { ItemStack slotmatch = null; for (int i = 0; i < inventorycrafting.getSizeInventory(); i++) { ItemStack slot = inventorycrafting.getStackInSlot(i); - if (slot != null && slot.itemID == ItemFacade.this.itemID && slotmatch == null) { + if (slot != null && slot.getItem() == ItemFacade.this && slotmatch == null) { slotmatch = slot; } else if (slot != null) { slotmatch = NO_MATCH; } } if (slotmatch != null && slotmatch != NO_MATCH) { - int blockId = ItemFacade.getBlockId(slotmatch); + Block block = ItemFacade.getBlock(slotmatch); int blockMeta = ItemFacade.getMetaData(slotmatch); - if (blockId >= Block.blocksList.length) - return null; - Block bl = Block.blocksList[blockId]; - // No Meta - if (bl != null && bl.getRenderType() == 31 && (blockMeta & 0xC) == 0) - return getStack(bl, (blockMeta & 0x3) | 4); + + + if (block != null && block.getRenderType() == 31 && (blockMeta & 0xC) == 0) + return getStack(block, (blockMeta & 0x3) | 4); // Meta | 4 = true - if (bl != null && bl.getRenderType() == 31 && (blockMeta & 0x8) == 0) - return getStack(bl, (blockMeta & 0x3) | 8); + if (block != null && block.getRenderType() == 31 && (blockMeta & 0x8) == 0) + return getStack(block, (blockMeta & 0x3) | 8); // Meta | 8 = true - if (bl != null && bl.getRenderType() == 31 && (blockMeta & 0x4) == 0) - return getStack(bl, (blockMeta & 0x3)); + if (block != null && block.getRenderType() == 31 && (blockMeta & 0x4) == 0) + return getStack(block, (blockMeta & 0x3)); } return null; } @@ -239,7 +267,7 @@ public class ItemFacade extends ItemBuildCraft { @Override @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister par1IconRegister) { + public void registerIcons(IIconRegister par1IconRegister) { // NOOP } @@ -250,14 +278,10 @@ public class ItemFacade extends ItemBuildCraft { } public static ItemStack getStack(Block block, int metadata) { - return getStack(block.blockID, metadata); - } - - public static ItemStack getStack(int blockID, int metadata) { ItemStack stack = new ItemStack(BuildCraftTransport.facadeItem, 1, 0); - NBTTagCompound nbt = new NBTTagCompound("tag"); - nbt.setInteger("meta", metadata); - nbt.setInteger("id", blockID); + NBTTagCompound nbt = new NBTTagCompound(); + nbt.setInteger("meta", metadata); + nbt.setInteger("id", Block.blockRegistry.getIDForObject(block)); stack.setTagCompound(nbt); return stack; } diff --git a/common/buildcraft/transport/ItemPipe.java b/common/buildcraft/transport/ItemPipe.java index 13893649..2873971d 100644 --- a/common/buildcraft/transport/ItemPipe.java +++ b/common/buildcraft/transport/ItemPipe.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.transport; @@ -14,13 +15,16 @@ import buildcraft.core.ItemBuildCraft; import buildcraft.core.utils.BCLog; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; + import java.util.List; import java.util.logging.Level; + import net.minecraft.block.Block; -import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; -import net.minecraft.util.Icon; +import net.minecraft.util.IIcon; import net.minecraft.world.World; public class ItemPipe extends ItemBuildCraft implements IItemPipe { @@ -29,21 +33,20 @@ public class ItemPipe extends ItemBuildCraft implements IItemPipe { private IIconProvider iconProvider; private int pipeIconIndex; - protected ItemPipe(int i) { - super(i); + protected ItemPipe() { + super(); } @Override public boolean onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int side, float par8, float par9, float par10) { - int blockID = BuildCraftTransport.genericPipeBlock.blockID; Block block = BuildCraftTransport.genericPipeBlock; - int id = world.getBlockId(i, j, k); + Block worldBlock = world.getBlock(i, j, k); - if (id == Block.snow.blockID) { + if (worldBlock == Blocks.snow) { side = 1; - } else if (id != Block.vine.blockID && id != Block.tallGrass.blockID && id != Block.deadBush.blockID - && (Block.blocksList[id] == null || !Block.blocksList[id].isBlockReplaceable(world, i, j, k))) { + } else if (worldBlock != Blocks.vine && worldBlock != Blocks.tallgrass && worldBlock != Blocks.deadbush + && (worldBlock == null || !worldBlock.isReplaceable(world, i, j, k))) { if (side == 0) { j--; } @@ -64,27 +67,34 @@ public class ItemPipe extends ItemBuildCraft implements IItemPipe { } } - if (itemstack.stackSize == 0) + if (itemstack.stackSize == 0) { return false; - if (world.canPlaceEntityOnSide(blockID, i, j, k, false, side, entityplayer, itemstack)) { - - Pipe pipe = BlockGenericPipe.createPipe(itemID); + } + + if (world.canPlaceEntityOnSide(block, i, j, k, false, side, entityplayer, itemstack)) { + Pipe pipe = BlockGenericPipe.createPipe(this); + if (pipe == null) { BCLog.logger.log(Level.WARNING, "Pipe failed to create during placement at {0},{1},{2}", new Object[]{i, j, k}); return true; } - if (BlockGenericPipe.placePipe(pipe, world, i, j, k, blockID, 0)) { - - Block.blocksList[blockID].onBlockPlacedBy(world, i, j, k, entityplayer, itemstack); - world.playSoundEffect(i + 0.5F, j + 0.5F, k + 0.5F, - block.stepSound.getPlaceSound(), - (block.stepSound.getVolume() + 1.0F) / 2.0F, - block.stepSound.getPitch() * 0.8F); + + if (BlockGenericPipe.placePipe(pipe, world, i, j, k, block, 0)) { + block.onBlockPlacedBy(world, i, j, k, entityplayer, itemstack); + + // TODO: Fix sound + //world.playSoundEffect(i + 0.5F, j + 0.5F, k + 0.5F, + // block.stepSound.getPlaceSound(), + // (block.stepSound.getVolume() + 1.0F) / 2.0F, + // block.stepSound.getPitch() * 0.8F); + itemstack.stackSize--; } + return true; - } else + } else { return false; + } } @SideOnly(Side.CLIENT) @@ -98,7 +108,7 @@ public class ItemPipe extends ItemBuildCraft implements IItemPipe { @Override @SideOnly(Side.CLIENT) - public Icon getIconFromDamage(int par1) { + public IIcon getIconFromDamage(int par1) { if (iconProvider != null) { // invalid pipes won't have this set return iconProvider.getIcon(pipeIconIndex); } else { @@ -108,7 +118,7 @@ public class ItemPipe extends ItemBuildCraft implements IItemPipe { @Override @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister par1IconRegister) { + public void registerIcons(IIconRegister par1IconRegister) { // NOOP } @@ -122,7 +132,7 @@ public class ItemPipe extends ItemBuildCraft implements IItemPipe { @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean advanced) { super.addInformation(stack, player, list, advanced); - Class pipe = BlockGenericPipe.pipes.get(itemID); + Class pipe = BlockGenericPipe.pipes.get(this); List toolTip = PipeToolTipManager.getToolTip(pipe); list.addAll(toolTip); } diff --git a/common/buildcraft/transport/ItemPipeWire.java b/common/buildcraft/transport/ItemPipeWire.java index ef4dd284..1b75061d 100644 --- a/common/buildcraft/transport/ItemPipeWire.java +++ b/common/buildcraft/transport/ItemPipeWire.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.transport; import buildcraft.api.transport.PipeWire; @@ -6,18 +14,21 @@ import buildcraft.silicon.ItemRedstoneChipset.Chipset; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; + import java.util.List; -import net.minecraft.client.renderer.texture.IconRegister; + +import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.util.Icon; +import net.minecraft.util.IIcon; public class ItemPipeWire extends ItemBuildCraft { - private Icon[] icons; + private IIcon[] icons; - public ItemPipeWire(int i) { - super(i); + public ItemPipeWire() { + super(); setHasSubtypes(true); setMaxDamage(0); setPassSneakClick(true); @@ -25,7 +36,7 @@ public class ItemPipeWire extends ItemBuildCraft { } @Override - public Icon getIconFromDamage(int damage) { + public IIcon getIconFromDamage(int damage) { return icons[damage]; } @@ -37,7 +48,7 @@ public class ItemPipeWire extends ItemBuildCraft { @SuppressWarnings({"rawtypes", "unchecked"}) @Override @SideOnly(Side.CLIENT) - public void getSubItems(int id, CreativeTabs tab, List itemList) { + public void getSubItems(Item item, CreativeTabs tab, List itemList) { for (PipeWire pipeWire : PipeWire.VALUES) { itemList.add(pipeWire.getStack()); } @@ -45,8 +56,8 @@ public class ItemPipeWire extends ItemBuildCraft { @Override @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister par1IconRegister) { - icons = new Icon[PipeWire.VALUES.length]; + public void registerIcons(IIconRegister par1IconRegister) { + icons = new IIcon[PipeWire.VALUES.length]; for (PipeWire pipeWire : PipeWire.VALUES) { icons[pipeWire.ordinal()] = par1IconRegister.registerIcon("buildcraft:" + pipeWire.getTag()); } diff --git a/common/buildcraft/transport/ItemPlug.java b/common/buildcraft/transport/ItemPlug.java index 94b5fcbf..d10778c8 100644 --- a/common/buildcraft/transport/ItemPlug.java +++ b/common/buildcraft/transport/ItemPlug.java @@ -1,16 +1,25 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.transport; import buildcraft.core.ItemBuildCraft; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.world.World; public class ItemPlug extends ItemBuildCraft { - public ItemPlug(int i) { - super(i); + public ItemPlug() { + super(); } @Override @@ -22,7 +31,7 @@ public class ItemPlug extends ItemBuildCraft { // public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World worldObj, int x, int y, int z, int side, float hitX, float hitY, float hitZ) { // if (worldObj.isRemote) // return false; -// TileEntity tile = worldObj.getBlockTileEntity(x, y, z); +// TileEntity tile = worldObj.getTileEntity(x, y, z); // if (!(tile instanceof TileGenericPipe)) // return false; // TileGenericPipe pipeTile = (TileGenericPipe) tile; @@ -44,13 +53,13 @@ public class ItemPlug extends ItemBuildCraft { // } @Override - public boolean shouldPassSneakingClickToBlock(World worldObj, int x, int y, int z ) { + public boolean doesSneakBypassUse(World world, int x, int y, int z, EntityPlayer player) { return true; } @Override @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister par1IconRegister) + public void registerIcons(IIconRegister par1IconRegister) { // NOOP } diff --git a/common/buildcraft/transport/ItemRobotStation.java b/common/buildcraft/transport/ItemRobotStation.java index 9091e628..e4ed02d1 100755 --- a/common/buildcraft/transport/ItemRobotStation.java +++ b/common/buildcraft/transport/ItemRobotStation.java @@ -8,17 +8,18 @@ */ package buildcraft.transport; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; import buildcraft.core.ItemBuildCraft; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.client.renderer.texture.IconRegister; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; public class ItemRobotStation extends ItemBuildCraft { - public ItemRobotStation(int i) { - super(i); + public ItemRobotStation() { + super(); } @Override @@ -27,13 +28,13 @@ public class ItemRobotStation extends ItemBuildCraft { } @Override - public boolean shouldPassSneakingClickToBlock(World worldObj, int x, int y, int z ) { + public boolean doesSneakBypassUse(World world, int x, int y, int z, EntityPlayer player) { return true; } @Override @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister par1IconRegister) { + public void registerIcons(IIconRegister par1IconRegister) { // NOOP } diff --git a/common/buildcraft/transport/Pipe.java b/common/buildcraft/transport/Pipe.java index e17ca036..544db445 100644 --- a/common/buildcraft/transport/Pipe.java +++ b/common/buildcraft/transport/Pipe.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.transport; @@ -21,26 +22,29 @@ import buildcraft.transport.gates.GateFactory; import buildcraft.transport.pipes.events.PipeEvent; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; + import java.lang.reflect.Method; import java.util.HashMap; import java.util.LinkedList; import java.util.Map; import java.util.Random; + import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; public abstract class Pipe implements IDropControlInventory { public int[] signalStrength = new int[]{0, 0, 0, 0}; public TileGenericPipe container; public final T transport; - public final int itemID; + public final Item item; private boolean internalUpdateScheduled = false; public boolean[] wireSet = new boolean[]{false, false, false, false}; public Gate gate; @@ -49,9 +53,9 @@ public abstract class Pipe implements IDropControlInven public SafeTimeTracker actionTracker = new SafeTimeTracker(); private static Map, Map, EventHandler>> eventHandlers = new HashMap, Map, EventHandler>>(); - public Pipe(T transport, int itemID) { + public Pipe(T transport, Item item) { this.transport = transport; - this.itemID = itemID; + this.item = item; if (!networkWrappers.containsKey(this.getClass())) { networkWrappers @@ -183,7 +187,7 @@ public abstract class Pipe implements IDropControlInven // Update the gate if we have any if (gate != null) { - if (container.worldObj.isRemote) { + if (container.getWorldObj().isRemote) { // on client, only update the graphical pulse if needed gate.updatePulse(); } else { @@ -310,7 +314,7 @@ public abstract class Pipe implements IDropControlInven } private boolean receiveSignal(int signal, PipeWire color) { - if (container.worldObj == null) + if (container.getWorldObj() == null) return false; int oldSignal = signalStrength[color.ordinal()]; @@ -418,12 +422,12 @@ public abstract class Pipe implements IDropControlInven } protected void notifyBlocksOfNeighborChange(ForgeDirection side) { - container.worldObj.notifyBlocksOfNeighborChange(container.xCoord + side.offsetX, container.yCoord + side.offsetY, container.zCoord + side.offsetZ, BuildCraftTransport.genericPipeBlock.blockID); + container.getWorldObj().notifyBlocksOfNeighborChange(container.xCoord + side.offsetX, container.yCoord + side.offsetY, container.zCoord + side.offsetZ, BuildCraftTransport.genericPipeBlock); } protected void updateNeighbors(boolean needSelf) { if (needSelf) { - container.worldObj.notifyBlocksOfNeighborChange(container.xCoord, container.yCoord, container.zCoord, BuildCraftTransport.genericPipeBlock.blockID); + container.getWorldObj().notifyBlocksOfNeighborChange(container.xCoord, container.yCoord, container.zCoord, BuildCraftTransport.genericPipeBlock); } for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { notifyBlocksOfNeighborChange(side); @@ -431,7 +435,7 @@ public abstract class Pipe implements IDropControlInven } public void dropItem(ItemStack stack) { - InvUtils.dropItems(container.worldObj, stack, container.xCoord, container.yCoord, container.zCoord); + InvUtils.dropItems(container.getWorldObj(), stack, container.xCoord, container.yCoord, container.zCoord); } public void onBlockRemoval() { @@ -555,6 +559,6 @@ public abstract class Pipe implements IDropControlInven } public World getWorld() { - return container.worldObj; + return container.getWorldObj(); } } diff --git a/common/buildcraft/transport/PipeConnectionBans.java b/common/buildcraft/transport/PipeConnectionBans.java index 12e2db23..53bf43ab 100644 --- a/common/buildcraft/transport/PipeConnectionBans.java +++ b/common/buildcraft/transport/PipeConnectionBans.java @@ -1,7 +1,7 @@ -/* - * Copyright (c) SpaceToad, 2011-2012 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * + * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt @@ -23,8 +23,6 @@ import com.google.common.collect.SetMultimap; /** * Controls whether one type of pipe can connect to another. - * - * @author CovertJaguar */ public class PipeConnectionBans { diff --git a/common/buildcraft/transport/PipeIconProvider.java b/common/buildcraft/transport/PipeIconProvider.java index 8d2b36e6..dca0efd1 100644 --- a/common/buildcraft/transport/PipeIconProvider.java +++ b/common/buildcraft/transport/PipeIconProvider.java @@ -1,7 +1,15 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.transport; -import net.minecraft.client.renderer.texture.IconRegister; -import net.minecraft.util.Icon; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.util.IIcon; import buildcraft.BuildCraftCore; import buildcraft.api.core.IIconProvider; import cpw.mods.fml.relauncher.Side; @@ -123,7 +131,7 @@ public class PipeIconProvider implements IIconProvider { public static final TYPE[] VALUES = values(); private final String iconTag; private final String iconTagColorBlind; - private Icon icon; + private IIcon icon; private TYPE(String iconTag, String IconTagColorBlind) { this.iconTag = iconTag; @@ -134,18 +142,18 @@ public class PipeIconProvider implements IIconProvider { this(iconTag, iconTag); } - private void registerIcon(IconRegister iconRegister) { + private void registerIcon(IIconRegister iconRegister) { icon = iconRegister.registerIcon("buildcraft:" + (BuildCraftCore.colorBlindMode ? iconTagColorBlind : iconTag)); } - public Icon getIcon() { + public IIcon getIcon() { return icon; } } @Override @SideOnly(Side.CLIENT) - public Icon getIcon(int pipeIconIndex) { + public IIcon getIcon(int pipeIconIndex) { if (pipeIconIndex == -1) return null; return TYPE.VALUES[pipeIconIndex].icon; @@ -153,7 +161,7 @@ public class PipeIconProvider implements IIconProvider { @Override @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister iconRegister) { + public void registerIcons(IIconRegister iconRegister) { for (TYPE type : TYPE.VALUES) { type.registerIcon(iconRegister); } diff --git a/common/buildcraft/transport/PipeRenderState.java b/common/buildcraft/transport/PipeRenderState.java index 4118747e..d1dd97a6 100644 --- a/common/buildcraft/transport/PipeRenderState.java +++ b/common/buildcraft/transport/PipeRenderState.java @@ -1,5 +1,15 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.transport; +import io.netty.buffer.ByteBuf; +import net.minecraft.util.IIcon; import buildcraft.core.network.IClientState; import buildcraft.transport.utils.ConnectionMatrix; import buildcraft.transport.utils.FacadeMatrix; @@ -7,10 +17,6 @@ import buildcraft.transport.utils.TextureMatrix; import buildcraft.transport.utils.WireMatrix; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; -import net.minecraft.util.Icon; public class PipeRenderState implements IClientState { @@ -29,9 +35,9 @@ public class PipeRenderState implements IClientState { * This is a placeholder for the pipe renderer to set to a value that the BlockGenericPipe->TileGenericPipe will then return the the WorldRenderer */ @SideOnly(Side.CLIENT) - public Icon currentTexture; + public IIcon currentTexture; @SideOnly(Side.CLIENT) - public Icon[] textureArray; + public IIcon[] textureArray; public void setIsGateLit(boolean value) { if (isGateLit != value) { @@ -79,7 +85,7 @@ public class PipeRenderState implements IClientState { } @Override - public void writeData(DataOutputStream data) throws IOException { + public void writeData(ByteBuf data) { data.writeBoolean(isGateLit); data.writeBoolean(isGatePulsing); data.writeInt(gateIconIndex); @@ -92,7 +98,7 @@ public class PipeRenderState implements IClientState { } @Override - public void readData(DataInputStream data) throws IOException { + public void readData(ByteBuf data) { isGateLit = data.readBoolean(); isGatePulsing = data.readBoolean(); gateIconIndex = data.readInt(); diff --git a/common/buildcraft/transport/PipeToolTipManager.java b/common/buildcraft/transport/PipeToolTipManager.java index f7c22df1..2ec6e3e1 100644 --- a/common/buildcraft/transport/PipeToolTipManager.java +++ b/common/buildcraft/transport/PipeToolTipManager.java @@ -1,7 +1,7 @@ -/* - * Copyright (c) SpaceToad, 2011-2012 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * + * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt @@ -17,10 +17,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -/** - * - * @author CovertJaguar - */ @SideOnly(Side.CLIENT) public class PipeToolTipManager { diff --git a/common/buildcraft/transport/PipeTransport.java b/common/buildcraft/transport/PipeTransport.java index fc0a7ca7..5fa3c1a1 100644 --- a/common/buildcraft/transport/PipeTransport.java +++ b/common/buildcraft/transport/PipeTransport.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.transport; @@ -11,7 +12,7 @@ import buildcraft.api.transport.IPipeTile.PipeType; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; public abstract class PipeTransport { @@ -20,7 +21,7 @@ public abstract class PipeTransport { public abstract PipeType getPipeType(); public World getWorld() { - return container.worldObj; + return container.getWorldObj(); } public void readFromNBT(NBTTagCompound nbttagcompound) { diff --git a/common/buildcraft/transport/PipeTransportFluids.java b/common/buildcraft/transport/PipeTransportFluids.java index ba8312a3..5fd79865 100644 --- a/common/buildcraft/transport/PipeTransportFluids.java +++ b/common/buildcraft/transport/PipeTransportFluids.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.transport; @@ -11,7 +12,7 @@ import java.util.BitSet; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidStack; @@ -19,6 +20,7 @@ import net.minecraftforge.fluids.FluidTank; import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidHandler; import buildcraft.BuildCraftCore; +import buildcraft.BuildCraftTransport; import buildcraft.api.core.SafeTimeTracker; import buildcraft.api.gates.ITrigger; import buildcraft.api.transport.IPipeTile.PipeType; @@ -187,12 +189,13 @@ public class PipeTransportFluids extends PipeTransport implements IFluidHandler @Override public void updateEntity() { - if (CoreProxy.proxy.isRenderWorld(container.worldObj)) + if (container.getWorldObj().isRemote) { return; + } moveFluids(); - if (tracker.markTimeIfDelay(container.worldObj, BuildCraftCore.updateFactor)) { + if (tracker.markTimeIfDelay(container.getWorldObj(), BuildCraftCore.updateFactor)) { boolean init = false; if (++clientSyncCounter > BuildCraftCore.longUpdateFactor) { @@ -201,7 +204,7 @@ public class PipeTransportFluids extends PipeTransport implements IFluidHandler } PacketFluidUpdate packet = computeFluidUpdate(init, true); if (packet != null) { - CoreProxy.proxy.sendToPlayers(packet.getPacket(), container.worldObj, container.xCoord, container.yCoord, container.zCoord, DefaultProps.PIPE_CONTENTS_RENDER_DIST); + BuildCraftTransport.instance.sendToPlayers(packet, container.getWorldObj(), container.xCoord, container.yCoord, container.zCoord, DefaultProps.PIPE_CONTENTS_RENDER_DIST); } } } @@ -332,7 +335,7 @@ public class PipeTransportFluids extends PipeTransport implements IFluidHandler } private void moveFluids() { - short newTimeSlot = (short) (container.worldObj.getTotalWorldTime() % travelDelay); + short newTimeSlot = (short) (container.getWorldObj().getTotalWorldTime() % travelDelay); short outputCount = computeCurrentConnectionStatesAndTickFlows(newTimeSlot); moveFromPipe(outputCount); @@ -357,7 +360,7 @@ public class PipeTransportFluids extends PipeTransport implements IFluidHandler if (filled <= 0) { outputTTL[o.ordinal()]--; } -// else FluidEvent.fireEvent(new FluidMotionEvent(liquidToPush, container.worldObj, container.xCoord, container.yCoord, container.zCoord)); +// else FluidEvent.fireEvent(new FluidMotionEvent(liquidToPush, container.getWorldObj(), container.xCoord, container.yCoord, container.zCoord)); } } } @@ -387,7 +390,7 @@ public class PipeTransportFluids extends PipeTransport implements IFluidHandler int filled = internalTanks[direction.ordinal()].fill(liquidToPush, true); internalTanks[ForgeDirection.UNKNOWN.ordinal()].drain(filled, true); // if (filled > 0) -// FluidEvent.fireEvent(new FluidMotionEvent(liquidToPush, container.worldObj, container.xCoord, container.yCoord, container.zCoord)); +// FluidEvent.fireEvent(new FluidMotionEvent(liquidToPush, container.getWorldObj(), container.xCoord, container.yCoord, container.zCoord)); } } } @@ -432,7 +435,7 @@ public class PipeTransportFluids extends PipeTransport implements IFluidHandler int filled = internalTanks[ForgeDirection.UNKNOWN.ordinal()].fill(liquidToPush, true); internalTanks[dir.ordinal()].drain(filled, true); // if (filled > 0) -// FluidEvent.fireEvent(new FluidMotionEvent(liquidToPush, container.worldObj, container.xCoord, container.yCoord, container.zCoord)); +// FluidEvent.fireEvent(new FluidMotionEvent(liquidToPush, container.getWorldObj(), container.xCoord, container.yCoord, container.zCoord)); } } } diff --git a/common/buildcraft/transport/PipeTransportItems.java b/common/buildcraft/transport/PipeTransportItems.java index bdaee203..53f5f564 100644 --- a/common/buildcraft/transport/PipeTransportItems.java +++ b/common/buildcraft/transport/PipeTransportItems.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.transport; @@ -15,26 +16,29 @@ import buildcraft.api.transport.IPipeTile.PipeType; import buildcraft.core.DefaultProps; import buildcraft.core.IMachine; import buildcraft.core.inventory.Transactor; +import buildcraft.core.proxy.CoreProxy; import buildcraft.core.utils.BCLog; import buildcraft.core.utils.BlockUtil; import buildcraft.core.utils.MathUtils; +import buildcraft.core.utils.Utils; import buildcraft.transport.network.PacketPipeTransportItemStackRequest; import buildcraft.transport.network.PacketPipeTransportTraveler; import buildcraft.transport.pipes.events.PipeEventItem; import buildcraft.transport.utils.TransportUtils; -import cpw.mods.fml.common.network.PacketDispatcher; + import java.util.Collections; import java.util.EnumSet; import java.util.LinkedList; import java.util.List; import java.util.logging.Level; + import net.minecraft.inventory.IInventory; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; public class PipeTransportItems extends PipeTransport { @@ -100,7 +104,7 @@ public class PipeTransportItems extends PipeTransport { readjustPosition(item); - if (!container.worldObj.isRemote) { + if (!container.getWorldObj().isRemote) { item.output = resolveDestination(item); } @@ -115,7 +119,7 @@ public class PipeTransportItems extends PipeTransport { items.add(item); - if (!container.worldObj.isRemote) { + if (!container.getWorldObj().isRemote) { sendTravelerPacket(item, false); if (items.size() > BuildCraftTransport.groupItemsTrigger) @@ -142,8 +146,8 @@ public class PipeTransportItems extends PipeTransport { } private void destroyPipe() { - BlockUtil.explodeBlock(container.worldObj, container.xCoord, container.yCoord, container.zCoord); - container.worldObj.setBlockToAir(container.xCoord, container.yCoord, container.zCoord); + BlockUtil.explodeBlock(container.getWorldObj(), container.xCoord, container.yCoord, container.zCoord); + container.getWorldObj().setBlockToAir(container.xCoord, container.yCoord, container.zCoord); } /** @@ -163,7 +167,7 @@ public class PipeTransportItems extends PipeTransport { readjustSpeed(item); readjustPosition(item); - if (!container.worldObj.isRemote) { + if (!container.getWorldObj().isRemote) { item.output = resolveDestination(item); } @@ -177,7 +181,7 @@ public class PipeTransportItems extends PipeTransport { items.unscheduleRemoval(item); - if (!container.worldObj.isRemote) + if (!container.getWorldObj().isRemote) sendTravelerPacket(item, true); } @@ -250,7 +254,7 @@ public class PipeTransportItems extends PipeTransport { private void moveSolids() { items.flush(); - if (!container.worldObj.isRemote) + if (!container.getWorldObj().isRemote) items.purgeCorruptedItems(); items.iterating = true; @@ -319,7 +323,7 @@ public class PipeTransportItems extends PipeTransport { if (passToNextPipe(item, tile)) { // NOOP } else if (tile instanceof IInventory) { - if (!container.worldObj.isRemote) { + if (!container.getWorldObj().isRemote) { if (item.getInsertionHandler().canInsertItem(item, (IInventory) tile)) { ItemStack added = Transactor.getTransactorFor(tile).add(item.getItemStack(), item.output.getOpposite(), true); item.getItemStack().stackSize -= added.stackSize; @@ -334,7 +338,7 @@ public class PipeTransportItems extends PipeTransport { } private void dropItem(TravelingItem item) { - if (container.worldObj.isRemote) + if (container.getWorldObj().isRemote) return; if (travelHook != null) { @@ -345,7 +349,7 @@ public class PipeTransportItems extends PipeTransport { container.pipe.handlePipeEvent(event); if (event.entity == null) return; - container.worldObj.spawnEntityInWorld(event.entity); + container.getWorldObj().spawnEntityInWorld(event.entity); } protected boolean middleReached(TravelingItem item) { @@ -370,11 +374,11 @@ public class PipeTransportItems extends PipeTransport { public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); - NBTTagList nbttaglist = nbt.getTagList("travelingEntities"); + NBTTagList nbttaglist = nbt.getTagList("travelingEntities", Utils.NBTTag_Types.NBTTagCompound.ordinal()); for (int j = 0; j < nbttaglist.tagCount(); ++j) { try { - NBTTagCompound dataTag = (NBTTagCompound) nbttaglist.tagAt(j); + NBTTagCompound dataTag = nbttaglist.getCompoundTagAt(j); TravelingItem item = TravelingItem.make(dataTag); @@ -414,15 +418,17 @@ public class PipeTransportItems extends PipeTransport { */ public void handleTravelerPacket(PacketPipeTransportTraveler packet) { TravelingItem item = TravelingItem.clientCache.get(packet.getTravelingEntityId()); + if (item == null) { item = TravelingItem.make(packet.getTravelingEntityId()); } - if (item.getContainer() != container) + if (item.getContainer() != container) { items.add(item); + } if (packet.forceStackRefresh() || item.getItemStack() == null) { - PacketDispatcher.sendPacketToServer(new PacketPipeTransportItemStackRequest(packet.getTravelingEntityId()).getPacket()); + BuildCraftTransport.instance.sendToServer(new PacketPipeTransportItemStackRequest(packet.getTravelingEntityId())); } item.setPosition(packet.getItemX(), packet.getItemY(), packet.getItemZ()); @@ -438,8 +444,7 @@ public class PipeTransportItems extends PipeTransport { private void sendTravelerPacket(TravelingItem data, boolean forceStackRefresh) { PacketPipeTransportTraveler packet = new PacketPipeTransportTraveler(data, forceStackRefresh); - int dimension = container.worldObj.provider.dimensionId; - PacketDispatcher.sendPacketToAllAround(container.xCoord, container.yCoord, container.zCoord, DefaultProps.PIPE_CONTENTS_RENDER_DIST, dimension, packet.getPacket()); + BuildCraftTransport.instance.sendToPlayers(packet, container.getWorldObj(), container.xCoord, container.yCoord, container.zCoord, DefaultProps.PIPE_CONTENTS_RENDER_DIST); } public int getNumberOfStacks() { diff --git a/common/buildcraft/transport/PipeTransportPower.java b/common/buildcraft/transport/PipeTransportPower.java index 4c52e4bf..c14811f7 100644 --- a/common/buildcraft/transport/PipeTransportPower.java +++ b/common/buildcraft/transport/PipeTransportPower.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.transport; @@ -14,8 +15,9 @@ import java.util.Map; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; import buildcraft.BuildCraftCore; +import buildcraft.BuildCraftTransport; import buildcraft.api.core.SafeTimeTracker; import buildcraft.api.gates.ITrigger; import buildcraft.api.power.IPowerEmitter; @@ -25,7 +27,6 @@ import buildcraft.api.power.PowerHandler.Type; import buildcraft.api.transport.IPipeTile.PipeType; import buildcraft.core.DefaultProps; import buildcraft.core.ReflectAPI; -import buildcraft.core.proxy.CoreProxy; import buildcraft.transport.network.PacketPowerUpdate; import buildcraft.transport.pipes.PipePowerCobblestone; import buildcraft.transport.pipes.PipePowerDiamond; @@ -147,7 +148,7 @@ public class PipeTransportPower extends PipeTransport { @Override public void updateEntity() { - if (CoreProxy.proxy.isRenderWorld(container.worldObj)) { + if (container.getWorldObj().isRemote) { // updating movement stage. We're only carrying the movement on half // the things. This is purely for animation purpose. @@ -318,7 +319,7 @@ public class PipeTransportPower extends PipeTransport { } } - if (tracker.markTimeIfDelay(container.worldObj, 2 * BuildCraftCore.updateFactor)) { + if (tracker.markTimeIfDelay(container.getWorldObj(), 2 * BuildCraftCore.updateFactor)) { PacketPowerUpdate packet = new PacketPowerUpdate(container.xCoord, container.yCoord, container.zCoord); double displayFactor = MAX_DISPLAY / 1024.0; @@ -328,7 +329,7 @@ public class PipeTransportPower extends PipeTransport { packet.displayPower = clientDisplayPower; packet.overload = isOverloaded(); - CoreProxy.proxy.sendToPlayers(packet.getPacket(), container.worldObj, container.xCoord, container.yCoord, container.zCoord, DefaultProps.PIPE_CONTENTS_RENDER_DIST); + BuildCraftTransport.instance.sendToPlayers(packet, container.getWorldObj(), container.xCoord, container.yCoord, container.zCoord, DefaultProps.PIPE_CONTENTS_RENDER_DIST); } } @@ -350,8 +351,8 @@ public class PipeTransportPower extends PipeTransport { } private void step() { - if (currentDate != container.worldObj.getTotalWorldTime()) { - currentDate = container.worldObj.getTotalWorldTime(); + if (currentDate != container.getWorldObj().getTotalWorldTime()) { + currentDate = container.getWorldObj().getTotalWorldTime(); powerQuery = nextPowerQuery; nextPowerQuery = new int[6]; @@ -412,7 +413,7 @@ public class PipeTransportPower extends PipeTransport { @Override public void initialize() { - currentDate = container.worldObj.getTotalWorldTime(); + currentDate = container.getWorldObj().getTotalWorldTime(); } @Override diff --git a/common/buildcraft/transport/PipeTransportStructure.java b/common/buildcraft/transport/PipeTransportStructure.java index 6d32fa3d..43810754 100644 --- a/common/buildcraft/transport/PipeTransportStructure.java +++ b/common/buildcraft/transport/PipeTransportStructure.java @@ -1,8 +1,16 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.transport; import buildcraft.api.transport.IPipeTile.PipeType; import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; public class PipeTransportStructure extends PipeTransport { diff --git a/common/buildcraft/transport/PipeTriggerProvider.java b/common/buildcraft/transport/PipeTriggerProvider.java index 42598117..cf6f0a90 100644 --- a/common/buildcraft/transport/PipeTriggerProvider.java +++ b/common/buildcraft/transport/PipeTriggerProvider.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.transport; import buildcraft.api.gates.IOverrideDefaultTriggers; diff --git a/common/buildcraft/transport/TileDummyGenericPipe.java b/common/buildcraft/transport/TileDummyGenericPipe.java index d4f9db2c..0aa4ea2e 100644 --- a/common/buildcraft/transport/TileDummyGenericPipe.java +++ b/common/buildcraft/transport/TileDummyGenericPipe.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.transport; public class TileDummyGenericPipe extends TileGenericPipe { diff --git a/common/buildcraft/transport/TileDummyGenericPipe2.java b/common/buildcraft/transport/TileDummyGenericPipe2.java index e6c344d1..718c6854 100644 --- a/common/buildcraft/transport/TileDummyGenericPipe2.java +++ b/common/buildcraft/transport/TileDummyGenericPipe2.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.transport; public class TileDummyGenericPipe2 extends TileGenericPipe { diff --git a/common/buildcraft/transport/TileFilteredBuffer.java b/common/buildcraft/transport/TileFilteredBuffer.java index 3101a9a4..6e512e9f 100644 --- a/common/buildcraft/transport/TileFilteredBuffer.java +++ b/common/buildcraft/transport/TileFilteredBuffer.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.transport; import buildcraft.core.TileBuildCraft; @@ -50,8 +58,8 @@ public class TileFilteredBuffer extends TileBuildCraft implements IInventory { } @Override - public String getInvName() { - return inventoryStorage.getInvName(); + public String getInventoryName() { + return inventoryStorage.getInventoryName(); } @Override @@ -61,15 +69,15 @@ public class TileFilteredBuffer extends TileBuildCraft implements IInventory { @Override public boolean isUseableByPlayer(EntityPlayer entityPlayer) { - return worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) == this; + return worldObj.getTileEntity(xCoord, yCoord, zCoord) == this; } @Override - public void openChest() { + public void openInventory() { } @Override - public void closeChest() { + public void closeInventory() { } @Override @@ -77,10 +85,10 @@ public class TileFilteredBuffer extends TileBuildCraft implements IInventory { ItemStack filterItemStack = inventoryFilters.getStackInSlot(i); - if ( filterItemStack == null || filterItemStack.itemID != itemstack.itemID) + if ( filterItemStack == null || filterItemStack.getItem() != itemstack.getItem()) return false; - if (Item.itemsList[itemstack.itemID].isDamageable()) + if (itemstack.getItem().isDamageable()) return true; if (filterItemStack.getItemDamage() == itemstack.getItemDamage()) @@ -111,4 +119,9 @@ public class TileFilteredBuffer extends TileBuildCraft implements IInventory { inventoryFilters.writeToNBT(inventoryFiltersTag); nbtTagCompound.setTag("inventoryFilters", inventoryFiltersTag); } + + @Override + public boolean hasCustomInventoryName() { + return false; + } } diff --git a/common/buildcraft/transport/TileGenericPipe.java b/common/buildcraft/transport/TileGenericPipe.java index 04ea969d..44755cff 100644 --- a/common/buildcraft/transport/TileGenericPipe.java +++ b/common/buildcraft/transport/TileGenericPipe.java @@ -8,22 +8,24 @@ */ package buildcraft.transport; -import buildcraft.api.transport.PipeWire; +import io.netty.buffer.ByteBuf; -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; +import java.util.HashSet; import java.util.LinkedList; +import java.util.Set; import java.util.logging.Level; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.network.packet.Packet; +import net.minecraft.network.Packet; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; -import net.minecraftforge.common.ForgeDirection; +import net.minecraft.world.WorldServer; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; @@ -42,27 +44,24 @@ import buildcraft.api.power.PowerHandler; import buildcraft.api.power.PowerHandler.PowerReceiver; import buildcraft.api.transport.IPipeConnection; import buildcraft.api.transport.IPipeTile; +import buildcraft.api.transport.PipeWire; import buildcraft.core.DefaultProps; import buildcraft.core.IDropControlInventory; import buildcraft.core.ITileBufferHolder; import buildcraft.core.TileBuffer; import buildcraft.core.inventory.InvUtils; +import buildcraft.core.network.BuildCraftPacket; import buildcraft.core.network.IClientState; import buildcraft.core.network.IGuiReturnHandler; import buildcraft.core.network.ISyncedTile; import buildcraft.core.network.PacketTileState; import buildcraft.core.utils.BCLog; +import buildcraft.core.utils.Utils; import buildcraft.transport.gates.GateDefinition; import buildcraft.transport.gates.GateFactory; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import java.util.HashSet; -import java.util.Set; - -import net.minecraft.server.management.PlayerInstance; -import net.minecraft.world.WorldServer; - public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFluidHandler, IPipeTile, IOverrideDefaultTriggers, ITileBufferHolder, IDropControlInventory, ISyncedTile, ISolidSideTile, IGuiReturnHandler { @@ -74,7 +73,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui public final Set expansions = new HashSet(); @Override - public void writeData(DataOutputStream data) throws IOException { + public void writeData(ByteBuf data) { data.writeInt(pipeId); data.writeByte(gateMaterial); data.writeByte(gateLogic); @@ -85,7 +84,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui } @Override - public void readData(DataInputStream data) throws IOException { + public void readData(ByteBuf data) { pipeId = data.readInt(); gateMaterial = data.readByte(); gateLogic = data.readByte(); @@ -109,7 +108,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui private boolean pipeBound = false; private boolean resyncGateExpansions = false; public int redstoneInput = 0; - private int[] facadeBlocks = new int[ForgeDirection.VALID_DIRECTIONS.length]; + private Block[] facadeBlocks = new Block[ForgeDirection.VALID_DIRECTIONS.length]; private int[] facadeMeta = new int[ForgeDirection.VALID_DIRECTIONS.length]; private boolean[] plugs = new boolean[ForgeDirection.VALID_DIRECTIONS.length]; private boolean[] robotStations = new boolean[ForgeDirection.VALID_DIRECTIONS.length]; @@ -120,30 +119,37 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui @Override public void writeToNBT(NBTTagCompound nbt) { super.writeToNBT(nbt); + nbt.setByte("redstoneInput", (byte)redstoneInput); if (pipe != null) { - nbt.setInteger("pipeId", pipe.itemID); + nbt.setInteger("pipeId", Item.itemRegistry.getIDForObject(pipe.item)); pipe.writeToNBT(nbt); - } else + } else { nbt.setInteger("pipeId", coreState.pipeId); + } for (int i = 0; i < ForgeDirection.VALID_DIRECTIONS.length; i++) { - nbt.setInteger("facadeBlocks[" + i + "]", facadeBlocks[i]); + if (facadeBlocks[i] == null) { + nbt.setInteger("facadeBlocks[" + i + "]", 0); + } else { + nbt.setInteger("facadeBlocks[" + i + "]", Block.blockRegistry.getIDForObject(facadeBlocks[i])); + } + nbt.setInteger("facadeMeta[" + i + "]", facadeMeta[i]); nbt.setBoolean("plug[" + i + "]", plugs[i]); nbt.setBoolean("robotStation[" + i + "]", robotStations[i]); } - } @Override public void readFromNBT(NBTTagCompound nbt) { super.readFromNBT(nbt); + redstoneInput = nbt.getByte("redstoneInput"); coreState.pipeId = nbt.getInteger("pipeId"); - pipe = BlockGenericPipe.createPipe(coreState.pipeId); + pipe = BlockGenericPipe.createPipe((Item) Item.itemRegistry.getObjectById(coreState.pipeId)); bindPipe(); if (pipe != null) @@ -154,7 +160,14 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui } for (int i = 0; i < ForgeDirection.VALID_DIRECTIONS.length; i++) { - facadeBlocks[i] = nbt.getInteger("facadeBlocks[" + i + "]"); + int blockId = nbt.getInteger("facadeBlocks[" + i + "]"); + + if (blockId != 0) { + facadeBlocks[i] = (Block) Block.blockRegistry.getObjectById(blockId); + } else { + facadeBlocks[i] = null; + } + facadeMeta[i] = nbt.getInteger("facadeMeta[" + i + "]"); plugs[i] = nbt.getBoolean("plug[" + i + "]"); robotStations[i] = nbt.getBoolean("robotStation[" + i + "]"); @@ -185,24 +198,30 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui @Override public void updateEntity() { if (!worldObj.isRemote) { - if (deletePipe) + if (deletePipe) { worldObj.setBlockToAir(xCoord, yCoord, zCoord); + } - if (pipe == null) + if (pipe == null) { return; + } - if (!initialized) + if (!initialized) { initialize(pipe); + } } - if (!BlockGenericPipe.isValid(pipe)) + if (!BlockGenericPipe.isValid(pipe)) { return; + } pipe.updateEntity(); if (worldObj.isRemote) { - if (resyncGateExpansions) + if (resyncGateExpansions) { syncGateExpansions(); + } + return; } @@ -219,16 +238,24 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui } PowerReceiver provider = getPowerReceiver(null); - if (provider != null) + + if (provider != null) { provider.update(); + } if (sendClientUpdate) { sendClientUpdate = false; + if (worldObj instanceof WorldServer) { WorldServer world = (WorldServer) worldObj; - PlayerInstance playerInstance = world.getPlayerManager().getOrCreateChunkWatcher(xCoord >> 4, zCoord >> 4, false); - if (playerInstance != null) { - playerInstance.sendToAllPlayersWatchingChunk(getDescriptionPacket()); + BuildCraftPacket updatePacket = getBCDescriptionPacket(); + + for (Object o : world.playerEntities) { + EntityPlayerMP player = (EntityPlayerMP) o; + + if (world.getPlayerManager().isPlayerWatchingChunk (player, xCoord >> 4, zCoord >> 4)) { + BuildCraftCore.instance.sendToPlayer(player, updatePacket); + } } } } @@ -250,9 +277,11 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui // WireState for (PipeWire color : PipeWire.values()) { renderState.wireMatrix.setWire(color, pipe.wireSet[color.ordinal()]); + for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) { renderState.wireMatrix.setWireConnected(color, direction, pipe.isWireConnectedTo(this.getTile(direction), color)); } + boolean lit = pipe.signalStrength[color.ordinal()] > 0; switch (color) { @@ -280,8 +309,8 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui // Facades for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) { - int blockId = this.facadeBlocks[direction.ordinal()]; - renderState.facadeMatrix.setFacade(direction, blockId, this.facadeMeta[direction.ordinal()]); + Block block = this.facadeBlocks[direction.ordinal()]; + renderState.facadeMatrix.setFacade(direction, block, this.facadeMeta[direction.ordinal()]); } //Plugs @@ -316,7 +345,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui TileEntity tile = getTile(o); if (tile instanceof ITileBufferHolder) - ((ITileBufferHolder) tile).blockCreated(o, BuildCraftTransport.genericPipeBlock.blockID, this); + ((ITileBufferHolder) tile).blockCreated(o, BuildCraftTransport.genericPipeBlock, this); if (tile instanceof TileGenericPipe) ((TileGenericPipe) tile).scheduleNeighborChange(); } @@ -338,7 +367,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui pipe.setTile(this); - coreState.pipeId = pipe.itemID; + coreState.pipeId = Item.getIdFromItem(pipe.item); pipeBound = true; } } @@ -389,12 +418,13 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui } /* SMP */ - @Override - public Packet getDescriptionPacket() { + + public BuildCraftPacket getBCDescriptionPacket() { bindPipe(); PacketTileState packet = new PacketTileState(this.xCoord, this.yCoord, this.zCoord); coreState.expansions.clear(); + if (pipe != null && pipe.gate != null) { coreState.gateMaterial = pipe.gate.material.ordinal(); coreState.gateLogic = pipe.gate.logic.ordinal(); @@ -411,9 +441,17 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui packet.addStateForSerialization((byte) 0, coreState); packet.addStateForSerialization((byte) 1, renderState); - if (pipe instanceof IClientState) + + if (pipe instanceof IClientState) { packet.addStateForSerialization((byte) 2, (IClientState) pipe); - return packet.getPacket(); + } + + return packet; + } + + @Override + public Packet getDescriptionPacket() { + return Utils.toPacket(getBCDescriptionPacket(), 1); } public void sendUpdateToClient() { @@ -434,7 +472,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui @Override public void blockRemoved(ForgeDirection from) { - // TODO Auto-generated method stub + } public TileBuffer[] getTileCache() { @@ -444,19 +482,19 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui } @Override - public void blockCreated(ForgeDirection from, int blockID, TileEntity tile) { + public void blockCreated(ForgeDirection from, Block block, TileEntity tile) { TileBuffer[] cache = getTileCache(); if (cache != null) - cache[from.getOpposite().ordinal()].set(blockID, tile); + cache[from.getOpposite().ordinal()].set(block, tile); } @Override - public int getBlockId(ForgeDirection to) { + public Block getBlock(ForgeDirection to) { TileBuffer[] cache = getTileCache(); if (cache != null) - return cache[to.ordinal()].getBlockID(); + return cache[to.ordinal()].getBlock(); else - return 0; + return null; } @Override @@ -600,28 +638,33 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui refreshRenderState = true; } - public boolean addFacade(ForgeDirection direction, int blockid, int meta) { - if (this.worldObj.isRemote) - return false; - if (this.facadeBlocks[direction.ordinal()] == blockid) + public boolean addFacade(ForgeDirection direction, Block block, int meta) { + if (this.getWorldObj().isRemote) { return false; + } - if (hasFacade(direction)) + if (this.facadeBlocks[direction.ordinal()] == block) { + return false; + } + + if (hasFacade(direction)) { dropFacadeItem(direction); + } - this.facadeBlocks[direction.ordinal()] = blockid; + this.facadeBlocks[direction.ordinal()] = block; this.facadeMeta[direction.ordinal()] = meta; - worldObj.notifyBlockChange(this.xCoord, this.yCoord, this.zCoord, getBlockId()); + worldObj.notifyBlockChange(this.xCoord, this.yCoord, this.zCoord, getBlock()); scheduleRenderUpdate(); + return true; } public boolean hasFacade(ForgeDirection direction) { if (direction == null || direction == ForgeDirection.UNKNOWN) return false; - if (this.worldObj.isRemote) - return renderState.facadeMatrix.getFacadeBlockId(direction) != 0; - return (this.facadeBlocks[direction.ordinal()] != 0); + if (this.getWorldObj().isRemote) + return renderState.facadeMatrix.getFacadeBlock(direction) != null; + return (this.facadeBlocks[direction.ordinal()] != null); } private void dropFacadeItem(ForgeDirection direction) { @@ -633,9 +676,9 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui return false; if (!worldObj.isRemote) { dropFacadeItem(direction); - this.facadeBlocks[direction.ordinal()] = 0; + this.facadeBlocks[direction.ordinal()] = null; this.facadeMeta[direction.ordinal()] = 0; - worldObj.notifyBlockChange(this.xCoord, this.yCoord, this.zCoord, getBlockId()); + worldObj.notifyBlockChange(this.xCoord, this.yCoord, this.zCoord, getBlock()); scheduleRenderUpdate(); } return true; @@ -668,24 +711,28 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui switch (stateId) { case 0: - if (pipe == null && coreState.pipeId != 0) - initialize(BlockGenericPipe.createPipe(coreState.pipeId)); + if (pipe == null && coreState.pipeId != 0) { + initialize(BlockGenericPipe.createPipe((Item) Item.itemRegistry.getObjectById(coreState.pipeId))); + } - if (pipe == null) + if (pipe == null) { break; + } - if (coreState.gateMaterial == -1) + if (coreState.gateMaterial == -1) { pipe.gate = null; - else if (pipe.gate == null) + } else if (pipe.gate == null) { pipe.gate = GateFactory.makeGate(pipe, GateDefinition.GateMaterial.fromOrdinal(coreState.gateMaterial), GateDefinition.GateLogic.fromOrdinal(coreState.gateLogic)); + } syncGateExpansions(); - worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); + worldObj.markBlockRangeForRenderUpdate(xCoord, yCoord, zCoord, xCoord, yCoord, zCoord); break; + case 1: { if (renderState.needsRenderUpdate()) { - worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); + worldObj.markBlockRangeForRenderUpdate(xCoord, yCoord, zCoord, xCoord, yCoord, zCoord); renderState.clean(); } break; @@ -715,8 +762,8 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui } @Override - public boolean shouldRefresh(int oldID, int newID, int oldMeta, int newMeta, World world, int x, int y, int z) { - return oldID != newID; + public boolean shouldRefresh(Block oldBlock, Block newBlock, int oldMeta, int newMeta, World world, int x, int y, int z) { + return oldBlock != newBlock; } @Override @@ -762,7 +809,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui if (!worldObj.isRemote) { plugs[side.ordinal()] = false; InvUtils.dropItems(worldObj, new ItemStack(BuildCraftTransport.plugItem), this.xCoord, this.yCoord, this.zCoord); - worldObj.notifyBlockChange(this.xCoord, this.yCoord, this.zCoord, getBlockId()); + worldObj.notifyBlockChange(this.xCoord, this.yCoord, this.zCoord, getBlock()); scheduleNeighborChange(); //To force recalculation of connections scheduleRenderUpdate(); } @@ -778,7 +825,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui if (!worldObj.isRemote) { robotStations[side.ordinal()] = false; InvUtils.dropItems(worldObj, new ItemStack(BuildCraftTransport.robotStationItem), this.xCoord, this.yCoord, this.zCoord); - worldObj.notifyBlockChange(this.xCoord, this.yCoord, this.zCoord, getBlockId()); + worldObj.notifyBlockChange(this.xCoord, this.yCoord, this.zCoord, getBlock()); scheduleNeighborChange(); //To force recalculation of connections scheduleRenderUpdate(); } @@ -792,7 +839,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui } plugs[forgeDirection.ordinal()] = true; - worldObj.notifyBlockChange(this.xCoord, this.yCoord, this.zCoord, getBlockId()); + worldObj.notifyBlockChange(this.xCoord, this.yCoord, this.zCoord, getBlock()); scheduleNeighborChange(); //To force recalculation of connections scheduleRenderUpdate(); return true; @@ -804,18 +851,15 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui } robotStations[forgeDirection.ordinal()] = true; - worldObj.notifyBlockChange(this.xCoord, this.yCoord, this.zCoord, getBlockId()); + worldObj.notifyBlockChange(this.xCoord, this.yCoord, this.zCoord, getBlock()); scheduleNeighborChange(); //To force recalculation of connections scheduleRenderUpdate(); return true; } - public int getBlockId() { - Block block = getBlockType(); - if (block != null) - return block.blockID; - return 0; + public Block getBlock() { + return getBlockType(); } @Override @@ -824,17 +868,17 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui } public boolean isUseableByPlayer(EntityPlayer player) { - return worldObj.getBlockTileEntity(xCoord, yCoord, zCoord) == this; + return worldObj.getTileEntity(xCoord, yCoord, zCoord) == this; } @Override - public void writeGuiData(DataOutputStream data) throws IOException { + public void writeGuiData(ByteBuf data) { if (BlockGenericPipe.isValid(pipe) && pipe instanceof IGuiReturnHandler) ((IGuiReturnHandler) pipe).writeGuiData(data); } @Override - public void readGuiData(DataInputStream data, EntityPlayer sender) throws IOException { + public void readGuiData(ByteBuf data, EntityPlayer sender) { if (BlockGenericPipe.isValid(pipe) && pipe instanceof IGuiReturnHandler) ((IGuiReturnHandler) pipe).readGuiData(data, sender); } diff --git a/common/buildcraft/transport/TransportConstants.java b/common/buildcraft/transport/TransportConstants.java index e76ef048..c80c3496 100644 --- a/common/buildcraft/transport/TransportConstants.java +++ b/common/buildcraft/transport/TransportConstants.java @@ -1,17 +1,13 @@ -/* - * Copyright (c) SpaceToad, 2011-2012 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * + * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.transport; -/** - * - * @author CovertJaguar - */ public class TransportConstants { public static final float FACADE_THICKNESS = 2F / 16F; diff --git a/common/buildcraft/transport/TransportProxy.java b/common/buildcraft/transport/TransportProxy.java index b27824bf..121ac53d 100644 --- a/common/buildcraft/transport/TransportProxy.java +++ b/common/buildcraft/transport/TransportProxy.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.transport; import buildcraft.BuildCraftTransport; diff --git a/common/buildcraft/transport/TransportProxyClient.java b/common/buildcraft/transport/TransportProxyClient.java index 5577d556..edd6a7d2 100644 --- a/common/buildcraft/transport/TransportProxyClient.java +++ b/common/buildcraft/transport/TransportProxyClient.java @@ -1,16 +1,24 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.transport; +import net.minecraftforge.client.MinecraftForgeClient; import buildcraft.BuildCraftTransport; import buildcraft.transport.render.FacadeItemRenderer; import buildcraft.transport.render.GateItemRenderer; import buildcraft.transport.render.PipeItemRenderer; +import buildcraft.transport.render.PipeRendererTESR; import buildcraft.transport.render.PipeRendererWorld; import buildcraft.transport.render.PlugItemRenderer; -import buildcraft.transport.render.PipeRendererTESR; import buildcraft.transport.render.RobotStationItemRenderer; import cpw.mods.fml.client.registry.ClientRegistry; import cpw.mods.fml.client.registry.RenderingRegistry; -import net.minecraftforge.client.MinecraftForgeClient; public class TransportProxyClient extends TransportProxy { @@ -33,45 +41,47 @@ public class TransportProxyClient extends TransportProxy { @Override public void registerRenderers() { - MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsWood.itemID, pipeItemRenderer); - MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsCobblestone.itemID, pipeItemRenderer); - MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsStone.itemID, pipeItemRenderer); - MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsQuartz.itemID, pipeItemRenderer); - MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsIron.itemID, pipeItemRenderer); - MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsGold.itemID, pipeItemRenderer); - MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsDiamond.itemID, pipeItemRenderer); - MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsObsidian.itemID, pipeItemRenderer); - MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsEmerald.itemID, pipeItemRenderer); - MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsLapis.itemID, pipeItemRenderer); - MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsDaizuli.itemID, pipeItemRenderer); - MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsEmzuli.itemID, pipeItemRenderer); + MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsWood, pipeItemRenderer); + MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsCobblestone, pipeItemRenderer); + MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsStone, pipeItemRenderer); + MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsQuartz, pipeItemRenderer); + MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsIron, pipeItemRenderer); + MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsGold, pipeItemRenderer); + MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsDiamond, pipeItemRenderer); + MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsObsidian, pipeItemRenderer); + MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsEmerald, pipeItemRenderer); + MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsLapis, pipeItemRenderer); + MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsDaizuli, pipeItemRenderer); + MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsEmzuli, pipeItemRenderer); - MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeFluidsWood.itemID, pipeItemRenderer); - MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeFluidsCobblestone.itemID, pipeItemRenderer); - MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeFluidsStone.itemID, pipeItemRenderer); - MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeFluidsIron.itemID, pipeItemRenderer); - MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeFluidsGold.itemID, pipeItemRenderer); - MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeFluidsEmerald.itemID, pipeItemRenderer); + MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeFluidsWood, pipeItemRenderer); + MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeFluidsCobblestone, pipeItemRenderer); + MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeFluidsStone, pipeItemRenderer); + MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeFluidsIron, pipeItemRenderer); + MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeFluidsGold, pipeItemRenderer); + MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeFluidsEmerald, pipeItemRenderer); + + MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipePowerWood, pipeItemRenderer); + MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipePowerCobblestone, pipeItemRenderer); + MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipePowerStone, pipeItemRenderer); + MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipePowerQuartz, pipeItemRenderer); + MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipePowerIron, pipeItemRenderer); + MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipePowerGold, pipeItemRenderer); + MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipePowerDiamond, pipeItemRenderer); + MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipePowerHeat, pipeItemRenderer); + MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeStructureCobblestone, pipeItemRenderer); - MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipePowerWood.itemID, pipeItemRenderer); - MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipePowerCobblestone.itemID, pipeItemRenderer); - MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipePowerStone.itemID, pipeItemRenderer); - MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipePowerQuartz.itemID, pipeItemRenderer); - MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipePowerIron.itemID, pipeItemRenderer); - MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipePowerGold.itemID, pipeItemRenderer); - MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipePowerDiamond.itemID, pipeItemRenderer); - MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipePowerHeat.itemID, pipeItemRenderer); - MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeStructureCobblestone.itemID, pipeItemRenderer); // MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsStipes.shiftedIndex, pipeItemRenderer); - MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsVoid.itemID, pipeItemRenderer); - MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeFluidsVoid.itemID, pipeItemRenderer); - MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsSandstone.itemID, pipeItemRenderer); - MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeFluidsSandstone.itemID, pipeItemRenderer); + MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsVoid, pipeItemRenderer); + MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeFluidsVoid, pipeItemRenderer); + MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeItemsSandstone, pipeItemRenderer); + MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeFluidsSandstone, pipeItemRenderer); + + MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.facadeItem, facadeItemRenderer); + MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.plugItem, plugItemRenderer); + MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.robotStationItem, robotStationItemRenderer); + MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeGate, gateItemRenderer); - MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.facadeItem.itemID, facadeItemRenderer); - MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.plugItem.itemID, plugItemRenderer); - MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.robotStationItem.itemID, robotStationItemRenderer); - MinecraftForgeClient.registerItemRenderer(BuildCraftTransport.pipeGate.itemID, gateItemRenderer); TransportProxy.pipeModel = RenderingRegistry.getNextAvailableRenderId(); RenderingRegistry.registerBlockHandler(pipeWorldRenderer); diff --git a/common/buildcraft/transport/TravelerSet.java b/common/buildcraft/transport/TravelerSet.java index c978a755..d22f5f40 100644 --- a/common/buildcraft/transport/TravelerSet.java +++ b/common/buildcraft/transport/TravelerSet.java @@ -1,7 +1,7 @@ -/* - * Copyright (c) SpaceToad, 2011-2012 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * + * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt @@ -16,10 +16,6 @@ import java.util.HashSet; import java.util.Iterator; import java.util.Set; -/** - * - * @author CovertJaguar - */ public class TravelerSet extends ForwardingSet { private final BiMap items = HashBiMap.create(); diff --git a/common/buildcraft/transport/TravelingItem.java b/common/buildcraft/transport/TravelingItem.java index 85cacf70..95738054 100644 --- a/common/buildcraft/transport/TravelingItem.java +++ b/common/buildcraft/transport/TravelingItem.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.transport; @@ -25,7 +26,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.MathHelper; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; public final class TravelingItem { @@ -179,7 +180,7 @@ public final class TravelingItem { data.setFloat("speed", getSpeed()); NBTTagCompound itemStackTag = new NBTTagCompound(); getItemStack().writeToNBT(itemStackTag); - data.setCompoundTag("Item", itemStackTag); + data.setTag("Item", itemStackTag); data.setBoolean("toCenter", toCenter); data.setInteger("input", input.ordinal()); @@ -192,7 +193,7 @@ public final class TravelingItem { } public EntityItem toEntityItem() { - if (container != null && !CoreProxy.proxy.isRenderWorld(container.worldObj)) { + if (container != null && !container.getWorldObj().isRemote) { if (getItemStack().stackSize <= 0) return null; @@ -200,9 +201,9 @@ public final class TravelingItem { motion.moveForwards(0.1 + getSpeed() * 2F); ItemStack stack = getItemStack(); - EntityItem entity = new EntityItem(container.worldObj, xCoord, yCoord, zCoord, getItemStack()); + EntityItem entity = new EntityItem(container.getWorldObj(), xCoord, yCoord, zCoord, getItemStack()); if (stack.getItem().hasCustomEntity(stack)) { - Entity e = stack.getItem().createEntity(container.worldObj, entity, stack); + Entity e = stack.getItem().createEntity(container.getWorldObj(), entity, stack); if (e instanceof EntityItem) entity = (EntityItem) e; } @@ -210,10 +211,10 @@ public final class TravelingItem { entity.lifespan = BuildCraftCore.itemLifespan; entity.delayBeforeCanPickup = 10; - float f3 = 0.00F + container.worldObj.rand.nextFloat() * 0.04F - 0.02F; - entity.motionX = (float) container.worldObj.rand.nextGaussian() * f3 + motion.x; - entity.motionY = (float) container.worldObj.rand.nextGaussian() * f3 + motion.y; - entity.motionZ = (float) container.worldObj.rand.nextGaussian() * f3 + +motion.z; + float f3 = 0.00F + container.getWorldObj().rand.nextFloat() * 0.04F - 0.02F; + entity.motionX = (float) container.getWorldObj().rand.nextGaussian() * f3 + motion.x; + entity.motionY = (float) container.getWorldObj().rand.nextGaussian() * f3 + motion.y; + entity.motionZ = (float) container.getWorldObj().rand.nextGaussian() * f3 + +motion.z; return entity; } return null; @@ -222,16 +223,16 @@ public final class TravelingItem { public float getEntityBrightness(float f) { int i = MathHelper.floor_double(xCoord); int j = MathHelper.floor_double(zCoord); - if (container != null && container.worldObj.blockExists(i, 128 / 2, j)) { + if (container != null && container.getWorldObj().blockExists(i, 128 / 2, j)) { double d = 0.66000000000000003D; int k = MathHelper.floor_double(yCoord + d); - return container.worldObj.getLightBrightness(i, k, j); + return container.getWorldObj().getLightBrightness(i, k, j); } else return 0.0F; } public boolean isCorrupted() { - return itemStack == null || itemStack.stackSize <= 0 || Item.itemsList[itemStack.itemID] == null; + return itemStack == null || itemStack.stackSize <= 0 || itemStack.getItem() == null; } public boolean canBeGroupedWith(TravelingItem otherItem) { diff --git a/common/buildcraft/transport/WireIconProvider.java b/common/buildcraft/transport/WireIconProvider.java index 9e65ad41..89102a41 100644 --- a/common/buildcraft/transport/WireIconProvider.java +++ b/common/buildcraft/transport/WireIconProvider.java @@ -1,10 +1,18 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.transport; import buildcraft.api.core.IIconProvider; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.client.renderer.texture.IconRegister; -import net.minecraft.util.Icon; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.util.IIcon; public class WireIconProvider implements IIconProvider { @@ -20,18 +28,18 @@ public class WireIconProvider implements IIconProvider { public static final int MAX = 8; @SideOnly(Side.CLIENT) - private Icon[] icons; + private IIcon[] icons; @Override @SideOnly(Side.CLIENT) - public Icon getIcon(int pipeIconIndex) { + public IIcon getIcon(int pipeIconIndex) { return icons[pipeIconIndex]; } @Override @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister iconRegister) { - icons = new Icon[MAX]; + public void registerIcons(IIconRegister iconRegister) { + icons = new IIcon[MAX]; icons[WireIconProvider.Texture_Red_Dark] = iconRegister.registerIcon("buildcraft:texture_red_dark"); icons[WireIconProvider.Texture_Red_Lit] = iconRegister.registerIcon("buildcraft:texture_red_lit"); diff --git a/common/buildcraft/transport/blueprints/BptBlockPipe.java b/common/buildcraft/transport/blueprints/BptBlockPipe.java index 04d315ed..91c51225 100644 --- a/common/buildcraft/transport/blueprints/BptBlockPipe.java +++ b/common/buildcraft/transport/blueprints/BptBlockPipe.java @@ -1,12 +1,11 @@ /** - * Copyright (c) SpaceToad, 2011-2012 + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.transport.blueprints; import buildcraft.BuildCraftCore; @@ -32,7 +31,7 @@ public class BptBlockPipe extends BptBlock { public void addRequirements(BptSlotInfo slot, IBptContext context, LinkedList requirements) { int pipeId = slot.cpt.getInteger("pipeId"); - requirements.add(new ItemStack(pipeId, 1, 0)); + //requirements.add(new ItemStack(pipeId, 1, 0)); // if (slot.cpt.hasKey("wire0")) { // requirements.add(new ItemStack(BuildCraftTransport.pipeWire)); @@ -59,40 +58,42 @@ public class BptBlockPipe extends BptBlock { // } // } - if (BuildCraftCore.itemBptProps[pipeId] != null) { - BuildCraftCore.itemBptProps[pipeId].addRequirements(slot, requirements); - } + //if (BuildCraftCore.itemBptProps[pipeId] != null) { + // BuildCraftCore.itemBptProps[pipeId].addRequirements(slot, requirements); + //} } @Override public boolean isValid(BptSlotInfo slot, IBptContext context) { Pipe pipe = BlockGenericPipe.getPipe(context.world(), slot.x, slot.y, slot.z); - if (BlockGenericPipe.isValid(pipe)) - return pipe.itemID == slot.cpt.getInteger("pipeId"); - else - return false; + //if (BlockGenericPipe.isValid(pipe)) + // return pipe.itemID == slot.cpt.getInteger("pipeId"); + //else + // return false; + + return false; } @Override public void rotateLeft(BptSlotInfo slot, IBptContext context) { int pipeId = slot.cpt.getInteger("pipeId"); - if (BuildCraftCore.itemBptProps[pipeId] != null) { - BuildCraftCore.itemBptProps[pipeId].rotateLeft(slot, context); - } + //if (BuildCraftCore.itemBptProps[pipeId] != null) { + // BuildCraftCore.itemBptProps[pipeId].rotateLeft(slot, context); + //} } @Override public void buildBlock(BptSlotInfo slot, IBptContext context) { int pipeId = slot.cpt.getInteger("pipeId"); - Pipe pipe = BlockGenericPipe.createPipe(pipeId); + //Pipe pipe = BlockGenericPipe.createPipe(pipeId); - for (int i = 0; i < pipe.wireSet.length; ++i) - if (slot.cpt.hasKey("wire" + i)) { - pipe.wireSet[i] = true; - } + //for (int i = 0; i < pipe.wireSet.length; ++i) + // if (slot.cpt.hasKey("wire" + i)) { + // pipe.wireSet[i] = true; + // } // if (slot.cpt.hasKey("gate")) { // // / TODO: Does not save/load custom gates @@ -125,11 +126,11 @@ public class BptBlockPipe extends BptBlock { // } // } - BlockGenericPipe.placePipe(pipe, context.world(), slot.x, slot.y, slot.z, slot.blockId, slot.meta); + //BlockGenericPipe.placePipe(pipe, context.world(), slot.x, slot.y, slot.z, slot.blockId, slot.meta); - if (BuildCraftCore.itemBptProps[pipeId] != null) { - BuildCraftCore.itemBptProps[pipeId].buildBlock(slot, context); - } + //if (BuildCraftCore.itemBptProps[pipeId] != null) { + // BuildCraftCore.itemBptProps[pipeId].buildBlock(slot, context); + //} } @Override @@ -137,7 +138,7 @@ public class BptBlockPipe extends BptBlock { Pipe pipe = BlockGenericPipe.getPipe(context.world(), x, y, z); if (BlockGenericPipe.isValid(pipe)) { - bptSlot.cpt.setInteger("pipeId", pipe.itemID); + //bptSlot.cpt.setInteger("pipeId", pipe.itemID); for (int i = 0; i < pipe.wireSet.length; ++i) if (pipe.wireSet[i]) { @@ -169,9 +170,9 @@ public class BptBlockPipe extends BptBlock { // } // } - if (BuildCraftCore.itemBptProps[pipe.itemID] != null) { - BuildCraftCore.itemBptProps[pipe.itemID].initializeFromWorld(bptSlot, context, x, y, z); - } + //if (BuildCraftCore.itemBptProps[pipe.itemID] != null) { + // BuildCraftCore.itemBptProps[pipe.itemID].initializeFromWorld(bptSlot, context, x, y, z); + //} } } @@ -179,9 +180,9 @@ public class BptBlockPipe extends BptBlock { public void postProcessing(BptSlotInfo slot, IBptContext context) { int pipeId = slot.cpt.getInteger("pipeId"); - if (BuildCraftCore.itemBptProps[pipeId] != null) { - BuildCraftCore.itemBptProps[pipeId].postProcessing(slot, context); - } + //if (BuildCraftCore.itemBptProps[pipeId] != null) { + // BuildCraftCore.itemBptProps[pipeId].postProcessing(slot, context); + //} } @Override diff --git a/common/buildcraft/transport/blueprints/BptItemPipeDiamond.java b/common/buildcraft/transport/blueprints/BptItemPipeDiamond.java index 88b23ae7..b6bfdebd 100644 --- a/common/buildcraft/transport/blueprints/BptItemPipeDiamond.java +++ b/common/buildcraft/transport/blueprints/BptItemPipeDiamond.java @@ -1,12 +1,11 @@ /** - * Copyright (c) SpaceToad, 2011 + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.transport.blueprints; import buildcraft.api.blueprints.BptBlockUtils; @@ -16,7 +15,7 @@ import buildcraft.core.blueprints.BptItem; import java.util.LinkedList; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; public class BptItemPipeDiamond extends BptItem { @@ -52,14 +51,14 @@ public class BptItemPipeDiamond extends BptItem { @Override public void initializeFromWorld(BptSlotInfo bptSlot, IBptContext context, int x, int y, int z) { - IInventory inventory = (IInventory) context.world().getBlockTileEntity(x, y, z); + IInventory inventory = (IInventory) context.world().getTileEntity(x, y, z); BptBlockUtils.initializeInventoryContents(bptSlot, context, inventory); } @Override public void buildBlock(BptSlotInfo slot, IBptContext context) { - IInventory inventory = (IInventory) context.world().getBlockTileEntity(slot.x, slot.y, slot.z); + IInventory inventory = (IInventory) context.world().getTileEntity(slot.x, slot.y, slot.z); BptBlockUtils.buildInventoryContents(slot, context, inventory); } diff --git a/common/buildcraft/transport/blueprints/BptItemPipeEmerald.java b/common/buildcraft/transport/blueprints/BptItemPipeEmerald.java index f1d4cd6e..508f8d26 100644 --- a/common/buildcraft/transport/blueprints/BptItemPipeEmerald.java +++ b/common/buildcraft/transport/blueprints/BptItemPipeEmerald.java @@ -1,12 +1,11 @@ /** - * Copyright (c) SpaceToad, 2011 + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.transport.blueprints; import buildcraft.api.blueprints.BptBlockUtils; @@ -29,14 +28,14 @@ public class BptItemPipeEmerald extends BptItem { @Override public void initializeFromWorld(BptSlotInfo bptSlot, IBptContext context, int x, int y, int z) { - IInventory inventory = (IInventory) context.world().getBlockTileEntity(x, y, z); + IInventory inventory = (IInventory) context.world().getTileEntity(x, y, z); BptBlockUtils.initializeInventoryContents(bptSlot, context, inventory); } @Override public void buildBlock(BptSlotInfo slot, IBptContext context) { - IInventory inventory = (IInventory) context.world().getBlockTileEntity(slot.x, slot.y, slot.z); + IInventory inventory = (IInventory) context.world().getTileEntity(slot.x, slot.y, slot.z); BptBlockUtils.buildInventoryContents(slot, context, inventory); } diff --git a/common/buildcraft/transport/blueprints/BptItemPipeIron.java b/common/buildcraft/transport/blueprints/BptItemPipeIron.java index 5f5539d1..64eb3b98 100644 --- a/common/buildcraft/transport/blueprints/BptItemPipeIron.java +++ b/common/buildcraft/transport/blueprints/BptItemPipeIron.java @@ -1,12 +1,11 @@ /** - * Copyright (c) SpaceToad, 2011 + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.transport.blueprints; import buildcraft.api.blueprints.BptSlotInfo; @@ -14,7 +13,7 @@ import buildcraft.api.blueprints.IBptContext; import buildcraft.core.blueprints.BptItem; import java.util.LinkedList; import net.minecraft.item.ItemStack; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; public class BptItemPipeIron extends BptItem { diff --git a/common/buildcraft/transport/blueprints/BptItemPipeWooden.java b/common/buildcraft/transport/blueprints/BptItemPipeWooden.java index 66ef7240..161af8db 100644 --- a/common/buildcraft/transport/blueprints/BptItemPipeWooden.java +++ b/common/buildcraft/transport/blueprints/BptItemPipeWooden.java @@ -1,12 +1,11 @@ /** - * Copyright (c) SpaceToad, 2011 + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ - package buildcraft.transport.blueprints; import buildcraft.api.blueprints.BptSlotInfo; @@ -14,7 +13,7 @@ import buildcraft.api.blueprints.IBptContext; import buildcraft.core.blueprints.BptItem; import java.util.LinkedList; import net.minecraft.item.ItemStack; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; public class BptItemPipeWooden extends BptItem { diff --git a/common/buildcraft/transport/gates/GateDefinition.java b/common/buildcraft/transport/gates/GateDefinition.java index 4a37b9da..18535e20 100644 --- a/common/buildcraft/transport/gates/GateDefinition.java +++ b/common/buildcraft/transport/gates/GateDefinition.java @@ -1,7 +1,7 @@ -/* - * Copyright (c) SpaceToad, 2011-2012 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * + * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt @@ -10,15 +10,15 @@ package buildcraft.transport.gates; import buildcraft.core.DefaultProps; import buildcraft.core.utils.StringUtils; + import java.util.Locale; -import net.minecraft.client.renderer.texture.IconRegister; -import net.minecraft.util.Icon; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; -/** - * - * @author CovertJaguar - */ public final class GateDefinition { private GateDefinition() { @@ -38,14 +38,18 @@ public final class GateDefinition { public final int guiHeight; public final int numSlots; public final boolean hasParameterSlot; - private Icon iconBlock; - private Icon iconItem; + @SideOnly(Side.CLIENT) + private IIcon iconBlock; + @SideOnly(Side.CLIENT) + private IIcon iconItem; - public Icon getIconBlock() { + @SideOnly(Side.CLIENT) + public IIcon getIconBlock() { return iconBlock; } - public Icon getIconItem() { + @SideOnly(Side.CLIENT) + public IIcon getIconItem() { return iconItem; } @@ -53,12 +57,14 @@ public final class GateDefinition { return name().toLowerCase(Locale.ENGLISH); } - public void registerBlockIcon(IconRegister iconRegister) { + @SideOnly(Side.CLIENT) + public void registerBlockIcon(IIconRegister iconRegister) { if (this != REDSTONE) iconBlock = iconRegister.registerIcon("buildcraft:gates/gate_material_" + getTag()); } - public void registerItemIcon(IconRegister iconRegister) { + @SideOnly(Side.CLIENT) + public void registerItemIcon(IIconRegister iconRegister) { if (this != REDSTONE) iconItem = iconRegister.registerIcon("buildcraft:gates/gate_material_" + getTag()); } @@ -81,19 +87,19 @@ public final class GateDefinition { AND, OR; public static final GateLogic[] VALUES = values(); - private Icon iconLit; - private Icon iconDark; - private Icon iconItem; + private IIcon iconLit; + private IIcon iconDark; + private IIcon iconItem; - public Icon getIconLit() { + public IIcon getIconLit() { return iconLit; } - public Icon getIconDark() { + public IIcon getIconDark() { return iconDark; } - public Icon getIconItem() { + public IIcon getIconItem() { return iconItem; } @@ -101,12 +107,12 @@ public final class GateDefinition { return name().toLowerCase(Locale.ENGLISH); } - public void registerBlockIcon(IconRegister iconRegister) { + public void registerBlockIcon(IIconRegister iconRegister) { iconLit = iconRegister.registerIcon("buildcraft:gates/gate_lit_" + getTag()); iconDark = iconRegister.registerIcon("buildcraft:gates/gate_dark_" + getTag()); } - public void registerItemIcon(IconRegister iconRegister) { + public void registerItemIcon(IIconRegister iconRegister) { iconItem = iconRegister.registerIcon("buildcraft:gates/gate_logic_" + getTag()); } diff --git a/common/buildcraft/transport/gates/GateExpansionBuildcraft.java b/common/buildcraft/transport/gates/GateExpansionBuildcraft.java index 3f44ff24..d338c14f 100644 --- a/common/buildcraft/transport/gates/GateExpansionBuildcraft.java +++ b/common/buildcraft/transport/gates/GateExpansionBuildcraft.java @@ -1,7 +1,7 @@ -/* - * Copyright (c) SpaceToad, 2011-2012 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * + * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt @@ -10,18 +10,14 @@ package buildcraft.transport.gates; import buildcraft.api.gates.IGateExpansion; import buildcraft.core.utils.StringUtils; -import net.minecraft.client.renderer.texture.IconRegister; -import net.minecraft.util.Icon; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.util.IIcon; -/** - * - * @author CovertJaguar - */ public abstract class GateExpansionBuildcraft implements IGateExpansion { private final String tag; - private Icon iconBlock; - private Icon iconItem; + private IIcon iconBlock; + private IIcon iconItem; public GateExpansionBuildcraft(String tag) { this.tag = tag; @@ -38,22 +34,22 @@ public abstract class GateExpansionBuildcraft implements IGateExpansion { } @Override - public void registerBlockOverlay(IconRegister iconRegister) { + public void registerBlockOverlay(IIconRegister iconRegister) { iconBlock = iconRegister.registerIcon("buildcraft:gates/gate_expansion_" + tag); } @Override - public void registerItemOverlay(IconRegister iconRegister) { + public void registerItemOverlay(IIconRegister iconRegister) { iconItem = iconRegister.registerIcon("buildcraft:gates/gate_expansion_" + tag); } @Override - public Icon getOverlayBlock() { + public IIcon getOverlayBlock() { return iconBlock; } @Override - public Icon getOverlayItem() { + public IIcon getOverlayItem() { return iconItem; } } diff --git a/common/buildcraft/transport/gates/GateExpansionPulsar.java b/common/buildcraft/transport/gates/GateExpansionPulsar.java index a1fb1955..95f41068 100644 --- a/common/buildcraft/transport/gates/GateExpansionPulsar.java +++ b/common/buildcraft/transport/gates/GateExpansionPulsar.java @@ -1,5 +1,5 @@ -/* - * Copyright (c) SpaceToad, 2011-2012 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com * * BuildCraft is distributed under the terms of the Minecraft Mod Public @@ -23,12 +23,8 @@ import java.util.List; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; -/** - * - * @author CovertJaguar - */ public class GateExpansionPulsar extends GateExpansionBuildcraft implements IGateExpansion { public static GateExpansionPulsar INSTANCE = new GateExpansionPulsar(); diff --git a/common/buildcraft/transport/gates/GateExpansionRedstoneFader.java b/common/buildcraft/transport/gates/GateExpansionRedstoneFader.java index 3f098726..e413b03e 100644 --- a/common/buildcraft/transport/gates/GateExpansionRedstoneFader.java +++ b/common/buildcraft/transport/gates/GateExpansionRedstoneFader.java @@ -1,7 +1,7 @@ -/* - * Copyright (c) SpaceToad, 2011-2012 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * + * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt @@ -20,10 +20,6 @@ import java.util.Arrays; import java.util.List; import net.minecraft.tileentity.TileEntity; -/** - * - * @author CovertJaguar - */ public class GateExpansionRedstoneFader extends GateExpansionBuildcraft implements IGateExpansion { public static GateExpansionRedstoneFader INSTANCE = new GateExpansionRedstoneFader(); diff --git a/common/buildcraft/transport/gates/GateExpansionTimer.java b/common/buildcraft/transport/gates/GateExpansionTimer.java index 470d58c8..456d5da1 100644 --- a/common/buildcraft/transport/gates/GateExpansionTimer.java +++ b/common/buildcraft/transport/gates/GateExpansionTimer.java @@ -1,7 +1,7 @@ -/* - * Copyright (c) SpaceToad, 2011-2012 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * + * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt @@ -18,10 +18,6 @@ import buildcraft.transport.triggers.TriggerClockTimer.Time; import java.util.List; import net.minecraft.tileentity.TileEntity; -/** - * - * @author CovertJaguar - */ public class GateExpansionTimer extends GateExpansionBuildcraft implements IGateExpansion { public static GateExpansionTimer INSTANCE = new GateExpansionTimer(); diff --git a/common/buildcraft/transport/gates/GateFactory.java b/common/buildcraft/transport/gates/GateFactory.java index f6dadb17..cabb67de 100644 --- a/common/buildcraft/transport/gates/GateFactory.java +++ b/common/buildcraft/transport/gates/GateFactory.java @@ -1,7 +1,7 @@ -/* - * Copyright (c) SpaceToad, 2011-2012 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * + * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt @@ -11,6 +11,7 @@ package buildcraft.transport.gates; import buildcraft.api.gates.GateExpansionController; import buildcraft.api.gates.GateExpansions; import buildcraft.api.gates.IGateExpansion; +import buildcraft.core.utils.Utils; import buildcraft.transport.Gate; import buildcraft.transport.Pipe; import buildcraft.transport.gates.GateDefinition.GateLogic; @@ -19,10 +20,6 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; -/** - * - * @author CovertJaguar - */ public class GateFactory { public static Gate makeGate(Pipe pipe, GateMaterial material, GateLogic logic) { @@ -98,9 +95,9 @@ public class GateFactory { gate.expansions.put(GateExpansionPulsar.INSTANCE, pulsarCon); } - NBTTagList exList = nbt.getTagList("expansions"); + NBTTagList exList = nbt.getTagList("expansions", Utils.NBTTag_Types.NBTTagCompound.ordinal()); for (int i = 0; i < exList.tagCount(); i++) { - NBTTagCompound conNBT = (NBTTagCompound) exList.tagAt(i); + NBTTagCompound conNBT = exList.getCompoundTagAt(i); IGateExpansion ex = GateExpansions.getExpansion(conNBT.getString("type")); if (ex != null) { GateExpansionController con = ex.makeController(pipe.container); diff --git a/common/buildcraft/transport/gates/ItemGate.java b/common/buildcraft/transport/gates/ItemGate.java index 3e7da7ae..ccec07d8 100644 --- a/common/buildcraft/transport/gates/ItemGate.java +++ b/common/buildcraft/transport/gates/ItemGate.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.transport.gates; import buildcraft.api.gates.GateExpansions; @@ -9,24 +17,28 @@ import buildcraft.api.gates.ITrigger; import buildcraft.core.ItemBuildCraft; import buildcraft.core.inventory.InvUtils; import buildcraft.core.utils.Localization; +import buildcraft.core.utils.Utils; import buildcraft.transport.Gate; import buildcraft.transport.gates.GateDefinition.GateLogic; import buildcraft.transport.gates.GateDefinition.GateMaterial; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; + import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Set; -import net.minecraft.client.renderer.texture.IconRegister; + +import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagString; -import net.minecraft.util.Icon; +import net.minecraft.util.IIcon; public class ItemGate extends ItemBuildCraft { @@ -34,17 +46,19 @@ public class ItemGate extends ItemBuildCraft { private static final String NBT_TAG_LOGIC = "logic"; private static final String NBT_TAG_EX = "ex"; - public ItemGate(int id) { - super(id); + public ItemGate() { + super(); setHasSubtypes(false); setMaxDamage(0); setPassSneakClick(true); } private static NBTTagCompound getNBT(ItemStack stack) { - if (stack == null || !(stack.getItem() instanceof ItemGate)) + if (stack == null || !(stack.getItem() instanceof ItemGate)) { return null; - return InvUtils.getItemData(stack); + } else { + return InvUtils.getItemData(stack); + } } public static void setMaterial(ItemStack stack, GateMaterial material) { @@ -54,16 +68,22 @@ public class ItemGate extends ItemBuildCraft { public static GateMaterial getMaterial(ItemStack stack) { NBTTagCompound nbt = getNBT(stack); - if (nbt == null) + + if (nbt == null) { return GateMaterial.REDSTONE; - return GateMaterial.fromOrdinal(nbt.getByte(NBT_TAG_MAT)); + } else { + return GateMaterial.fromOrdinal(nbt.getByte(NBT_TAG_MAT)); + } } public static GateLogic getLogic(ItemStack stack) { NBTTagCompound nbt = getNBT(stack); - if (nbt == null) + + if (nbt == null) { return GateLogic.AND; - return GateLogic.fromOrdinal(nbt.getByte(NBT_TAG_LOGIC)); + } else { + return GateLogic.fromOrdinal(nbt.getByte(NBT_TAG_LOGIC)); + } } public static void setLogic(ItemStack stack, GateLogic logic) { @@ -73,44 +93,58 @@ public class ItemGate extends ItemBuildCraft { public static void addGateExpansion(ItemStack stack, IGateExpansion expansion) { NBTTagCompound nbt = getNBT(stack); - if (nbt == null) + + if (nbt == null) { return; - NBTTagList expansionList = nbt.getTagList(NBT_TAG_EX); - expansionList.appendTag(new NBTTagString("", expansion.getUniqueIdentifier())); + } + + NBTTagList expansionList = nbt.getTagList(NBT_TAG_EX, Utils.NBTTag_Types.NBTTagString.ordinal()); + expansionList.appendTag(new NBTTagString(expansion.getUniqueIdentifier())); nbt.setTag(NBT_TAG_EX, expansionList); } public static boolean hasGateExpansion(ItemStack stack, IGateExpansion expansion) { NBTTagCompound nbt = getNBT(stack); - if (nbt == null) + + if (nbt == null) { return false; + } + try { - NBTTagList expansionList = nbt.getTagList(NBT_TAG_EX); + NBTTagList expansionList = nbt.getTagList(NBT_TAG_EX, Utils.NBTTag_Types.NBTTagString.ordinal()); + for (int i = 0; i < expansionList.tagCount(); i++) { - NBTTagString ex = (NBTTagString) expansionList.tagAt(i); - if (ex.data.equals(expansion.getUniqueIdentifier())) + String ex = expansionList.getStringTagAt(i); + + if (ex.equals(expansion.getUniqueIdentifier())) { return true; + } } } catch (RuntimeException error) { } + return false; } public static Set getInstalledExpansions(ItemStack stack) { Set expansions = new HashSet(); NBTTagCompound nbt = getNBT(stack); - if (nbt == null) + + if (nbt == null) { return expansions; + } + try { - NBTTagList expansionList = nbt.getTagList(NBT_TAG_EX); + NBTTagList expansionList = nbt.getTagList(NBT_TAG_EX, Utils.NBTTag_Types.NBTTagString.ordinal()); for (int i = 0; i < expansionList.tagCount(); i++) { - NBTTagString exTag = (NBTTagString) expansionList.tagAt(i); - IGateExpansion ex = GateExpansions.getExpansion(exTag.data); + String exTag = expansionList.getStringTagAt(i); + IGateExpansion ex = GateExpansions.getExpansion(exTag); if (ex != null) expansions.add(ex); } } catch (RuntimeException error) { } + return expansions; } @@ -119,6 +153,7 @@ public class ItemGate extends ItemBuildCraft { NBTTagCompound nbt = InvUtils.getItemData(stack); nbt.setByte(NBT_TAG_MAT, (byte) material.ordinal()); nbt.setByte(NBT_TAG_LOGIC, (byte) logic.ordinal()); + return stack; } @@ -127,9 +162,11 @@ public class ItemGate extends ItemBuildCraft { NBTTagCompound nbt = InvUtils.getItemData(stack); nbt.setByte(NBT_TAG_MAT, (byte) gate.material.ordinal()); nbt.setByte(NBT_TAG_LOGIC, (byte) gate.logic.ordinal()); + for (IGateExpansion expansion : gate.expansions.keySet()) { addGateExpansion(stack, expansion); } + return stack; } @@ -141,40 +178,51 @@ public class ItemGate extends ItemBuildCraft { @SuppressWarnings({"unchecked", "rawtypes"}) @Override @SideOnly(Side.CLIENT) - public void getSubItems(int id, CreativeTabs tab, List itemList) { + public void getSubItems(Item item, CreativeTabs tab, List itemList) { for (GateMaterial material : GateMaterial.VALUES) { for (GateLogic logic : GateLogic.VALUES) { - if (material == GateMaterial.REDSTONE && logic == GateLogic.OR) + if (material == GateMaterial.REDSTONE && logic == GateLogic.OR) { continue; - ItemStack stack = makeGateItem(material, logic); - for (IGateExpansion exp : GateExpansions.getExpansions()) { - addGateExpansion(stack, exp); } - itemList.add(stack); + + itemList.add(makeGateItem(material, logic)); + + for (IGateExpansion exp : GateExpansions.getExpansions()) { + ItemStack stackExpansion = makeGateItem(material, logic); + addGateExpansion(stackExpansion, exp); + itemList.add(stackExpansion); + } } } } public static ItemStack[] getGateVarients() { ArrayList gates = new ArrayList(); + for (GateMaterial material : GateMaterial.VALUES) { for (GateLogic logic : GateLogic.VALUES) { - if (material == GateMaterial.REDSTONE && logic == GateLogic.OR) + if (material == GateMaterial.REDSTONE && logic == GateLogic.OR) { continue; + } + gates.add(makeGateItem(material, logic)); } } + return gates.toArray(new ItemStack[gates.size()]); } @Override public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean adv) { super.addInformation(stack, player, list, adv); + list.add("§9§o" + Localization.get("tip.gate.wires")); list.add(Localization.get("tip.gate.wires." + getMaterial(stack).getTag())); Set expansions = getInstalledExpansions(stack); + if (!expansions.isEmpty()) { list.add("§9§o" + Localization.get("tip.gate.expansions")); + for (IGateExpansion expansion : expansions) { list.add(expansion.getDisplayName()); } @@ -182,14 +230,13 @@ public class ItemGate extends ItemBuildCraft { } @Override - public Icon getIconIndex(ItemStack stack) { + public IIcon getIconIndex(ItemStack stack) { return getLogic(stack).getIconItem(); } @Override @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister iconRegister) { - + public void registerIcons(IIconRegister iconRegister) { for (GateDefinition.GateMaterial material : GateDefinition.GateMaterial.VALUES) { material.registerItemIcon(iconRegister); } diff --git a/common/buildcraft/transport/gui/ContainerDiamondPipe.java b/common/buildcraft/transport/gui/ContainerDiamondPipe.java index b55c9987..a0c7f3f2 100644 --- a/common/buildcraft/transport/gui/ContainerDiamondPipe.java +++ b/common/buildcraft/transport/gui/ContainerDiamondPipe.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.transport.gui; diff --git a/common/buildcraft/transport/gui/ContainerEmeraldPipe.java b/common/buildcraft/transport/gui/ContainerEmeraldPipe.java index 86beec41..7acbc334 100644 --- a/common/buildcraft/transport/gui/ContainerEmeraldPipe.java +++ b/common/buildcraft/transport/gui/ContainerEmeraldPipe.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.transport.gui; diff --git a/common/buildcraft/transport/gui/ContainerEmzuliPipe.java b/common/buildcraft/transport/gui/ContainerEmzuliPipe.java index 76e5a3ef..031d1846 100644 --- a/common/buildcraft/transport/gui/ContainerEmzuliPipe.java +++ b/common/buildcraft/transport/gui/ContainerEmzuliPipe.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.transport.gui; @@ -32,10 +33,6 @@ import net.minecraft.inventory.ICrafting; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; -/** - * - * @author SandGrainOne - */ public class ContainerEmzuliPipe extends BuildCraftContainer { private final PipeItemsEmzuli pipe; diff --git a/common/buildcraft/transport/gui/ContainerFilteredBuffer.java b/common/buildcraft/transport/gui/ContainerFilteredBuffer.java index 4e9cb88f..731aa6ed 100644 --- a/common/buildcraft/transport/gui/ContainerFilteredBuffer.java +++ b/common/buildcraft/transport/gui/ContainerFilteredBuffer.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.transport.gui; @@ -16,10 +17,6 @@ import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; -/** - * - * @author SandGrainOne - */ public class ContainerFilteredBuffer extends BuildCraftContainer { private class SlotPhantomLockable extends SlotPhantom { diff --git a/common/buildcraft/transport/gui/ContainerGateInterface.java b/common/buildcraft/transport/gui/ContainerGateInterface.java index e153f841..ccd5eb76 100644 --- a/common/buildcraft/transport/gui/ContainerGateInterface.java +++ b/common/buildcraft/transport/gui/ContainerGateInterface.java @@ -1,12 +1,14 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.transport.gui; +import buildcraft.BuildCraftTransport; import buildcraft.api.gates.ActionManager; import buildcraft.api.gates.IAction; import buildcraft.api.gates.IOverrideDefaultTriggers; @@ -20,8 +22,10 @@ import buildcraft.core.network.PacketPayload; import buildcraft.core.network.PacketPayloadStream; import buildcraft.core.network.PacketUpdate; import buildcraft.core.proxy.CoreProxy; +import buildcraft.core.utils.Utils; import buildcraft.transport.Pipe; import buildcraft.transport.gates.GateDefinition; +import io.netty.buffer.ByteBuf; import java.io.ByteArrayOutputStream; import java.io.DataInputStream; @@ -33,32 +37,37 @@ import java.util.NavigableSet; import java.util.TreeSet; import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.ICrafting; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -import net.minecraft.network.packet.Packet; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.Packet; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; public class ContainerGateInterface extends BuildCraftContainer { IInventory playerIInventory; Pipe pipe; + private final NavigableSet _potentialTriggers = new TreeSet(new Comparator() { @Override public int compare(ITrigger o1, ITrigger o2) { return o1.getUniqueTag().compareTo(o2.getUniqueTag()); } }); + private final NavigableSet _potentialActions = new TreeSet(new Comparator() { @Override public int compare(IAction o1, IAction o2) { return o1.getUniqueTag().compareTo(o2.getUniqueTag()); } }); + private boolean isSynchronized = false; private boolean isNetInitialized = false; public boolean[] triggerState = new boolean[8]; @@ -66,6 +75,7 @@ public class ContainerGateInterface extends BuildCraftContainer { public ContainerGateInterface(IInventory playerInventory, Pipe pipe) { super(0); + this.playerIInventory = playerInventory; for (int y = 0; y < 3; y++) { @@ -82,7 +92,7 @@ public class ContainerGateInterface extends BuildCraftContainer { // Do not attempt to create a list of potential actions and triggers on // the client. - if (!CoreProxy.proxy.isRenderWorld(pipe.container.worldObj)) { + if (!pipe.container.getWorldObj().isRemote) { _potentialActions.addAll(pipe.getActions()); _potentialTriggers.addAll(ActionManager.getPipeTriggers(pipe.container)); @@ -92,18 +102,20 @@ public class ContainerGateInterface extends BuildCraftContainer { for (ForgeDirection o : ForgeDirection.VALID_DIRECTIONS) { TileEntity tile = pipe.container.getTile(o); - int blockID = pipe.container.getBlockId(o); - Block block = Block.blocksList[blockID]; + Block block = pipe.container.getBlock(o); _potentialTriggers.addAll(ActionManager.getNeighborTriggers(block, tile)); _potentialActions.addAll(ActionManager.getNeighborActions(block, tile)); } if (!pipe.gate.material.hasParameterSlot) { Iterator it = _potentialTriggers.iterator(); + while (it.hasNext()) { ITrigger trigger = it.next(); - if (trigger.requiresParameter()) + + if (trigger.requiresParameter()) { it.remove(); + } } } } @@ -111,9 +123,11 @@ public class ContainerGateInterface extends BuildCraftContainer { @Override public boolean canInteractWith(EntityPlayer player) { - if (pipe == null || pipe.gate == null) + if (pipe == null || pipe.gate == null) { return false; - return true; + } else { + return true; + } } /** @@ -135,15 +149,10 @@ public class ContainerGateInterface extends BuildCraftContainer { public void updateActions(PacketUpdate packet) { _potentialActions.clear(); PacketPayloadStream payload = (PacketPayloadStream) packet.payload; - try { - int length = payload.stream.readInt(); - for (int i = 0; i < length; i++) { - _potentialActions.add(ActionManager.actions.get(payload.stream.readUTF())); - } - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + int length = payload.stream.readInt(); + for (int i = 0; i < length; i++) { + _potentialActions.add(ActionManager.actions.get(Utils.readUTF(payload.stream))); } } @@ -156,17 +165,12 @@ public class ContainerGateInterface extends BuildCraftContainer { _potentialTriggers.clear(); PacketPayloadStream payload = (PacketPayloadStream) packet.payload; - try { - int length = payload.stream.readInt(); + int length = payload.stream.readInt(); - for (int i = 0; i < length; i++) { - String trigger = payload.stream.readUTF(); - _potentialTriggers.add(ActionManager.triggers.get(trigger)); - } - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } + for (int i = 0; i < length; i++) { + String trigger = Utils.readUTF(payload.stream); + _potentialTriggers.add(ActionManager.triggers.get(trigger)); + } } /** @@ -175,50 +179,47 @@ public class ContainerGateInterface extends BuildCraftContainer { * @param packet */ public void setSelection(PacketUpdate packet, boolean notify) { - try { - PacketPayloadStream payload = (PacketPayloadStream) packet.payload; - DataInputStream data = payload.stream; + PacketPayloadStream payload = (PacketPayloadStream) packet.payload; + ByteBuf data = payload.stream; - int position = data.readInt(); + int position = data.readInt(); - setTrigger(position, ActionManager.triggers.get(data.readUTF()), notify); - setAction(position, ActionManager.actions.get(data.readUTF()), notify); + setTrigger(position, ActionManager.triggers.get(Utils.readUTF(data)), notify); + setAction(position, ActionManager.actions.get(Utils.readUTF(data)), notify); - ItemStack parameter = Packet.readItemStack(data); - if (parameter != null) { - ITriggerParameter param = new TriggerParameter(); - param.set(parameter); - setTriggerParameter(position, param, notify); - } else { - setTriggerParameter(position, null, notify); - } - } catch (IOException e) { - e.printStackTrace(); + ItemStack parameter = Utils.readStack(data); + + if (parameter != null) { + ITriggerParameter param = new TriggerParameter(); + param.set(parameter); + setTriggerParameter(position, param, notify); + } else { + setTriggerParameter(position, null, notify); } } private PacketPayload getSelectionPayload(final int position) { PacketPayloadStream payload = new PacketPayloadStream(new PacketPayloadStream.StreamWriter() { @Override - public void writeData(DataOutputStream data) throws IOException { + public void writeData(ByteBuf data) { data.writeInt(position); if (pipe.gate.triggers[position] != null) { - data.writeUTF(pipe.gate.triggers[position].getUniqueTag()); + Utils.writeUTF(data, pipe.gate.triggers[position].getUniqueTag()); } else { - data.writeUTF(""); + Utils.writeUTF(data, ""); } if (pipe.gate.actions[position] != null) { - data.writeUTF(pipe.gate.actions[position].getUniqueTag()); + Utils.writeUTF(data, pipe.gate.actions[position].getUniqueTag()); } else { - data.writeUTF(""); + Utils.writeUTF(data, ""); } if (pipe.gate.triggerParameters[position] != null && pipe.gate.triggerParameters[position].getItemStack() != null) { - Packet.writeItemStack(pipe.gate.triggerParameters[position].getItemStack().copy(), data); + Utils.writeStack(data, pipe.gate.triggerParameters[position].getItemStack()); } else { - Packet.writeItemStack(null, data); + Utils.writeStack(data, null); } } }); @@ -227,7 +228,12 @@ public class ContainerGateInterface extends BuildCraftContainer { } public void sendSelectionChange(int position) { - CoreProxy.proxy.sendToServer(new PacketUpdate(PacketIds.GATE_SELECTION_CHANGE, pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord, getSelectionPayload(position)).getPacket()); + if (pipe.container.getWorld().isRemote) { + BuildCraftTransport.instance.sendToServer(new PacketUpdate( + PacketIds.GATE_SELECTION_CHANGE, pipe.container.xCoord, + pipe.container.yCoord, pipe.container.zCoord, + getSelectionPayload(position))); + } } /** @@ -235,15 +241,14 @@ public class ContainerGateInterface extends BuildCraftContainer { * (re-)requests the current selection on the gate if needed. */ public void synchronize() { - - if (!isNetInitialized && CoreProxy.proxy.isRenderWorld(pipe.container.worldObj)) { + if (!isNetInitialized && pipe.container.getWorldObj().isRemote) { isNetInitialized = true; - CoreProxy.proxy.sendToServer(new PacketCoordinates(PacketIds.GATE_REQUEST_INIT, pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord).getPacket()); + BuildCraftTransport.instance.sendToServer(new PacketCoordinates(PacketIds.GATE_REQUEST_INIT, pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord)); } - if (!isSynchronized && CoreProxy.proxy.isRenderWorld(pipe.container.worldObj)) { + if (!isSynchronized && pipe.container.getWorldObj().isRemote) { isSynchronized = true; - CoreProxy.proxy.sendToServer(new PacketCoordinates(PacketIds.GATE_REQUEST_SELECTION, pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord).getPacket()); + BuildCraftTransport.instance.sendToServer(new PacketCoordinates(PacketIds.GATE_REQUEST_SELECTION, pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord)); } } @@ -261,28 +266,36 @@ public class ContainerGateInterface extends BuildCraftContainer { * SERVER SIDE * */ private int calculateTriggerState() { - if (pipe.gate == null) + if (pipe.gate == null) { return 0; + } + int state = 0; + for (int i = 0; i < triggerState.length; i++) { if (pipe.gate.triggers[i] != null) { triggerState[i] = isNearbyTriggerActive(pipe.gate.triggers[i], pipe.gate.getTriggerParameter(i)); } + state |= triggerState[i] ? 0x01 << i : 0x0; } + return state; } @Override public void detectAndSendChanges() { super.detectAndSendChanges(); + int state = calculateTriggerState(); + if (state != lastTriggerState) { for (int i = 0; i < this.crafters.size(); i++) { ICrafting viewingPlayer = (ICrafting) this.crafters.get(i); viewingPlayer.sendProgressBarUpdate(this, 0 /* State update */, state); } + lastTriggerState = state; } } @@ -299,20 +312,16 @@ public class ContainerGateInterface extends BuildCraftContainer { * @param player */ private void sendActions(EntityPlayer player) { - // Compose update packet - PacketPayloadStream payload = new PacketPayloadStream( new PacketPayloadStream.StreamWriter() { @Override - public void writeData(DataOutputStream data) - throws IOException { - + public void writeData(ByteBuf data) { int length = _potentialActions.size(); data.writeInt(length); for (IAction action : _potentialActions) { - data.writeUTF(action.getUniqueTag()); + Utils.writeUTF(data, action.getUniqueTag()); } } }); @@ -320,7 +329,7 @@ public class ContainerGateInterface extends BuildCraftContainer { PacketUpdate packet = new PacketUpdate(PacketIds.GATE_ACTIONS, pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord, payload); // Send to player - CoreProxy.proxy.sendToPlayer(player, packet); + BuildCraftTransport.instance.sendToPlayer(player, packet); } /** @@ -329,18 +338,16 @@ public class ContainerGateInterface extends BuildCraftContainer { * @param player */ private void sendTriggers(EntityPlayer player) { - PacketPayloadStream payload = new PacketPayloadStream( new PacketPayloadStream.StreamWriter() { @Override - public void writeData(DataOutputStream data) - throws IOException { + public void writeData(ByteBuf data) { int length = _potentialTriggers.size(); data.writeInt(length); for (ITrigger trigger : _potentialTriggers) { - data.writeUTF(trigger.getUniqueTag()); + Utils.writeUTF(data, trigger.getUniqueTag()); } } }); @@ -348,7 +355,7 @@ public class ContainerGateInterface extends BuildCraftContainer { PacketUpdate packet = new PacketUpdate(PacketIds.GATE_TRIGGERS, pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord, payload); // Send to player - CoreProxy.proxy.sendToPlayer(player, packet); + BuildCraftTransport.instance.sendToPlayer(player, packet); } /** @@ -357,13 +364,13 @@ public class ContainerGateInterface extends BuildCraftContainer { * @param player */ public void sendSelection(EntityPlayer player) { - if (pipe == null || pipe.gate == null) + if (pipe == null || pipe.gate == null) { return; - for (int position = 0; position < pipe.gate.material.numSlots; position++) { - CoreProxy.proxy.sendToPlayer(player, new PacketUpdate(PacketIds.GATE_SELECTION, pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord, getSelectionPayload(position))); } - - // System.out.println("Sending current selection to player"); + + for (int position = 0; position < pipe.gate.material.numSlots; position++) { + BuildCraftTransport.instance.sendToPlayer(player, new PacketUpdate(PacketIds.GATE_SELECTION, pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord, getSelectionPayload(position))); + } } /** @@ -374,15 +381,19 @@ public class ContainerGateInterface extends BuildCraftContainer { } public ITrigger getFirstTrigger() { - if (_potentialTriggers.isEmpty()) + if (_potentialTriggers.isEmpty()) { return null; - return _potentialTriggers.first(); + } else { + return _potentialTriggers.first(); + } } public ITrigger getLastTrigger() { - if (_potentialTriggers.isEmpty()) + if (_potentialTriggers.isEmpty()) { return null; - return _potentialTriggers.last(); + } else { + return _potentialTriggers.last(); + } } public Iterator getTriggerIterator(boolean descending) { @@ -390,25 +401,33 @@ public class ContainerGateInterface extends BuildCraftContainer { } public boolean isNearbyTriggerActive(ITrigger trigger, ITriggerParameter parameter) { - if (pipe.gate == null) + if (pipe.gate == null) { return false; - return pipe.gate.isNearbyTriggerActive(trigger, parameter); + } else { + return pipe.gate.isNearbyTriggerActive(trigger, parameter); + } } public void setTrigger(int position, ITrigger trigger, boolean notify) { - if (pipe.gate == null) + if (pipe.gate == null) { return; + } + pipe.gate.setTrigger(position, trigger); - if (CoreProxy.proxy.isRenderWorld(pipe.container.worldObj) && notify) { + + if (pipe.container.getWorldObj().isRemote && notify) { sendSelectionChange(position); } } public void setTriggerParameter(int position, ITriggerParameter parameter, boolean notify) { - if (pipe.gate == null) + if (pipe.gate == null) { return; + } + pipe.gate.setTriggerParameter(position, parameter); - if (CoreProxy.proxy.isRenderWorld(pipe.container.worldObj) && notify) { + + if (pipe.container.getWorldObj().isRemote && notify) { sendSelectionChange(position); } } @@ -421,15 +440,19 @@ public class ContainerGateInterface extends BuildCraftContainer { } public IAction getFirstAction() { - if (_potentialActions.isEmpty()) + if (_potentialActions.isEmpty()) { return null; - return _potentialActions.first(); + } else { + return _potentialActions.first(); + } } public IAction getLastAction() { - if (_potentialActions.isEmpty()) + if (_potentialActions.isEmpty()) { return null; - return _potentialActions.last(); + } else { + return _potentialActions.last(); + } } public Iterator getActionIterator(boolean descending) { @@ -438,7 +461,8 @@ public class ContainerGateInterface extends BuildCraftContainer { public void setAction(int position, IAction action, boolean notify) { pipe.gate.setAction(position, action); - if (CoreProxy.proxy.isRenderWorld(pipe.container.worldObj) && notify) { + + if (pipe.container.getWorldObj().isRemote && notify) { sendSelectionChange(position); } } diff --git a/common/buildcraft/transport/gui/GuiDiamondPipe.java b/common/buildcraft/transport/gui/GuiDiamondPipe.java index 85e9a1ad..82dc48e5 100644 --- a/common/buildcraft/transport/gui/GuiDiamondPipe.java +++ b/common/buildcraft/transport/gui/GuiDiamondPipe.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.transport.gui; @@ -42,8 +43,8 @@ public class GuiDiamondPipe extends GuiBuildCraft { @Override protected void drawGuiContainerForegroundLayer(int par1, int par2) { - fontRenderer.drawString(filterInventory.getInvName(), getCenteredOffset(filterInventory.getInvName()), 6, 0x404040); - fontRenderer.drawString(StringUtils.localize("gui.inventory"), 8, ySize - 97, 0x404040); + fontRendererObj.drawString(filterInventory.getInventoryName(), getCenteredOffset(filterInventory.getInventoryName()), 6, 0x404040); + fontRendererObj.drawString(StringUtils.localize("gui.inventory"), 8, ySize - 97, 0x404040); } @Override diff --git a/common/buildcraft/transport/gui/GuiEmeraldPipe.java b/common/buildcraft/transport/gui/GuiEmeraldPipe.java index 8c5e2f59..00c91dff 100644 --- a/common/buildcraft/transport/gui/GuiEmeraldPipe.java +++ b/common/buildcraft/transport/gui/GuiEmeraldPipe.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.transport.gui; @@ -51,7 +52,7 @@ public class GuiEmeraldPipe extends GuiBuildCraft { @Override public void onGuiClosed() { - if (CoreProxy.proxy.isRenderWorld(pipe.getWorld())) { + if (pipe.getWorld().isRemote) { pipe.getStateController().setCurrentState(button.getController().getCurrentState()); PacketGuiReturn pkt = new PacketGuiReturn(pipe.getContainer()); pkt.sendPacket(); @@ -62,8 +63,8 @@ public class GuiEmeraldPipe extends GuiBuildCraft { @Override protected void drawGuiContainerForegroundLayer(int par1, int par2) { - fontRenderer.drawString(filterInventory.getInvName(), getCenteredOffset(filterInventory.getInvName()), 6, 0x404040); - fontRenderer.drawString(StringUtils.localize("gui.inventory"), 8, ySize - 93, 0x404040); + fontRendererObj.drawString(filterInventory.getInventoryName(), getCenteredOffset(filterInventory.getInventoryName()), 6, 0x404040); + fontRendererObj.drawString(StringUtils.localize("gui.inventory"), 8, ySize - 93, 0x404040); } @Override diff --git a/common/buildcraft/transport/gui/GuiEmzuliPipe.java b/common/buildcraft/transport/gui/GuiEmzuliPipe.java index 5336186e..c7e30a1e 100644 --- a/common/buildcraft/transport/gui/GuiEmzuliPipe.java +++ b/common/buildcraft/transport/gui/GuiEmzuliPipe.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.transport.gui; @@ -16,10 +17,6 @@ import buildcraft.core.gui.GuiBuildCraft; import buildcraft.core.utils.StringUtils; import buildcraft.transport.pipes.PipeItemsEmzuli; -/** - * - * @author SandGrainOne - */ public class GuiEmzuliPipe extends GuiBuildCraft { private static final ResourceLocation TEXTURE = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/pipe_emzuli.png"); @@ -39,7 +36,7 @@ public class GuiEmzuliPipe extends GuiBuildCraft { @Override protected void drawGuiContainerForegroundLayer(int par1, int par2) { String title = StringUtils.localize("gui.pipes.emzuli.title"); - fontRenderer.drawString(title, (xSize - fontRenderer.getStringWidth(title)) / 2, 6, 0x404040); - fontRenderer.drawString(StringUtils.localize("gui.inventory"), 8, ySize - 93, 0x404040); + fontRendererObj.drawString(title, (xSize - fontRendererObj.getStringWidth(title)) / 2, 6, 0x404040); + fontRendererObj.drawString(StringUtils.localize("gui.inventory"), 8, ySize - 93, 0x404040); } } diff --git a/common/buildcraft/transport/gui/GuiFilteredBuffer.java b/common/buildcraft/transport/gui/GuiFilteredBuffer.java index ec2356f4..a5ec8f3c 100644 --- a/common/buildcraft/transport/gui/GuiFilteredBuffer.java +++ b/common/buildcraft/transport/gui/GuiFilteredBuffer.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.transport.gui; @@ -16,10 +17,6 @@ import net.minecraft.inventory.IInventory; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; -/** - * - * @author SandGrainOne - */ public class GuiFilteredBuffer extends GuiContainer { private static final ResourceLocation TEXTURE = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/filteredBuffer_gui.png"); @@ -57,7 +54,7 @@ public class GuiFilteredBuffer extends GuiContainer { @Override protected void drawGuiContainerForegroundLayer(int par1, int par2) { String title = StringUtils.localize("tile.filteredBufferBlock"); - int xPos = (xSize - fontRenderer.getStringWidth(title)) / 2; - fontRenderer.drawString(title, xPos, 10, 0x404040); + int xPos = (xSize - fontRendererObj.getStringWidth(title)) / 2; + fontRendererObj.drawString(title, xPos, 10, 0x404040); } } diff --git a/common/buildcraft/transport/gui/GuiGateInterface.java b/common/buildcraft/transport/gui/GuiGateInterface.java index 58d03be4..93b27b13 100644 --- a/common/buildcraft/transport/gui/GuiGateInterface.java +++ b/common/buildcraft/transport/gui/GuiGateInterface.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.transport.gui; @@ -23,7 +24,7 @@ import java.util.Iterator; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; -import net.minecraft.util.Icon; +import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; @@ -50,20 +51,24 @@ public class GuiGateInterface extends GuiAdvancedInterface { @Override public String getDescription() { ITrigger trigger = pipe.gate.getTrigger(slot); - if (trigger != null) + + if (trigger != null) { return trigger.getDescription(); - else + } else { return ""; + } } @SideOnly(Side.CLIENT) @Override - public Icon getIcon() { + public IIcon getIcon() { ITrigger trigger = pipe.gate.getTrigger(slot); - if (trigger != null) + + if (trigger != null) { return trigger.getIcon(); - else + } else { return null; + } } @Override @@ -91,30 +96,37 @@ public class GuiGateInterface extends GuiAdvancedInterface { @Override public String getDescription() { IAction action = pipe.gate.getAction(slot); - if (action != null) + if (action != null) { return action.getDescription(); - else + } else { return ""; + } } @SideOnly(Side.CLIENT) @Override - public Icon getIcon() { + public IIcon getIcon() { IAction action = pipe.gate.getAction(slot); - if (action != null) + + if (action != null) { return action.getIcon(); - else + } else { return null; + } } @Override public ResourceLocation getTexture() { IAction action = pipe.gate.getAction(slot); + if (action instanceof BCAction) { BCAction bcAction = (BCAction) action; - if (bcAction.getTextureMap() == 0) + + if (bcAction.getTextureMap() == 0) { return TextureMap.locationBlocksTexture; + } } + return super.getTexture(); } @@ -148,10 +160,12 @@ public class GuiGateInterface extends GuiAdvancedInterface { @Override public ItemStack getItemStack() { ITriggerParameter parameter = pipe.gate.getTriggerParameter(slot); - if (parameter != null) + + if (parameter != null) { return parameter.getItemStack(); - else + } else { return null; + } } public ITriggerParameter getTriggerParameter() { @@ -232,8 +246,8 @@ public class GuiGateInterface extends GuiAdvancedInterface { protected void drawGuiContainerForegroundLayer(int par1, int par2) { String name = _container.getGateName(); - fontRenderer.drawString(name, getCenteredOffset(name), 10, 0x404040); - fontRenderer.drawString(StringUtils.localize("gui.inventory"), 8, ySize - 97, 0x404040); + fontRendererObj.drawString(name, getCenteredOffset(name), 10, 0x404040); + fontRendererObj.drawString(StringUtils.localize("gui.inventory"), 8, ySize - 97, 0x404040); drawForegroundSelection(par1, par2); } @@ -294,8 +308,9 @@ public class GuiGateInterface extends GuiAdvancedInterface { AdvancedSlot slot = null; - if (position < 0) + if (position < 0) { return; + } slot = slots[position]; diff --git a/common/buildcraft/transport/network/PacketFluidUpdate.java b/common/buildcraft/transport/network/PacketFluidUpdate.java index 115770e2..5526be75 100644 --- a/common/buildcraft/transport/network/PacketFluidUpdate.java +++ b/common/buildcraft/transport/network/PacketFluidUpdate.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.transport.network; import buildcraft.core.network.PacketCoordinates; @@ -5,13 +13,16 @@ import buildcraft.core.network.PacketIds; import buildcraft.core.proxy.CoreProxy; import buildcraft.transport.PipeTransportFluids; import buildcraft.transport.TileGenericPipe; +import io.netty.buffer.ByteBuf; + import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.util.BitSet; + import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; public class PacketFluidUpdate extends PacketCoordinates { @@ -37,14 +48,14 @@ public class PacketFluidUpdate extends PacketCoordinates { } @Override - public void readData(DataInputStream data) throws IOException { + public void readData(ByteBuf data) { super.readData(data); World world = CoreProxy.proxy.getClientWorld(); if (!world.blockExists(posX, posY, posZ)) return; - TileEntity entity = world.getBlockTileEntity(posX, posY, posZ); + TileEntity entity = world.getTileEntity(posX, posY, posZ); if (!(entity instanceof TileGenericPipe)) return; @@ -61,7 +72,7 @@ public class PacketFluidUpdate extends PacketCoordinates { colorRenderCache = transLiq.colorRenderCache; byte[] dBytes = new byte[2]; - data.read(dBytes); + data.readBytes(dBytes); delta = fromByteArray(dBytes); // System.out.printf("read %d, %d, %d = %s, %s%n", posX, posY, posZ, Arrays.toString(dBytes), delta); @@ -82,12 +93,12 @@ public class PacketFluidUpdate extends PacketCoordinates { } @Override - public void writeData(DataOutputStream data) throws IOException { + public void writeData(ByteBuf data) { super.writeData(data); byte[] dBytes = toByteArray(delta); // System.out.printf("write %d, %d, %d = %s, %s%n", posX, posY, posZ, Arrays.toString(dBytes), delta); - data.write(dBytes); + data.writeBytes(dBytes); for (ForgeDirection dir : ForgeDirection.values()) { FluidStack liquid = renderCache[dir.ordinal()]; diff --git a/common/buildcraft/transport/network/PacketGateExpansionMap.java b/common/buildcraft/transport/network/PacketGateExpansionMap.java index 4f390f6d..7dc3b1b8 100644 --- a/common/buildcraft/transport/network/PacketGateExpansionMap.java +++ b/common/buildcraft/transport/network/PacketGateExpansionMap.java @@ -1,10 +1,23 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.transport.network; import buildcraft.api.gates.GateExpansions; import buildcraft.core.network.BuildCraftPacket; import buildcraft.core.network.PacketIds; +import buildcraft.core.utils.Utils; + import com.google.common.collect.BiMap; import com.google.common.collect.HashBiMap; + +import io.netty.buffer.ByteBuf; + import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; @@ -16,22 +29,22 @@ public class PacketGateExpansionMap extends BuildCraftPacket { } @Override - public void writeData(DataOutputStream data) throws IOException { + public void writeData(ByteBuf data) { BiMap map = GateExpansions.getServerMap(); data.writeByte(map.size()); for (Map.Entry entry : map.entrySet()) { data.writeByte(entry.getKey()); - data.writeUTF(entry.getValue()); + Utils.writeUTF(data, entry.getValue()); } } @Override - public void readData(DataInputStream data) throws IOException { + public void readData(ByteBuf data) { int numEntries = data.readByte(); BiMap map = HashBiMap.create(numEntries); for (int i = 0; i < numEntries; i++) { byte id = data.readByte(); - String identifier = data.readUTF(); + String identifier = Utils.readUTF(data); map.put(id, identifier); } GateExpansions.setClientMap(map); diff --git a/common/buildcraft/transport/network/PacketHandlerTransport.java b/common/buildcraft/transport/network/PacketHandlerTransport.java index 75e3d47e..43c1d90b 100644 --- a/common/buildcraft/transport/network/PacketHandlerTransport.java +++ b/common/buildcraft/transport/network/PacketHandlerTransport.java @@ -1,115 +1,118 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.transport.network; +import buildcraft.core.network.BuildCraftChannelHandler; +import buildcraft.core.network.BuildCraftPacket; import buildcraft.core.network.PacketCoordinates; import buildcraft.core.network.PacketIds; import buildcraft.core.network.PacketSlotChange; import buildcraft.core.network.PacketUpdate; +import buildcraft.core.proxy.CoreProxy; +import buildcraft.core.utils.Utils; import buildcraft.transport.PipeTransportItems; import buildcraft.transport.PipeTransportPower; import buildcraft.transport.TileGenericPipe; import buildcraft.transport.gui.ContainerGateInterface; import buildcraft.transport.pipes.PipeItemsDiamond; import buildcraft.transport.pipes.PipeItemsEmerald; -import cpw.mods.fml.common.network.IPacketHandler; -import cpw.mods.fml.common.network.Player; +import cpw.mods.fml.common.network.FMLOutboundHandler; +import cpw.mods.fml.common.network.NetworkRegistry; +import io.netty.buffer.ByteBuf; +import io.netty.channel.ChannelHandlerContext; + import java.io.ByteArrayInputStream; import java.io.DataInputStream; + +import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.inventory.Container; -import net.minecraft.network.INetworkManager; -import net.minecraft.network.packet.Packet250CustomPayload; +import net.minecraft.network.INetHandler; +import net.minecraft.network.NetHandlerPlayServer; +import net.minecraft.network.play.INetHandlerPlayServer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; -public class PacketHandlerTransport implements IPacketHandler { +public class PacketHandlerTransport extends BuildCraftChannelHandler { + /** + * TODO: A lot of this is based on the player to retrieve the world. + * Passing a dimension id would be more appropriate. More generally, it + * seems like a lot of these packets could be replaced with tile-based + * RPCs. + */ @Override - public void onPacketData(INetworkManager manager, Packet250CustomPayload packet2, Player player) { - DataInputStream data = new DataInputStream(new ByteArrayInputStream(packet2.data)); + public void decodeInto(ChannelHandlerContext ctx, ByteBuf data, BuildCraftPacket packet) { + super.decodeInto(ctx, data, packet); try { - // NetClientHandler net = (NetClientHandler) network.getNetHandler(); + INetHandler netHandler = ctx.channel().attr(NetworkRegistry.NET_HANDLER).get(); + EntityPlayer player = Utils.getPlayerFromNetHandler(netHandler); - int packetID = data.read(); + int packetID = packet.getID(); - PacketUpdate packet = new PacketUpdate(); switch (packetID) { case PacketIds.PIPE_POWER: - PacketPowerUpdate packetPower = new PacketPowerUpdate(); - packetPower.readData(data); - onPacketPower((EntityPlayer) player, packetPower); + onPacketPower(player, (PacketPowerUpdate) packet); break; case PacketIds.PIPE_LIQUID: - PacketFluidUpdate packetFluid = new PacketFluidUpdate(); - packetFluid.readData(data); + // action will have happened already at read time break; case PacketIds.PIPE_TRAVELER: { - PacketPipeTransportTraveler pkt = new PacketPipeTransportTraveler(); - pkt.readData(data); - onPipeTravelerUpdate((EntityPlayer) player, pkt); + onPipeTravelerUpdate(player, (PacketPipeTransportTraveler) packet); break; } case PacketIds.GATE_ACTIONS: - packet.readData(data); - onGateActions((EntityPlayer) player, packet); + onGateActions(player, (PacketUpdate) packet); break; case PacketIds.GATE_TRIGGERS: - packet.readData(data); - onGateTriggers((EntityPlayer) player, packet); + onGateTriggers(player, (PacketUpdate) packet); break; case PacketIds.GATE_SELECTION: - packet.readData(data); - onGateSelection((EntityPlayer) player, packet); + onGateSelection(player, (PacketUpdate) packet); break; case PacketIds.PIPE_ITEMSTACK: { - PacketPipeTransportItemStack pkt = new PacketPipeTransportItemStack(); - pkt.readData(data); + // action will have happened already at read time break; } case PacketIds.PIPE_GATE_EXPANSION_MAP: { - PacketGateExpansionMap pkt = new PacketGateExpansionMap(); - pkt.readData(data); + // action will have happened already at read time break; } /** * SERVER SIDE * */ - case PacketIds.DIAMOND_PIPE_SELECT: { - PacketSlotChange packet1 = new PacketSlotChange(); - packet1.readData(data); - onDiamondPipeSelect((EntityPlayer) player, packet1); + case PacketIds.DIAMOND_PIPE_SELECT: { + onDiamondPipeSelect(player, (PacketSlotChange) packet); break; } - case PacketIds.EMERALD_PIPE_SELECT: { - PacketSlotChange packet1 = new PacketSlotChange(); - packet1.readData(data); - onEmeraldPipeSelect((EntityPlayer) player, packet1); + case PacketIds.EMERALD_PIPE_SELECT: { + onEmeraldPipeSelect(player, (PacketSlotChange) packet); break; } - case PacketIds.GATE_REQUEST_INIT: - PacketCoordinates packetU = new PacketCoordinates(); - packetU.readData(data); - onGateInitRequest((EntityPlayer) player, packetU); + case PacketIds.GATE_REQUEST_INIT: + onGateInitRequest(player, (PacketCoordinates) packet); break; case PacketIds.GATE_REQUEST_SELECTION: - PacketCoordinates packetS = new PacketCoordinates(); - packetS.readData(data); - onGateSelectionRequest((EntityPlayerMP) player, packetS); + onGateSelectionRequest(player, (PacketCoordinates) packet); break; case PacketIds.GATE_SELECTION_CHANGE: - PacketUpdate packet3 = new PacketUpdate(); - packet3.readData(data); - onGateSelectionChange((EntityPlayerMP) player, packet3); + onGateSelectionChange(player, (PacketUpdate) packet); break; case PacketIds.PIPE_ITEMSTACK_REQUEST: { - PacketPipeTransportItemStackRequest pkt = new PacketPipeTransportItemStackRequest(player); - pkt.readData(data); + ((PacketPipeTransportItemStackRequest) packet).sendDataToPlayer(player); break; } } @@ -172,7 +175,7 @@ public class PacketHandlerTransport implements IPacketHandler { if (!world.blockExists(packet.posX, packet.posY, packet.posZ)) return; - TileEntity entity = world.getBlockTileEntity(packet.posX, packet.posY, packet.posZ); + TileEntity entity = world.getTileEntity(packet.posX, packet.posY, packet.posZ); if (!(entity instanceof TileGenericPipe)) return; @@ -196,7 +199,7 @@ public class PacketHandlerTransport implements IPacketHandler { if (!world.blockExists(packetPower.posX, packetPower.posY, packetPower.posZ)) return; - TileEntity entity = world.getBlockTileEntity(packetPower.posX, packetPower.posY, packetPower.posZ); + TileEntity entity = world.getTileEntity(packetPower.posX, packetPower.posY, packetPower.posZ); if (!(entity instanceof TileGenericPipe)) return; @@ -221,8 +224,9 @@ public class PacketHandlerTransport implements IPacketHandler { * @param packet */ private void onGateSelectionChange(EntityPlayer playerEntity, PacketUpdate packet) { - if (!(playerEntity.openContainer instanceof ContainerGateInterface)) + if (!(playerEntity.openContainer instanceof ContainerGateInterface)) { return; + } ((ContainerGateInterface) playerEntity.openContainer).setSelection(packet, true); } @@ -266,7 +270,7 @@ public class PacketHandlerTransport implements IPacketHandler { if (!world.blockExists(x, y, z)) return null; - TileEntity tile = world.getBlockTileEntity(x, y, z); + TileEntity tile = world.getTileEntity(x, y, z); if (!(tile instanceof TileGenericPipe)) return null; diff --git a/common/buildcraft/transport/network/PacketPipeTransportItemStack.java b/common/buildcraft/transport/network/PacketPipeTransportItemStack.java index b8217be3..94d6f08d 100644 --- a/common/buildcraft/transport/network/PacketPipeTransportItemStack.java +++ b/common/buildcraft/transport/network/PacketPipeTransportItemStack.java @@ -1,13 +1,25 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.transport.network; import buildcraft.core.network.BuildCraftPacket; import buildcraft.core.network.PacketIds; +import buildcraft.core.utils.Utils; import buildcraft.transport.TravelingItem; +import io.netty.buffer.ByteBuf; + import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; + import net.minecraft.item.ItemStack; -import net.minecraft.network.packet.Packet; +import net.minecraft.network.Packet; public class PacketPipeTransportItemStack extends BuildCraftPacket { @@ -23,15 +35,15 @@ public class PacketPipeTransportItemStack extends BuildCraftPacket { } @Override - public void writeData(DataOutputStream data) throws IOException { + public void writeData(ByteBuf data) { data.writeInt(entityId); - Packet.writeItemStack(stack, data); + Utils.writeStack(data, stack); } @Override - public void readData(DataInputStream data) throws IOException { + public void readData(ByteBuf data) { this.entityId = data.readInt(); - stack = Packet.readItemStack(data); + stack = Utils.readStack(data); TravelingItem item = TravelingItem.clientCache.get(entityId); if (item != null) item.setItemStack(stack); diff --git a/common/buildcraft/transport/network/PacketPipeTransportItemStackRequest.java b/common/buildcraft/transport/network/PacketPipeTransportItemStackRequest.java index c4b12f95..52fe82b3 100644 --- a/common/buildcraft/transport/network/PacketPipeTransportItemStackRequest.java +++ b/common/buildcraft/transport/network/PacketPipeTransportItemStackRequest.java @@ -1,42 +1,59 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.transport.network; +import buildcraft.BuildCraftTransport; import buildcraft.core.network.BuildCraftPacket; import buildcraft.core.network.PacketIds; import buildcraft.transport.TravelingItem; -import cpw.mods.fml.common.network.PacketDispatcher; -import cpw.mods.fml.common.network.Player; +import io.netty.buffer.ByteBuf; + import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; +import net.minecraft.entity.player.EntityPlayer; + public class PacketPipeTransportItemStackRequest extends BuildCraftPacket { public int travelerID; - public Player player; - - public PacketPipeTransportItemStackRequest(Player player) { - this.player = player; + TravelingItem item; + + public PacketPipeTransportItemStackRequest() { + } - + public PacketPipeTransportItemStackRequest(int travelerID) { this.travelerID = travelerID; } @Override - public void writeData(DataOutputStream data) throws IOException { + public void writeData(ByteBuf data) { data.writeShort(travelerID); } @Override - public void readData(DataInputStream data) throws IOException { + public void readData(ByteBuf data) { travelerID = data.readShort(); TravelingItem.TravelingItemCache cache = TravelingItem.serverCache; - TravelingItem item = cache.get(travelerID); - if (item == null) - return; - PacketDispatcher.sendPacketToPlayer(new PacketPipeTransportItemStack(travelerID, item.getItemStack()).getPacket(), player); + item = cache.get(travelerID); } + public void sendDataToPlayer (EntityPlayer player) { + if (item != null) { + BuildCraftTransport.instance.sendToPlayer( + player, + new PacketPipeTransportItemStack(travelerID, item + .getItemStack())); + } + } + @Override public int getID() { return PacketIds.PIPE_ITEMSTACK_REQUEST; diff --git a/common/buildcraft/transport/network/PacketPipeTransportTraveler.java b/common/buildcraft/transport/network/PacketPipeTransportTraveler.java index c5eae053..ba0b162d 100644 --- a/common/buildcraft/transport/network/PacketPipeTransportTraveler.java +++ b/common/buildcraft/transport/network/PacketPipeTransportTraveler.java @@ -1,14 +1,25 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.transport.network; import buildcraft.core.network.BuildCraftPacket; import buildcraft.core.network.PacketIds; import buildcraft.core.utils.EnumColor; import buildcraft.transport.TravelingItem; +import io.netty.buffer.ByteBuf; + import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; + import net.minecraft.util.MathHelper; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; public class PacketPipeTransportTraveler extends BuildCraftPacket { @@ -35,7 +46,7 @@ public class PacketPipeTransportTraveler extends BuildCraftPacket { } @Override - public void writeData(DataOutputStream data) throws IOException { + public void writeData(ByteBuf data) { data.writeFloat((float) item.xCoord); data.writeFloat((float) item.yCoord); data.writeFloat((float) item.zCoord); @@ -53,7 +64,7 @@ public class PacketPipeTransportTraveler extends BuildCraftPacket { } @Override - public void readData(DataInputStream data) throws IOException { + public void readData(ByteBuf data) { this.itemX = data.readFloat(); this.itemY = data.readFloat(); this.itemZ = data.readFloat(); diff --git a/common/buildcraft/transport/network/PacketPowerUpdate.java b/common/buildcraft/transport/network/PacketPowerUpdate.java index 64f86e35..630ccaf9 100644 --- a/common/buildcraft/transport/network/PacketPowerUpdate.java +++ b/common/buildcraft/transport/network/PacketPowerUpdate.java @@ -1,7 +1,17 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.transport.network; import buildcraft.core.network.PacketCoordinates; import buildcraft.core.network.PacketIds; +import io.netty.buffer.ByteBuf; + import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; @@ -19,9 +29,9 @@ public class PacketPowerUpdate extends PacketCoordinates { } @Override - public void readData(DataInputStream data) throws IOException { - displayPower = new short[] { 0, 0, 0, 0, 0, 0 }; + public void readData(ByteBuf data) { super.readData(data); + displayPower = new short[] { 0, 0, 0, 0, 0, 0 }; overload = data.readBoolean(); for (int i = 0; i < displayPower.length; i++) { displayPower[i] = data.readByte(); @@ -29,7 +39,7 @@ public class PacketPowerUpdate extends PacketCoordinates { } @Override - public void writeData(DataOutputStream data) throws IOException { + public void writeData(ByteBuf data) { super.writeData(data); data.writeBoolean(overload); for (int i = 0; i < displayPower.length; i++) { diff --git a/common/buildcraft/transport/network/TransportConnectionHandler.java b/common/buildcraft/transport/network/TransportConnectionHandler.java deleted file mode 100644 index 65ec35f0..00000000 --- a/common/buildcraft/transport/network/TransportConnectionHandler.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) SpaceToad, 2011-2012 - * http://www.mod-buildcraft.com - * - * BuildCraft is distributed under the terms of the Minecraft Mod Public - * License 1.0, or MMPL. Please check the contents of the license located in - * http://www.mod-buildcraft.com/MMPL-1.0.txt - */ -package buildcraft.transport.network; - -import cpw.mods.fml.common.network.IConnectionHandler; -import cpw.mods.fml.common.network.PacketDispatcher; -import cpw.mods.fml.common.network.Player; -import net.minecraft.network.INetworkManager; -import net.minecraft.network.NetLoginHandler; -import net.minecraft.network.packet.NetHandler; -import net.minecraft.network.packet.Packet1Login; -import net.minecraft.server.MinecraftServer; - -/** - * - * @author CovertJaguar - */ -public class TransportConnectionHandler implements IConnectionHandler { - - @Override - public void playerLoggedIn(Player player, NetHandler netHandler, INetworkManager manager) { - PacketGateExpansionMap pkt = new PacketGateExpansionMap(); - PacketDispatcher.sendPacketToPlayer(pkt.getPacket(), player); - } - - @Override - public String connectionReceived(NetLoginHandler netHandler, INetworkManager manager) { - return null; - } - - @Override - public void connectionOpened(NetHandler netClientHandler, String server, int port, INetworkManager manager) { - } - - @Override - public void connectionOpened(NetHandler netClientHandler, MinecraftServer server, INetworkManager manager) { - } - - @Override - public void connectionClosed(INetworkManager manager) { - } - - @Override - public void clientLoggedIn(NetHandler clientHandler, INetworkManager manager, Packet1Login login) { - } -} diff --git a/common/buildcraft/transport/pipes/PipeFluidsCobblestone.java b/common/buildcraft/transport/pipes/PipeFluidsCobblestone.java index 6c43e2ab..2b8f1a1a 100644 --- a/common/buildcraft/transport/pipes/PipeFluidsCobblestone.java +++ b/common/buildcraft/transport/pipes/PipeFluidsCobblestone.java @@ -1,9 +1,10 @@ /** - * BuildCraft is open-source. It is distributed under the terms of the - * BuildCraft Open Source License. It grants rights to read, modify, compile or - * run the code. It does *NOT* grant the right to redistribute this software or - * its modifications in any form, binary or source, except if expressively - * granted by the copyright holder. + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.transport.pipes; @@ -14,12 +15,13 @@ import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeTransportFluids; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import net.minecraftforge.common.ForgeDirection; +import net.minecraft.item.Item; +import net.minecraftforge.common.util.ForgeDirection; public class PipeFluidsCobblestone extends Pipe { - public PipeFluidsCobblestone(int itemID) { - super(new PipeTransportFluids(), itemID); + public PipeFluidsCobblestone(Item item) { + super(new PipeTransportFluids(), item); } @Override diff --git a/common/buildcraft/transport/pipes/PipeFluidsEmerald.java b/common/buildcraft/transport/pipes/PipeFluidsEmerald.java index 78ee7ae4..06353d75 100644 --- a/common/buildcraft/transport/pipes/PipeFluidsEmerald.java +++ b/common/buildcraft/transport/pipes/PipeFluidsEmerald.java @@ -1,22 +1,20 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.transport.pipes; +import net.minecraft.item.Item; import buildcraft.transport.PipeIconProvider; -/** - * - * @author CovertJaguar - */ public class PipeFluidsEmerald extends PipeFluidsWood { - public PipeFluidsEmerald(int itemID) { - super(itemID); + public PipeFluidsEmerald(Item item) { + super(item); standardIconIndex = PipeIconProvider.TYPE.PipeFluidsEmerald_Standard.ordinal(); solidIconIndex = PipeIconProvider.TYPE.PipeAllEmerald_Solid.ordinal(); diff --git a/common/buildcraft/transport/pipes/PipeFluidsGold.java b/common/buildcraft/transport/pipes/PipeFluidsGold.java index f5c87bf2..d05680b0 100644 --- a/common/buildcraft/transport/pipes/PipeFluidsGold.java +++ b/common/buildcraft/transport/pipes/PipeFluidsGold.java @@ -1,9 +1,10 @@ /** - * BuildCraft is open-source. It is distributed under the terms of the - * BuildCraft Open Source License. It grants rights to read, modify, compile or - * run the code. It does *NOT* grant the right to redistribute this software or - * its modifications in any form, binary or source, except if expressively - * granted by the copyright holder. + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.transport.pipes; @@ -14,12 +15,13 @@ import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeTransportFluids; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import net.minecraftforge.common.ForgeDirection; +import net.minecraft.item.Item; +import net.minecraftforge.common.util.ForgeDirection; public class PipeFluidsGold extends Pipe { - public PipeFluidsGold(int itemID) { - super(new PipeTransportFluids(), itemID); + public PipeFluidsGold(Item item) { + super(new PipeTransportFluids(), item); transport.flowRate = 40; transport.travelDelay = 4; diff --git a/common/buildcraft/transport/pipes/PipeFluidsIron.java b/common/buildcraft/transport/pipes/PipeFluidsIron.java index f7738cd4..1e334ee1 100644 --- a/common/buildcraft/transport/pipes/PipeFluidsIron.java +++ b/common/buildcraft/transport/pipes/PipeFluidsIron.java @@ -1,9 +1,10 @@ /** - * BuildCraft is open-source. It is distributed under the terms of the - * BuildCraft Open Source License. It grants rights to read, modify, compile or - * run the code. It does *NOT* grant the right to redistribute this software or - * its modifications in any form, binary or source, except if expressively - * granted by the copyright holder. + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.transport.pipes; @@ -21,8 +22,9 @@ import buildcraft.transport.triggers.ActionPipeDirection; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.IFluidHandler; public class PipeFluidsIron extends Pipe { @@ -46,8 +48,8 @@ public class PipeFluidsIron extends Pipe { } }; - public PipeFluidsIron(int itemID) { - super(new PipeTransportFluids(), itemID); + public PipeFluidsIron(Item item) { + super(new PipeTransportFluids(), item); } @Override diff --git a/common/buildcraft/transport/pipes/PipeFluidsSandstone.java b/common/buildcraft/transport/pipes/PipeFluidsSandstone.java index 1483426c..1a98b5fe 100644 --- a/common/buildcraft/transport/pipes/PipeFluidsSandstone.java +++ b/common/buildcraft/transport/pipes/PipeFluidsSandstone.java @@ -1,14 +1,16 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.transport.pipes; +import net.minecraft.item.Item; import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; import buildcraft.BuildCraftTransport; import buildcraft.api.core.IIconProvider; @@ -23,8 +25,8 @@ import cpw.mods.fml.relauncher.SideOnly; public class PipeFluidsSandstone extends Pipe implements IPipeTransportFluidsHook, IPipeConnectionForced { - public PipeFluidsSandstone(int itemID) { - super(new PipeTransportFluids(), itemID); + public PipeFluidsSandstone(Item item) { + super(new PipeTransportFluids(), item); } @Override diff --git a/common/buildcraft/transport/pipes/PipeFluidsStone.java b/common/buildcraft/transport/pipes/PipeFluidsStone.java index 77324206..d7c740b0 100644 --- a/common/buildcraft/transport/pipes/PipeFluidsStone.java +++ b/common/buildcraft/transport/pipes/PipeFluidsStone.java @@ -1,9 +1,10 @@ /** - * BuildCraft is open-source. It is distributed under the terms of the - * BuildCraft Open Source License. It grants rights to read, modify, compile or - * run the code. It does *NOT* grant the right to redistribute this software or - * its modifications in any form, binary or source, except if expressively - * granted by the copyright holder. + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.transport.pipes; @@ -14,12 +15,13 @@ import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeTransportFluids; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import net.minecraftforge.common.ForgeDirection; +import net.minecraft.item.Item; +import net.minecraftforge.common.util.ForgeDirection; public class PipeFluidsStone extends Pipe { - public PipeFluidsStone(int itemID) { - super(new PipeTransportFluids(), itemID); + public PipeFluidsStone(Item item) { + super(new PipeTransportFluids(), item); // ((PipeTransportFluids) transport).flowRate = 40; } diff --git a/common/buildcraft/transport/pipes/PipeFluidsVoid.java b/common/buildcraft/transport/pipes/PipeFluidsVoid.java index 02ac8a0b..24e8f3d3 100644 --- a/common/buildcraft/transport/pipes/PipeFluidsVoid.java +++ b/common/buildcraft/transport/pipes/PipeFluidsVoid.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.transport.pipes; @@ -15,13 +16,14 @@ import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeTransportFluids; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import net.minecraftforge.common.ForgeDirection; +import net.minecraft.item.Item; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; public class PipeFluidsVoid extends Pipe implements IPipeTransportFluidsHook { - public PipeFluidsVoid(int itemID) { - super(new PipeTransportFluids(), itemID); + public PipeFluidsVoid(Item item) { + super(new PipeTransportFluids(), item); } @Override diff --git a/common/buildcraft/transport/pipes/PipeFluidsWood.java b/common/buildcraft/transport/pipes/PipeFluidsWood.java index 47f93bff..0f0fd24c 100644 --- a/common/buildcraft/transport/pipes/PipeFluidsWood.java +++ b/common/buildcraft/transport/pipes/PipeFluidsWood.java @@ -1,9 +1,10 @@ /** - * BuildCraft is open-source. It is distributed under the terms of the - * BuildCraft Open Source License. It grants rights to read, modify, compile or - * run the code. It does *NOT* grant the right to redistribute this software or - * its modifications in any form, binary or source, except if expressively - * granted by the copyright holder. + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.transport.pipes; @@ -22,9 +23,10 @@ import buildcraft.transport.PipeTransportFluids; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidHandler; @@ -45,14 +47,14 @@ public class PipeFluidsWood extends Pipe implements IPowerR return false; if (!(tile instanceof IFluidHandler)) return false; - if (!PipeManager.canExtractFluids(pipe, tile.worldObj, tile.xCoord, tile.yCoord, tile.zCoord)) + if (!PipeManager.canExtractFluids(pipe, tile.getWorldObj (), tile.xCoord, tile.yCoord, tile.zCoord)) return false; return true; } }; - public PipeFluidsWood(int itemID) { - super(new PipeTransportFluids(), itemID); + public PipeFluidsWood(Item item) { + super(new PipeTransportFluids(), item); powerHandler = new PowerHandler(this, Type.MACHINE); powerHandler.configure(1, 100, 1, 250); @@ -84,7 +86,7 @@ public class PipeFluidsWood extends Pipe implements IPowerR if (powerHandler.getEnergyStored() <= 0) return; - World w = container.worldObj; + World w = container.getWorld(); int meta = container.getBlockMetadata(); @@ -94,7 +96,7 @@ public class PipeFluidsWood extends Pipe implements IPowerR TileEntity tile = container.getTile(ForgeDirection.getOrientation(meta)); if (tile instanceof IFluidHandler) { - if (!PipeManager.canExtractFluids(this, tile.worldObj, tile.xCoord, tile.yCoord, tile.zCoord)) + if (!PipeManager.canExtractFluids(this, tile.getWorldObj(), tile.xCoord, tile.yCoord, tile.zCoord)) return; if (liquidToExtract <= FluidContainerRegistry.BUCKET_VOLUME) { diff --git a/common/buildcraft/transport/pipes/PipeItemsCobblestone.java b/common/buildcraft/transport/pipes/PipeItemsCobblestone.java index 38c78a81..702c1a0e 100644 --- a/common/buildcraft/transport/pipes/PipeItemsCobblestone.java +++ b/common/buildcraft/transport/pipes/PipeItemsCobblestone.java @@ -1,9 +1,10 @@ /** - * BuildCraft is open-source. It is distributed under the terms of the - * BuildCraft Open Source License. It grants rights to read, modify, compile or - * run the code. It does *NOT* grant the right to redistribute this software or - * its modifications in any form, binary or source, except if expressively - * granted by the copyright holder. + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.transport.pipes; @@ -14,12 +15,13 @@ import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeTransportItems; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import net.minecraftforge.common.ForgeDirection; +import net.minecraft.item.Item; +import net.minecraftforge.common.util.ForgeDirection; public class PipeItemsCobblestone extends Pipe { - public PipeItemsCobblestone(int itemID) { - super(new PipeTransportItems(), itemID); + public PipeItemsCobblestone(Item item) { + super(new PipeTransportItems(), item); } @Override diff --git a/common/buildcraft/transport/pipes/PipeItemsDaizuli.java b/common/buildcraft/transport/pipes/PipeItemsDaizuli.java index f99a8aac..259a348f 100644 --- a/common/buildcraft/transport/pipes/PipeItemsDaizuli.java +++ b/common/buildcraft/transport/pipes/PipeItemsDaizuli.java @@ -1,9 +1,10 @@ /** - * BuildCraft is open-source. It is distributed under the terms of the - * BuildCraft Open Source License. It grants rights to read, modify, compile or - * run the code. It does *NOT* grant the right to redistribute this software or - * its modifications in any form, binary or source, except if expressively - * granted by the copyright holder. + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.transport.pipes; @@ -32,7 +33,7 @@ import net.minecraft.inventory.IInventory; import net.minecraft.item.Item; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; public class PipeItemsDaizuli extends Pipe { @@ -57,8 +58,8 @@ public class PipeItemsDaizuli extends Pipe { } }; - public PipeItemsDaizuli(int itemID) { - super(new PipeTransportItems(), itemID); + public PipeItemsDaizuli(Item item) { + super(new PipeTransportItems(), item); transport.allowBouncing = true; } diff --git a/common/buildcraft/transport/pipes/PipeItemsDiamond.java b/common/buildcraft/transport/pipes/PipeItemsDiamond.java index 21be7f68..122f087f 100644 --- a/common/buildcraft/transport/pipes/PipeItemsDiamond.java +++ b/common/buildcraft/transport/pipes/PipeItemsDiamond.java @@ -1,12 +1,15 @@ /** - * BuildCraft is open-source. It is distributed under the terms of the - * BuildCraft Open Source License. It grants rights to read, modify, compile or - * run the code. It does *NOT* grant the right to redistribute this software or - * its modifications in any form, binary or source, except if expressively - * granted by the copyright holder. + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.transport.pipes; +import io.netty.buffer.ByteBuf; + import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; @@ -15,10 +18,11 @@ import java.util.LinkedList; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; import buildcraft.BuildCraftTransport; import buildcraft.api.core.IIconProvider; import buildcraft.core.GuiIds; @@ -26,6 +30,7 @@ import buildcraft.core.inventory.SimpleInventory; import buildcraft.core.inventory.StackHelper; import buildcraft.core.network.IClientState; import buildcraft.core.proxy.CoreProxy; +import buildcraft.core.utils.Utils; import buildcraft.transport.BlockGenericPipe; import buildcraft.transport.Pipe; import buildcraft.transport.PipeIconProvider; @@ -38,8 +43,8 @@ public class PipeItemsDiamond extends Pipe implements IClien private SimpleInventory filters = new SimpleInventory(54, "Filters", 1); - public PipeItemsDiamond(int itemID) { - super(new PipeTransportItems(), itemID); + public PipeItemsDiamond(Item item) { + super(new PipeTransportItems(), item); } public IInventory getFilters() { @@ -81,12 +86,12 @@ public class PipeItemsDiamond extends Pipe implements IClien @Override public boolean blockActivated(EntityPlayer entityplayer) { - if (entityplayer.getCurrentEquippedItem() != null && entityplayer.getCurrentEquippedItem().itemID < Block.blocksList.length) - if (Block.blocksList[entityplayer.getCurrentEquippedItem().itemID] instanceof BlockGenericPipe) + if (entityplayer.getCurrentEquippedItem() != null) + if (Block.getBlockFromItem(entityplayer.getCurrentEquippedItem().getItem()) instanceof BlockGenericPipe) return false; - if (!CoreProxy.proxy.isRenderWorld(container.worldObj)) { - entityplayer.openGui(BuildCraftTransport.instance, GuiIds.PIPE_DIAMOND, container.worldObj, container.xCoord, container.yCoord, container.zCoord); + if (!container.getWorldObj().isRemote) { + entityplayer.openGui(BuildCraftTransport.instance, GuiIds.PIPE_DIAMOND, container.getWorldObj(), container.xCoord, container.yCoord, container.zCoord); } return true; @@ -137,17 +142,15 @@ public class PipeItemsDiamond extends Pipe implements IClien // ICLIENTSTATE @Override - public void writeData(DataOutputStream data) throws IOException { + public void writeData(ByteBuf data) { NBTTagCompound nbt = new NBTTagCompound(); writeToNBT(nbt); - NBTBase.writeNamedTag(nbt, data); + Utils.writeNBT(data, nbt); } @Override - public void readData(DataInputStream data) throws IOException { - NBTBase nbt = NBTBase.readNamedTag(data); - if (nbt instanceof NBTTagCompound) { - readFromNBT((NBTTagCompound) nbt); - } + public void readData(ByteBuf data) { + NBTTagCompound nbt = Utils.readNBT(data); + readFromNBT(nbt); } } diff --git a/common/buildcraft/transport/pipes/PipeItemsEmerald.java b/common/buildcraft/transport/pipes/PipeItemsEmerald.java index 724dffd0..20b8fca8 100644 --- a/common/buildcraft/transport/pipes/PipeItemsEmerald.java +++ b/common/buildcraft/transport/pipes/PipeItemsEmerald.java @@ -1,12 +1,15 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.transport.pipes; +import io.netty.buffer.ByteBuf; + import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; @@ -14,10 +17,11 @@ import java.io.IOException; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; import buildcraft.BuildCraftTransport; import buildcraft.api.inventory.ISpecialInventory; import buildcraft.core.GuiIds; @@ -74,8 +78,8 @@ public class PipeItemsEmerald extends PipeItemsWood implements IClientState, IGu private final SimpleInventory filters = new SimpleInventory(9, "Filters", 1); private int currentFilter = 0; - public PipeItemsEmerald(int itemID) { - super(itemID); + public PipeItemsEmerald(Item item) { + super(item); standardIconIndex = PipeIconProvider.TYPE.PipeItemsEmerald_Standard.ordinal(); solidIconIndex = PipeIconProvider.TYPE.PipeAllEmerald_Solid.ordinal(); @@ -83,8 +87,8 @@ public class PipeItemsEmerald extends PipeItemsWood implements IClientState, IGu @Override public boolean blockActivated(EntityPlayer entityplayer) { - if (entityplayer.getCurrentEquippedItem() != null && entityplayer.getCurrentEquippedItem().itemID < Block.blocksList.length) { - if (Block.blocksList[entityplayer.getCurrentEquippedItem().itemID] instanceof BlockGenericPipe) { + if (entityplayer.getCurrentEquippedItem() != null) { + if (Block.getBlockFromItem(entityplayer.getCurrentEquippedItem().getItem()) instanceof BlockGenericPipe) { return false; } } @@ -93,8 +97,8 @@ public class PipeItemsEmerald extends PipeItemsWood implements IClientState, IGu return true; } - if (!CoreProxy.proxy.isRenderWorld(container.worldObj)) { - entityplayer.openGui(BuildCraftTransport.instance, GuiIds.PIPE_EMERALD_ITEM, container.worldObj, container.xCoord, container.yCoord, container.zCoord); + if (!container.getWorldObj().isRemote) { + entityplayer.openGui(BuildCraftTransport.instance, GuiIds.PIPE_EMERALD_ITEM, container.getWorldObj(), container.xCoord, container.yCoord, container.zCoord); } return true; @@ -245,18 +249,16 @@ public class PipeItemsEmerald extends PipeItemsWood implements IClientState, IGu // ICLIENTSTATE @Override - public void writeData(DataOutputStream data) throws IOException { + public void writeData(ByteBuf data) { NBTTagCompound nbt = new NBTTagCompound(); writeToNBT(nbt); - NBTBase.writeNamedTag(nbt, data); + Utils.writeNBT(data, nbt); } @Override - public void readData(DataInputStream data) throws IOException { - NBTBase nbt = NBTBase.readNamedTag(data); - if (nbt instanceof NBTTagCompound) { - readFromNBT((NBTTagCompound) nbt); - } + public void readData(ByteBuf data) { + NBTTagCompound nbt = Utils.readNBT(data); + readFromNBT(nbt); } public IInventory getFilters() { @@ -268,12 +270,12 @@ public class PipeItemsEmerald extends PipeItemsWood implements IClientState, IGu } @Override - public void writeGuiData(DataOutputStream data) throws IOException { + public void writeGuiData(ByteBuf data) { data.writeByte(stateController.getCurrentState()); } @Override - public void readGuiData(DataInputStream data, EntityPlayer sender) throws IOException { + public void readGuiData(ByteBuf data, EntityPlayer sender) { stateController.setCurrentState(data.readByte()); } } diff --git a/common/buildcraft/transport/pipes/PipeItemsEmzuli.java b/common/buildcraft/transport/pipes/PipeItemsEmzuli.java index 65f74d78..cc002882 100644 --- a/common/buildcraft/transport/pipes/PipeItemsEmzuli.java +++ b/common/buildcraft/transport/pipes/PipeItemsEmzuli.java @@ -1,13 +1,15 @@ -/* - * Copyright (c) SpaceToad, 2011-2012 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * + * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.transport.pipes; +import io.netty.buffer.ByteBuf; + import java.util.BitSet; import java.util.LinkedList; import java.util.Map; @@ -16,9 +18,10 @@ import java.util.Map.Entry; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; import buildcraft.BuildCraftTransport; import buildcraft.api.gates.IAction; import buildcraft.api.inventory.ISpecialInventory; @@ -32,14 +35,11 @@ import buildcraft.transport.BlockGenericPipe; import buildcraft.transport.PipeIconProvider; import buildcraft.transport.TravelingItem; import buildcraft.transport.triggers.ActionExtractionPreset; + import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; -/** - * - * @author SandGrainOne - */ public class PipeItemsEmzuli extends PipeItemsWood implements IGuiReturnHandler { public final byte[] slotColors = new byte[4]; @@ -48,8 +48,8 @@ public class PipeItemsEmzuli extends PipeItemsWood implements IGuiReturnHandler private final int filterCount = filters.getSizeInventory(); private int currentFilter = 0; - public PipeItemsEmzuli(int itemID) { - super(itemID); + public PipeItemsEmzuli(Item item) { + super(item); standardIconIndex = PipeIconProvider.TYPE.PipeItemsEmzuli_Standard.ordinal(); solidIconIndex = PipeIconProvider.TYPE.PipeAllEmzuli_Solid.ordinal(); @@ -57,8 +57,8 @@ public class PipeItemsEmzuli extends PipeItemsWood implements IGuiReturnHandler @Override public boolean blockActivated(EntityPlayer entityplayer) { - if (entityplayer.getCurrentEquippedItem() != null && entityplayer.getCurrentEquippedItem().itemID < Block.blocksList.length) { - if (Block.blocksList[entityplayer.getCurrentEquippedItem().itemID] instanceof BlockGenericPipe) { + if (entityplayer.getCurrentEquippedItem() != null) { + if (Block.getBlockFromItem(entityplayer.getCurrentEquippedItem().getItem()) instanceof BlockGenericPipe) { return false; } } @@ -67,8 +67,8 @@ public class PipeItemsEmzuli extends PipeItemsWood implements IGuiReturnHandler return true; } - if (!CoreProxy.proxy.isRenderWorld(container.worldObj)) { - entityplayer.openGui(BuildCraftTransport.instance, GuiIds.PIPE_LOGEMERALD_ITEM, container.worldObj, container.xCoord, container.yCoord, container.zCoord); + if (!container.getWorldObj().isRemote) { + entityplayer.openGui(BuildCraftTransport.instance, GuiIds.PIPE_LOGEMERALD_ITEM, container.getWorldObj(), container.xCoord, container.yCoord, container.zCoord); } return true; @@ -234,11 +234,11 @@ public class PipeItemsEmzuli extends PipeItemsWood implements IGuiReturnHandler } @Override - public void writeGuiData(DataOutputStream paramDataOutputStream) throws IOException { + public void writeGuiData(ByteBuf paramDataOutputStream) { } @Override - public void readGuiData(DataInputStream data, EntityPlayer paramEntityPlayer) throws IOException { + public void readGuiData(ByteBuf data, EntityPlayer paramEntityPlayer) { byte slot = data.readByte(); slotColors[slot] = data.readByte(); } diff --git a/common/buildcraft/transport/pipes/PipeItemsGold.java b/common/buildcraft/transport/pipes/PipeItemsGold.java index a1ce5994..9f9c785e 100644 --- a/common/buildcraft/transport/pipes/PipeItemsGold.java +++ b/common/buildcraft/transport/pipes/PipeItemsGold.java @@ -1,9 +1,10 @@ /** - * BuildCraft is open-source. It is distributed under the terms of the - * BuildCraft Open Source License. It grants rights to read, modify, compile or - * run the code. It does *NOT* grant the right to redistribute this software or - * its modifications in any form, binary or source, except if expressively - * granted by the copyright holder. + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.transport.pipes; @@ -18,12 +19,13 @@ import buildcraft.transport.TravelingItem; import buildcraft.transport.pipes.events.PipeEventItem; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import net.minecraftforge.common.ForgeDirection; +import net.minecraft.item.Item; +import net.minecraftforge.common.util.ForgeDirection; public class PipeItemsGold extends Pipe { - public PipeItemsGold(int itemID) { - super(new PipeTransportItems(), itemID); + public PipeItemsGold(Item item) { + super(new PipeTransportItems(), item); } @Override diff --git a/common/buildcraft/transport/pipes/PipeItemsIron.java b/common/buildcraft/transport/pipes/PipeItemsIron.java index 2b884897..c8f89b33 100644 --- a/common/buildcraft/transport/pipes/PipeItemsIron.java +++ b/common/buildcraft/transport/pipes/PipeItemsIron.java @@ -1,9 +1,10 @@ /** - * BuildCraft is open-source. It is distributed under the terms of the - * BuildCraft Open Source License. It grants rights to read, modify, compile or - * run the code. It does *NOT* grant the right to redistribute this software or - * its modifications in any form, binary or source, except if expressively - * granted by the copyright holder. + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.transport.pipes; @@ -17,12 +18,15 @@ import buildcraft.transport.TileGenericPipe; import buildcraft.transport.triggers.ActionPipeDirection; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; + import java.util.LinkedList; import java.util.Map; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; +import net.minecraft.item.Item; import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; public class PipeItemsIron extends Pipe { @@ -45,8 +49,8 @@ public class PipeItemsIron extends Pipe { } }; - public PipeItemsIron(int itemID) { - super(new PipeTransportItems(), itemID); + public PipeItemsIron(Item item) { + super(new PipeTransportItems(), item); transport.allowBouncing = true; } diff --git a/common/buildcraft/transport/pipes/PipeItemsLapis.java b/common/buildcraft/transport/pipes/PipeItemsLapis.java index 6e7d5352..65e7c9d6 100644 --- a/common/buildcraft/transport/pipes/PipeItemsLapis.java +++ b/common/buildcraft/transport/pipes/PipeItemsLapis.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.transport.pipes; @@ -27,12 +28,12 @@ import java.util.Map; import java.util.Map.Entry; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; public class PipeItemsLapis extends Pipe { - public PipeItemsLapis(int itemID) { - super(new PipeTransportItems(), itemID); + public PipeItemsLapis(Item item) { + super(new PipeTransportItems(), item); } @Override @@ -71,7 +72,7 @@ public class PipeItemsLapis extends Pipe { public void setColor(EnumColor color) { if (color.ordinal() != container.getBlockMetadata()) { - container.worldObj.setBlockMetadataWithNotify(container.xCoord, container.yCoord, container.zCoord, color.ordinal(), 3); + container.getWorldObj().setBlockMetadataWithNotify(container.xCoord, container.yCoord, container.zCoord, color.ordinal(), 3); container.scheduleRenderUpdate(); } } diff --git a/common/buildcraft/transport/pipes/PipeItemsObsidian.java b/common/buildcraft/transport/pipes/PipeItemsObsidian.java index a48de240..7c89d8f5 100644 --- a/common/buildcraft/transport/pipes/PipeItemsObsidian.java +++ b/common/buildcraft/transport/pipes/PipeItemsObsidian.java @@ -1,9 +1,10 @@ /** - * BuildCraft is open-source. It is distributed under the terms of the - * BuildCraft Open Source License. It grants rights to read, modify, compile or - * run the code. It does *NOT* grant the right to redistribute this software or - * its modifications in any form, binary or source, except if expressively - * granted by the copyright holder. + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.transport.pipes; @@ -27,16 +28,19 @@ import buildcraft.transport.pipes.events.PipeEventItem; import buildcraft.transport.utils.TransportUtils; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; + import java.util.Arrays; import java.util.List; + import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.EntityMinecartChest; import net.minecraft.entity.projectile.EntityArrow; +import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.AxisAlignedBB; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; public class PipeItemsObsidian extends Pipe implements IPowerReceptor { @@ -45,8 +49,8 @@ public class PipeItemsObsidian extends Pipe implements IPowe private int[] entitiesDropped; private int entitiesDroppedIndex = 0; - public PipeItemsObsidian(int itemID) { - super(new PipeTransportItems(), itemID); + public PipeItemsObsidian(Item item) { + super(new PipeTransportItems(), item); entitiesDropped = new int[32]; Arrays.fill(entitiesDropped, -1); @@ -159,7 +163,7 @@ public class PipeItemsObsidian extends Pipe implements IPowe return false; @SuppressWarnings("rawtypes") - List discoveredEntities = (List) container.worldObj.getEntitiesWithinAABB(Entity.class, box); + List discoveredEntities = (List) container.getWorldObj().getEntitiesWithinAABB(Entity.class, box); for (Entity entity : discoveredEntities) { if (canSuck(entity, distance)) { @@ -175,9 +179,9 @@ public class PipeItemsObsidian extends Pipe implements IPowe ItemStack stack = trans.remove(StackFilter.ALL, openOrientation, false); if (stack != null && powerHandler.useEnergy(1, 1, true) == 1) { trans.remove(StackFilter.ALL, openOrientation, true); - EntityItem entityitem = new EntityItem(container.worldObj, cart.posX, cart.posY + 0.3F, cart.posZ, stack); + EntityItem entityitem = new EntityItem(container.getWorldObj(), cart.posX, cart.posY + 0.3F, cart.posZ, stack); entityitem.delayBeforeCanPickup = 10; - container.worldObj.spawnEntityInWorld(entityitem); + container.getWorldObj().spawnEntityInWorld(entityitem); pullItemIntoPipe(entityitem, 1); return true; } @@ -189,13 +193,14 @@ public class PipeItemsObsidian extends Pipe implements IPowe } public void pullItemIntoPipe(Entity entity, int distance) { - if (CoreProxy.proxy.isRenderWorld(container.worldObj)) + if (container.getWorldObj().isRemote) { return; + } ForgeDirection orientation = getOpenOrientation().getOpposite(); if (orientation != ForgeDirection.UNKNOWN) { - container.worldObj.playSoundAtEntity(entity, "random.pop", 0.2F, ((container.worldObj.rand.nextFloat() - container.worldObj.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F); + container.getWorldObj().playSoundAtEntity(entity, "random.pop", 0.2F, ((container.getWorldObj().rand.nextFloat() - container.getWorldObj().rand.nextFloat()) * 0.7F + 1.0F) * 2.0F); ItemStack stack = null; @@ -205,7 +210,7 @@ public class PipeItemsObsidian extends Pipe implements IPowe EntityItem item = (EntityItem) entity; ItemStack contained = item.getEntityItem(); - CoreProxy.proxy.obsidianPipePickup(container.worldObj, item, this.container); + CoreProxy.proxy.obsidianPipePickup(container.getWorldObj(), item, this.container); double energyUsed = powerHandler.useEnergy(distance, contained.stackSize * distance, true); @@ -224,7 +229,7 @@ public class PipeItemsObsidian extends Pipe implements IPowe } } else if (entity instanceof EntityArrow) { powerHandler.useEnergy(distance, distance, true); - stack = new ItemStack(Item.arrow, 1); + stack = new ItemStack(Items.arrow, 1); CoreProxy.proxy.removeEntity(entity); } @@ -241,7 +246,7 @@ public class PipeItemsObsidian extends Pipe implements IPowe entitiesDroppedIndex = 0; else entitiesDroppedIndex++; - entitiesDropped[entitiesDroppedIndex] = event.entity.entityId; + entitiesDropped[entitiesDroppedIndex] = event.entity.getEntityId(); } public boolean canSuck(Entity entity, int distance) { @@ -254,7 +259,7 @@ public class PipeItemsObsidian extends Pipe implements IPowe return false; for (int i = 0; i < entitiesDropped.length; ++i) { - if (item.entityId == entitiesDropped[i]) + if (item.getEntityId() == entitiesDropped[i]) return false; } diff --git a/common/buildcraft/transport/pipes/PipeItemsQuartz.java b/common/buildcraft/transport/pipes/PipeItemsQuartz.java index 6873ffde..ff4ab304 100644 --- a/common/buildcraft/transport/pipes/PipeItemsQuartz.java +++ b/common/buildcraft/transport/pipes/PipeItemsQuartz.java @@ -1,9 +1,10 @@ /** - * BuildCraft is open-source. It is distributed under the terms of the - * BuildCraft Open Source License. It grants rights to read, modify, compile or - * run the code. It does *NOT* grant the right to redistribute this software or - * its modifications in any form, binary or source, except if expressively - * granted by the copyright holder. + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.transport.pipes; @@ -17,12 +18,13 @@ import buildcraft.transport.TravelingItem; import buildcraft.transport.pipes.events.PipeEventItem; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import net.minecraftforge.common.ForgeDirection; +import net.minecraft.item.Item; +import net.minecraftforge.common.util.ForgeDirection; public class PipeItemsQuartz extends Pipe { - public PipeItemsQuartz(int itemID) { - super(new PipeTransportItems(), itemID); + public PipeItemsQuartz(Item item) { + super(new PipeTransportItems(), item); } diff --git a/common/buildcraft/transport/pipes/PipeItemsSandstone.java b/common/buildcraft/transport/pipes/PipeItemsSandstone.java index 6e23d15a..2ace9d41 100644 --- a/common/buildcraft/transport/pipes/PipeItemsSandstone.java +++ b/common/buildcraft/transport/pipes/PipeItemsSandstone.java @@ -1,14 +1,16 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.transport.pipes; +import net.minecraft.item.Item; import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; import buildcraft.BuildCraftTransport; import buildcraft.api.core.IIconProvider; import buildcraft.transport.IPipeConnectionForced; @@ -21,8 +23,8 @@ import cpw.mods.fml.relauncher.SideOnly; public class PipeItemsSandstone extends Pipe implements IPipeConnectionForced { - public PipeItemsSandstone(int itemID) { - super(new PipeTransportItems(), itemID); + public PipeItemsSandstone(Item item) { + super(new PipeTransportItems(), item); } @Override diff --git a/common/buildcraft/transport/pipes/PipeItemsStone.java b/common/buildcraft/transport/pipes/PipeItemsStone.java index 86c96858..fa688d84 100644 --- a/common/buildcraft/transport/pipes/PipeItemsStone.java +++ b/common/buildcraft/transport/pipes/PipeItemsStone.java @@ -1,9 +1,10 @@ /** - * BuildCraft is open-source. It is distributed under the terms of the - * BuildCraft Open Source License. It grants rights to read, modify, compile or - * run the code. It does *NOT* grant the right to redistribute this software or - * its modifications in any form, binary or source, except if expressively - * granted by the copyright holder. + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.transport.pipes; @@ -17,12 +18,13 @@ import buildcraft.transport.TravelingItem; import buildcraft.transport.pipes.events.PipeEventItem; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import net.minecraftforge.common.ForgeDirection; +import net.minecraft.item.Item; +import net.minecraftforge.common.util.ForgeDirection; public class PipeItemsStone extends Pipe { - public PipeItemsStone(int itemID) { - super(new PipeTransportItems(), itemID); + public PipeItemsStone(Item item) { + super(new PipeTransportItems(), item); } @Override diff --git a/common/buildcraft/transport/pipes/PipeItemsVoid.java b/common/buildcraft/transport/pipes/PipeItemsVoid.java index 352cf815..33c2c6c2 100644 --- a/common/buildcraft/transport/pipes/PipeItemsVoid.java +++ b/common/buildcraft/transport/pipes/PipeItemsVoid.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.transport.pipes; @@ -15,12 +16,13 @@ import buildcraft.transport.PipeTransportItems; import buildcraft.transport.pipes.events.PipeEventItem; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import net.minecraftforge.common.ForgeDirection; +import net.minecraft.item.Item; +import net.minecraftforge.common.util.ForgeDirection; public class PipeItemsVoid extends Pipe { - public PipeItemsVoid(int itemID) { - super(new PipeTransportItems(), itemID); + public PipeItemsVoid(Item item) { + super(new PipeTransportItems(), item); } @Override diff --git a/common/buildcraft/transport/pipes/PipeItemsWood.java b/common/buildcraft/transport/pipes/PipeItemsWood.java index b2b8282c..4c0dd9ca 100644 --- a/common/buildcraft/transport/pipes/PipeItemsWood.java +++ b/common/buildcraft/transport/pipes/PipeItemsWood.java @@ -1,9 +1,10 @@ /** - * BuildCraft is open-source. It is distributed under the terms of the - * BuildCraft Open Source License. It grants rights to read, modify, compile or - * run the code. It does *NOT* grant the right to redistribute this software or - * its modifications in any form, binary or source, except if expressively - * granted by the copyright holder. + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.transport.pipes; @@ -28,9 +29,10 @@ import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; public class PipeItemsWood extends Pipe implements IPowerReceptor { @@ -44,14 +46,14 @@ public class PipeItemsWood extends Pipe implements IPowerRec return false; if (!(tile instanceof IInventory)) return false; - if (!PipeManager.canExtractItems(pipe, tile.worldObj, tile.xCoord, tile.yCoord, tile.zCoord)) + if (!PipeManager.canExtractItems(pipe, tile.getWorldObj(), tile.xCoord, tile.yCoord, tile.zCoord)) return false; return true; } }; - public PipeItemsWood(int itemID) { - super(new PipeTransportItems(), itemID); + public PipeItemsWood(Item item) { + super(new PipeTransportItems(), item); powerHandler = new PowerHandler(this, Type.MACHINE); powerHandler.configure(1, 64.1f, 1, 64.1f); @@ -102,7 +104,7 @@ public class PipeItemsWood extends Pipe implements IPowerRec @Override public void doWork(PowerHandler workProvider) { - if(container.worldObj.isRemote) + if(container.getWorldObj().isRemote) return; if (powerHandler.getEnergyStored() <= 0) @@ -123,7 +125,7 @@ public class PipeItemsWood extends Pipe implements IPowerRec TileEntity tile = container.getTile(side); if (tile instanceof IInventory) { - if (!PipeManager.canExtractItems(this, tile.worldObj, tile.xCoord, tile.yCoord, tile.zCoord)) + if (!PipeManager.canExtractItems(this, tile.getWorldObj(), tile.xCoord, tile.yCoord, tile.zCoord)) return; IInventory inventory = (IInventory) tile; @@ -132,7 +134,7 @@ public class PipeItemsWood extends Pipe implements IPowerRec if (extracted == null) return; - tile.onInventoryChanged(); + tile.markDirty(); for (ItemStack stack : extracted) { if (stack == null || stack.stackSize == 0) { diff --git a/common/buildcraft/transport/pipes/PipeLogicIron.java b/common/buildcraft/transport/pipes/PipeLogicIron.java index 6c6c1e73..d12564d9 100644 --- a/common/buildcraft/transport/pipes/PipeLogicIron.java +++ b/common/buildcraft/transport/pipes/PipeLogicIron.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.transport.pipes; @@ -13,7 +14,7 @@ import buildcraft.transport.Pipe; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; public abstract class PipeLogicIron { @@ -25,7 +26,7 @@ public abstract class PipeLogicIron { } public void switchOnRedstone() { - boolean currentPower = pipe.container.worldObj.isBlockIndirectlyGettingPowered(pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord); + boolean currentPower = pipe.container.getWorldObj().isBlockIndirectlyGettingPowered(pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord); if (currentPower != lastPower) { switchPosition(); @@ -63,17 +64,17 @@ public abstract class PipeLogicIron { protected abstract boolean isValidConnectingTile(TileEntity tile); public void initialize() { - lastPower = pipe.container.worldObj.isBlockIndirectlyGettingPowered(pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord); + lastPower = pipe.container.getWorldObj().isBlockIndirectlyGettingPowered(pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord); } public void onBlockPlaced() { - pipe.container.worldObj.setBlockMetadataWithNotify(pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord, 1, 3); + pipe.container.getWorldObj().setBlockMetadataWithNotify(pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord, 1, 3); switchPosition(); } public boolean setFacing(ForgeDirection facing) { if (facing.ordinal() != pipe.container.getBlockMetadata() && isValidFacing(facing)) { - pipe.container.worldObj.setBlockMetadataWithNotify(pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord, facing.ordinal(), 3); + pipe.container.getWorldObj().setBlockMetadataWithNotify(pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord, facing.ordinal(), 3); pipe.container.scheduleRenderUpdate(); return true; } diff --git a/common/buildcraft/transport/pipes/PipeLogicWood.java b/common/buildcraft/transport/pipes/PipeLogicWood.java index 05f269b9..c2902268 100644 --- a/common/buildcraft/transport/pipes/PipeLogicWood.java +++ b/common/buildcraft/transport/pipes/PipeLogicWood.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.transport.pipes; @@ -14,7 +15,7 @@ import buildcraft.transport.Pipe; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; public abstract class PipeLogicWood { @@ -37,7 +38,7 @@ public abstract class PipeLogicWood { } if (newFacing != null && newFacing.ordinal() != meta) { - pipe.container.worldObj.setBlockMetadataWithNotify(pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord, newFacing.ordinal(), 3); + pipe.container.getWorldObj().setBlockMetadataWithNotify(pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord, newFacing.ordinal(), 3); pipe.container.scheduleRenderUpdate(); } } @@ -70,7 +71,7 @@ public abstract class PipeLogicWood { protected abstract boolean isValidConnectingTile(TileEntity tile); public void initialize() { - if (!CoreProxy.proxy.isRenderWorld(pipe.container.worldObj)) { + if (!pipe.container.getWorldObj().isRemote) { switchSourceIfNeeded(); } } @@ -87,7 +88,7 @@ public abstract class PipeLogicWood { } public void onNeighborBlockChange(int blockId) { - if (!CoreProxy.proxy.isRenderWorld(pipe.container.worldObj)) { + if (!pipe.container.getWorldObj().isRemote) { switchSourceIfNeeded(); } } diff --git a/common/buildcraft/transport/pipes/PipePowerCobblestone.java b/common/buildcraft/transport/pipes/PipePowerCobblestone.java index 790b6e0e..5e9a3545 100644 --- a/common/buildcraft/transport/pipes/PipePowerCobblestone.java +++ b/common/buildcraft/transport/pipes/PipePowerCobblestone.java @@ -1,9 +1,10 @@ /** - * BuildCraft is open-source. It is distributed under the terms of the - * BuildCraft Open Source License. It grants rights to read, modify, compile or - * run the code. It does *NOT* grant the right to redistribute this software or - * its modifications in any form, binary or source, except if expressively - * granted by the copyright holder. + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.transport.pipes; @@ -14,12 +15,13 @@ import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeTransportPower; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import net.minecraftforge.common.ForgeDirection; +import net.minecraft.item.Item; +import net.minecraftforge.common.util.ForgeDirection; public class PipePowerCobblestone extends Pipe { - public PipePowerCobblestone(int itemID) { - super(new PipeTransportPower(), itemID); + public PipePowerCobblestone(Item item) { + super(new PipeTransportPower(), item); transport.initFromPipe(getClass()); } diff --git a/common/buildcraft/transport/pipes/PipePowerDiamond.java b/common/buildcraft/transport/pipes/PipePowerDiamond.java index 47294ecb..084987bc 100644 --- a/common/buildcraft/transport/pipes/PipePowerDiamond.java +++ b/common/buildcraft/transport/pipes/PipePowerDiamond.java @@ -1,9 +1,10 @@ /** - * BuildCraft is open-source. It is distributed under the terms of the - * BuildCraft Open Source License. It grants rights to read, modify, compile or - * run the code. It does *NOT* grant the right to redistribute this software or - * its modifications in any form, binary or source, except if expressively - * granted by the copyright holder. + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.transport.pipes; @@ -14,12 +15,13 @@ import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeTransportPower; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import net.minecraftforge.common.ForgeDirection; +import net.minecraft.item.Item; +import net.minecraftforge.common.util.ForgeDirection; public class PipePowerDiamond extends Pipe { - public PipePowerDiamond(int itemID) { - super(new PipeTransportPower(), itemID); + public PipePowerDiamond(Item item) { + super(new PipeTransportPower(), item); transport.initFromPipe(getClass()); } diff --git a/common/buildcraft/transport/pipes/PipePowerGold.java b/common/buildcraft/transport/pipes/PipePowerGold.java index cfff315f..8941e383 100644 --- a/common/buildcraft/transport/pipes/PipePowerGold.java +++ b/common/buildcraft/transport/pipes/PipePowerGold.java @@ -1,9 +1,10 @@ /** - * BuildCraft is open-source. It is distributed under the terms of the - * BuildCraft Open Source License. It grants rights to read, modify, compile or - * run the code. It does *NOT* grant the right to redistribute this software or - * its modifications in any form, binary or source, except if expressively - * granted by the copyright holder. + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.transport.pipes; @@ -14,12 +15,13 @@ import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeTransportPower; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import net.minecraftforge.common.ForgeDirection; +import net.minecraft.item.Item; +import net.minecraftforge.common.util.ForgeDirection; public class PipePowerGold extends Pipe { - public PipePowerGold(int itemID) { - super(new PipeTransportPower(), itemID); + public PipePowerGold(Item item) { + super(new PipeTransportPower(), item); transport.initFromPipe(getClass()); } diff --git a/common/buildcraft/transport/pipes/PipePowerHeat.java b/common/buildcraft/transport/pipes/PipePowerHeat.java index d4ab4e36..380e3621 100755 --- a/common/buildcraft/transport/pipes/PipePowerHeat.java +++ b/common/buildcraft/transport/pipes/PipePowerHeat.java @@ -8,20 +8,20 @@ */ package buildcraft.transport.pipes; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; import buildcraft.BuildCraftCore; import buildcraft.BuildCraftTransport; import buildcraft.api.core.IIconProvider; import buildcraft.api.core.SafeTimeTracker; -import buildcraft.core.proxy.CoreProxy; import buildcraft.transport.Pipe; import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeTransportPower; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.block.Block; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.item.ItemStack; -import net.minecraftforge.common.ForgeDirection; public class PipePowerHeat extends Pipe { @@ -30,8 +30,8 @@ public class PipePowerHeat extends Pipe { SafeTimeTracker scanTracker = new SafeTimeTracker(40, 5); - public PipePowerHeat(int itemID) { - super(new PipeTransportPower(), itemID); + public PipePowerHeat(Item item) { + super(new PipeTransportPower(), item); transport.initFromPipe(getClass()); } @@ -57,7 +57,7 @@ public class PipePowerHeat extends Pipe { return PipeIconProvider.TYPE.PipePowerHeat0.ordinal(); } else { return PipeIconProvider.TYPE.PipePowerHeat0.ordinal() - + container.worldObj.getBlockMetadata(container.xCoord, + + container.getWorld().getBlockMetadata(container.xCoord, container.yCoord, container.zCoord); } } @@ -66,27 +66,26 @@ public class PipePowerHeat extends Pipe { public void updateEntity() { super.updateEntity(); - if (!CoreProxy.proxy.isSimulating(container.worldObj)) { + if (container.getWorld().isRemote) { return; } - PipeTransportPower power = ((PipeTransportPower) transport); + PipeTransportPower power = (transport); power.requestEnergy(ForgeDirection.UP, 1024); powerLevel = power.clearInstantPower (); - int meta = container.worldObj.getBlockMetadata(container.xCoord, container.yCoord, container.zCoord); + int meta = container.getWorld().getBlockMetadata(container.xCoord, container.yCoord, container.zCoord); int newMeta = getHeatLevel(); if (meta != newMeta) { - System.out.println ("SEND NEW META " + newMeta); - container.worldObj.setBlockMetadataWithNotify(container.xCoord, + container.getWorld().setBlockMetadataWithNotify(container.xCoord, container.yCoord, container.zCoord, newMeta, 2); container.scheduleRenderUpdate(); } - if (powerLevel >= 10 && scanTracker.markTimeIfDelay(container.worldObj)) { + if (powerLevel >= 10 && scanTracker.markTimeIfDelay(container.getWorld())) { int x = container.xCoord; int y = container.yCoord; int z = container.zCoord; @@ -94,27 +93,27 @@ public class PipePowerHeat extends Pipe { for (int xi = x - 1; xi <= x + 1; ++xi) { for (int yi = y - 1; yi <= y + 1; ++yi) { for (int zi = z - 1; zi <= z + 1; ++zi) { - if (container.worldObj.getBlockId(xi, yi, zi) == Block.blockRedstone.blockID) { - container.worldObj.setBlock(xi, yi, zi, 0); + if (container.getWorld().getBlock(xi, yi, zi) == Blocks.redstone_block) { + container.getWorld().setBlock(xi, yi, zi, Blocks.air); for (int i = 0; i < 4; ++i) { ItemStack stack = new ItemStack( BuildCraftCore.redstoneCrystal); EntityItem entityitem = new EntityItem( - container.worldObj, xi + 0.5F, + container.getWorld(), xi + 0.5F, yi + 0.5F, zi + 0.5F, stack); entityitem.lifespan = BuildCraftCore.itemLifespan; entityitem.delayBeforeCanPickup = 10; float f3 = 0.05F; - entityitem.motionX = (float) (container.worldObj.rand + entityitem.motionX = (float) (container.getWorld().rand .nextGaussian() - 0.5F) * f3; - entityitem.motionY = (float) (container.worldObj.rand + entityitem.motionY = (float) (container.getWorld().rand .nextGaussian() - 0.5F) * f3; - entityitem.motionZ = (float) (container.worldObj.rand + entityitem.motionZ = (float) (container.getWorld().rand .nextGaussian() - 0.5F) * f3; - container.worldObj + container.getWorld() .spawnEntityInWorld(entityitem); } } diff --git a/common/buildcraft/transport/pipes/PipePowerIron.java b/common/buildcraft/transport/pipes/PipePowerIron.java index 2a6b30bd..fd035033 100644 --- a/common/buildcraft/transport/pipes/PipePowerIron.java +++ b/common/buildcraft/transport/pipes/PipePowerIron.java @@ -1,9 +1,10 @@ /** - * BuildCraft is open-source. It is distributed under the terms of the - * BuildCraft Open Source License. It grants rights to read, modify, compile or - * run the code. It does *NOT* grant the right to redistribute this software or - * its modifications in any form, binary or source, except if expressively - * granted by the copyright holder. + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.transport.pipes; @@ -18,11 +19,14 @@ import buildcraft.transport.PipeTransportPower; import buildcraft.transport.triggers.ActionPowerLimiter; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; + import java.util.LinkedList; import java.util.Map; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; -import net.minecraftforge.common.ForgeDirection; +import net.minecraft.util.ChatComponentText; +import net.minecraftforge.common.util.ForgeDirection; public class PipePowerIron extends Pipe { @@ -54,8 +58,8 @@ public class PipePowerIron extends Pipe { } } - public PipePowerIron(int itemID) { - super(new PipeTransportPower(), itemID); + public PipePowerIron(Item item) { + super(new PipeTransportPower(), item); transport.initFromPipe(getClass()); } @@ -76,7 +80,9 @@ public class PipePowerIron extends Pipe { setMode(getMode().getNext()); } if (getWorld().isRemote) - player.addChatMessage(String.format(StringUtils.localize("chat.pipe.power.iron.mode"), getMode().maxPower)); + player.addChatMessage(new ChatComponentText(String.format( + StringUtils.localize("chat.pipe.power.iron.mode"), + getMode().maxPower))); ((IToolWrench) equipped).wrenchUsed(player, container.xCoord, container.yCoord, container.zCoord); return true; @@ -97,7 +103,7 @@ public class PipePowerIron extends Pipe { public void setMode(PowerMode mode) { if (mode.ordinal() != container.getBlockMetadata()) { - container.worldObj.setBlockMetadataWithNotify(container.xCoord, container.yCoord, container.zCoord, mode.ordinal(), 3); + container.getWorldObj().setBlockMetadataWithNotify(container.xCoord, container.yCoord, container.zCoord, mode.ordinal(), 3); container.scheduleRenderUpdate(); } } diff --git a/common/buildcraft/transport/pipes/PipePowerQuartz.java b/common/buildcraft/transport/pipes/PipePowerQuartz.java index d0e80fe9..a9ad0a4a 100644 --- a/common/buildcraft/transport/pipes/PipePowerQuartz.java +++ b/common/buildcraft/transport/pipes/PipePowerQuartz.java @@ -1,9 +1,10 @@ /** - * BuildCraft is open-source. It is distributed under the terms of the - * BuildCraft Open Source License. It grants rights to read, modify, compile or - * run the code. It does *NOT* grant the right to redistribute this software or - * its modifications in any form, binary or source, except if expressively - * granted by the copyright holder. + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.transport.pipes; @@ -14,12 +15,13 @@ import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeTransportPower; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import net.minecraftforge.common.ForgeDirection; +import net.minecraft.item.Item; +import net.minecraftforge.common.util.ForgeDirection; public class PipePowerQuartz extends Pipe { - public PipePowerQuartz(int itemID) { - super(new PipeTransportPower(), itemID); + public PipePowerQuartz(Item item) { + super(new PipeTransportPower(), item); transport.initFromPipe(getClass()); } diff --git a/common/buildcraft/transport/pipes/PipePowerStone.java b/common/buildcraft/transport/pipes/PipePowerStone.java index df488faf..096f8f82 100644 --- a/common/buildcraft/transport/pipes/PipePowerStone.java +++ b/common/buildcraft/transport/pipes/PipePowerStone.java @@ -1,9 +1,10 @@ /** - * BuildCraft is open-source. It is distributed under the terms of the - * BuildCraft Open Source License. It grants rights to read, modify, compile or - * run the code. It does *NOT* grant the right to redistribute this software or - * its modifications in any form, binary or source, except if expressively - * granted by the copyright holder. + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.transport.pipes; @@ -14,12 +15,13 @@ import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeTransportPower; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import net.minecraftforge.common.ForgeDirection; +import net.minecraft.item.Item; +import net.minecraftforge.common.util.ForgeDirection; public class PipePowerStone extends Pipe { - public PipePowerStone(int itemID) { - super(new PipeTransportPower(), itemID); + public PipePowerStone(Item item) { + super(new PipeTransportPower(), item); transport.initFromPipe(getClass()); } diff --git a/common/buildcraft/transport/pipes/PipePowerWood.java b/common/buildcraft/transport/pipes/PipePowerWood.java index fe2e5c25..13763fa4 100644 --- a/common/buildcraft/transport/pipes/PipePowerWood.java +++ b/common/buildcraft/transport/pipes/PipePowerWood.java @@ -1,9 +1,10 @@ /** - * BuildCraft is open-source. It is distributed under the terms of the - * BuildCraft Open Source License. It grants rights to read, modify, compile or - * run the code. It does *NOT* grant the right to redistribute this software or - * its modifications in any form, binary or source, except if expressively - * granted by the copyright holder. + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.transport.pipes; @@ -20,8 +21,9 @@ import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeTransportPower; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.item.Item; import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; public class PipePowerWood extends Pipe implements IPowerReceptor, IPipeTransportPowerHook { @@ -31,8 +33,8 @@ public class PipePowerWood extends Pipe implements IPowerRec private boolean[] powerSources = new boolean[6]; private boolean full; - public PipePowerWood(int itemID) { - super(new PipeTransportPower(), itemID); + public PipePowerWood(Item item) { + super(new PipeTransportPower(), item); powerHandler = new PowerHandler(this, Type.PIPE); initPowerProvider(); @@ -67,7 +69,7 @@ public class PipePowerWood extends Pipe implements IPowerRec @Override public void updateEntity() { super.updateEntity(); - if (container.worldObj.isRemote) + if (container.getWorldObj().isRemote) return; if (powerHandler.getEnergyStored() <= 0) diff --git a/common/buildcraft/transport/pipes/PipeStructureCobblestone.java b/common/buildcraft/transport/pipes/PipeStructureCobblestone.java index 90e94beb..f0a2e114 100644 --- a/common/buildcraft/transport/pipes/PipeStructureCobblestone.java +++ b/common/buildcraft/transport/pipes/PipeStructureCobblestone.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.transport.pipes; import buildcraft.BuildCraftTransport; @@ -7,12 +15,13 @@ import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeTransportStructure; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import net.minecraftforge.common.ForgeDirection; +import net.minecraft.item.Item; +import net.minecraftforge.common.util.ForgeDirection; public class PipeStructureCobblestone extends Pipe { - public PipeStructureCobblestone(int itemID) { - super(new PipeTransportStructure(), itemID); + public PipeStructureCobblestone(Item item) { + super(new PipeTransportStructure(), item); } @Override diff --git a/common/buildcraft/transport/pipes/events/PipeEvent.java b/common/buildcraft/transport/pipes/events/PipeEvent.java index 8cc7177e..e5d74a5a 100644 --- a/common/buildcraft/transport/pipes/events/PipeEvent.java +++ b/common/buildcraft/transport/pipes/events/PipeEvent.java @@ -1,16 +1,12 @@ -/* - * Copyright (c) SpaceToad, 2011-2012 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * + * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.transport.pipes.events; -/** - * - * @author CovertJaguar - */ public abstract class PipeEvent { } diff --git a/common/buildcraft/transport/pipes/events/PipeEventItem.java b/common/buildcraft/transport/pipes/events/PipeEventItem.java index 0671c8ad..f06c7e42 100644 --- a/common/buildcraft/transport/pipes/events/PipeEventItem.java +++ b/common/buildcraft/transport/pipes/events/PipeEventItem.java @@ -1,7 +1,7 @@ -/* - * Copyright (c) SpaceToad, 2011-2012 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * + * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt @@ -12,12 +12,8 @@ import buildcraft.transport.TravelingItem; import java.util.List; import net.minecraft.entity.item.EntityItem; import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; -/** - * - * @author CovertJaguar - */ public abstract class PipeEventItem extends PipeEvent { public final TravelingItem item; diff --git a/common/buildcraft/transport/render/FacadeItemRenderer.java b/common/buildcraft/transport/render/FacadeItemRenderer.java index 749fc0d6..0a16db8f 100644 --- a/common/buildcraft/transport/render/FacadeItemRenderer.java +++ b/common/buildcraft/transport/render/FacadeItemRenderer.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.transport.render; import buildcraft.BuildCraftTransport; @@ -10,7 +18,7 @@ import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.util.Icon; +import net.minecraft.util.IIcon; import net.minecraftforge.client.IItemRenderer; import static net.minecraftforge.client.IItemRenderer.ItemRenderType.EQUIPPED_FIRST_PERSON; import org.lwjgl.opengl.GL11; @@ -20,17 +28,16 @@ public class FacadeItemRenderer implements IItemRenderer { private void renderFacadeItem(RenderBlocks render, ItemStack item, float translateX, float translateY, float translateZ) { int decodedMeta = ItemFacade.getMetaData(item); - int decodedBlockId = ItemFacade.getBlockId(item); + Block block = ItemFacade.getBlock(item); try { - int color = Item.itemsList[decodedBlockId].getColorFromItemStack(new ItemStack(decodedBlockId, 1, decodedMeta), 0); + int color = item.getItem().getColorFromItemStack(new ItemStack(block, 1, decodedMeta), 0); RenderUtils.setGLColorFromInt(color); } catch (Throwable error) { } Tessellator tessellator = Tessellator.instance; - Block block = Block.blocksList[decodedBlockId]; if (block == null) return; @@ -69,7 +76,7 @@ public class FacadeItemRenderer implements IItemRenderer { // Render StructurePipe block = BuildCraftTransport.genericPipeBlock; - Icon textureID = BuildCraftTransport.instance.pipeIconProvider.getIcon(PipeIconProvider.TYPE.PipeStructureCobblestone.ordinal()); // Structure pipe + IIcon textureID = BuildCraftTransport.instance.pipeIconProvider.getIcon(PipeIconProvider.TYPE.PipeStructureCobblestone.ordinal()); // Structure pipe block.setBlockBounds(CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MIN_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS, CoreConstants.PIPE_MAX_POS - 1F / 16F); block.setBlockBoundsForItemRender(); diff --git a/common/buildcraft/transport/render/FacadeRenderHelper.java b/common/buildcraft/transport/render/FacadeRenderHelper.java index 6ff9e549..690164fc 100644 --- a/common/buildcraft/transport/render/FacadeRenderHelper.java +++ b/common/buildcraft/transport/render/FacadeRenderHelper.java @@ -1,7 +1,7 @@ -/* - * Copyright (c) SpaceToad, 2011-2012 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * + * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt @@ -19,13 +19,9 @@ import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.util.Icon; -import net.minecraftforge.common.ForgeDirection; +import net.minecraft.util.IIcon; +import net.minecraftforge.common.util.ForgeDirection; -/** - * - * @author CovertJaguar - */ public class FacadeRenderHelper { private static final float zFightOffset = 1F / 4096F; @@ -90,12 +86,12 @@ public class FacadeRenderHelper { } public static void pipeFacadeRenderer(RenderBlocks renderblocks, BlockGenericPipe block, PipeRenderState state, int x, int y, int z) { - state.textureArray = new Icon[6]; + state.textureArray = new IIcon[6]; for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) { - int facadeId = state.facadeMatrix.getFacadeBlockId(direction); - if (facadeId != 0) { - Block renderBlock = Block.blocksList[facadeId]; + Block renderBlock = state.facadeMatrix.getFacadeBlock(direction); + + if (renderBlock != null) { int renderMeta = state.facadeMatrix.getFacadeMetaId(direction); for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { @@ -103,11 +99,11 @@ public class FacadeRenderHelper { if (side == direction || side == direction.getOpposite()) block.setRenderSide(side, true); else - block.setRenderSide(side, state.facadeMatrix.getFacadeBlockId(side) == 0); + block.setRenderSide(side, state.facadeMatrix.getFacadeBlock(side) == null); } try { - BlockGenericPipe.facadeRenderColor = Item.itemsList[state.facadeMatrix.getFacadeBlockId(direction)].getColorFromItemStack(new ItemStack(facadeId, 1, renderMeta), 0); + BlockGenericPipe.facadeRenderColor = Item.getItemFromBlock(state.facadeMatrix.getFacadeBlock(direction)).getColorFromItemStack(new ItemStack(renderBlock, 1, renderMeta), 0); } catch (Throwable error) { } @@ -181,7 +177,7 @@ public class FacadeRenderHelper { state.currentTexture = BuildCraftTransport.instance.pipeIconProvider.getIcon(PipeIconProvider.TYPE.PipeStructureCobblestone.ordinal()); // Structure Pipe for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) { - if (state.facadeMatrix.getFacadeBlockId(direction) != 0 && !state.pipeConnectionMatrix.isConnected(direction)) { + if (state.facadeMatrix.getFacadeBlock(direction) != null && !state.pipeConnectionMatrix.isConnected(direction)) { float[][] rotated = MatrixTranformations.deepClone(zeroStateSupport); MatrixTranformations.transform(rotated, direction); diff --git a/common/buildcraft/transport/render/GateItemRenderer.java b/common/buildcraft/transport/render/GateItemRenderer.java index a6fed8f9..831bc441 100644 --- a/common/buildcraft/transport/render/GateItemRenderer.java +++ b/common/buildcraft/transport/render/GateItemRenderer.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.transport.render; import buildcraft.api.gates.IGateExpansion; @@ -7,7 +15,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.client.renderer.entity.RenderItem; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.Tessellator; -import net.minecraft.util.Icon; +import net.minecraft.util.IIcon; import net.minecraft.client.renderer.ItemRenderer; import net.minecraftforge.client.IItemRenderer; import net.minecraftforge.client.IItemRenderer.ItemRenderType; @@ -15,10 +23,6 @@ import net.minecraftforge.client.IItemRenderer.ItemRendererHelper; import org.lwjgl.opengl.GL11; import net.minecraft.entity.item.EntityItem; -/** - * - * @author CovertJaguar - */ public class GateItemRenderer implements IItemRenderer { RenderItem renderItem = new RenderItem(); @@ -65,7 +69,7 @@ public class GateItemRenderer implements IItemRenderer { GL11.glPopMatrix(); } - private void renderLayerIn3D(Icon icon) { + private void renderLayerIn3D(IIcon icon) { if (icon == null) return; GL11.glPushMatrix(); @@ -148,7 +152,7 @@ public class GateItemRenderer implements IItemRenderer { private void render(ItemRenderType type, ItemStack stack) { GL11.glPushMatrix(); GL11.glDisable(GL11.GL_LIGHTING); - Icon icon = ItemGate.getLogic(stack).getIconItem(); + IIcon icon = ItemGate.getLogic(stack).getIconItem(); renderItem.renderIcon(0, 0, icon, 16, 16); if (type == ItemRenderType.ENTITY) diff --git a/common/buildcraft/transport/render/PipeItemRenderer.java b/common/buildcraft/transport/render/PipeItemRenderer.java index 28b58bd2..9cd4eb51 100644 --- a/common/buildcraft/transport/render/PipeItemRenderer.java +++ b/common/buildcraft/transport/render/PipeItemRenderer.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.transport.render; import buildcraft.BuildCraftTransport; @@ -8,7 +16,7 @@ import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.item.ItemStack; -import net.minecraft.util.Icon; +import net.minecraft.util.IIcon; import net.minecraftforge.client.IItemRenderer; import org.lwjgl.opengl.GL11; @@ -20,7 +28,7 @@ public class PipeItemRenderer implements IItemRenderer { Tessellator tessellator = Tessellator.instance; Block block = BuildCraftTransport.genericPipeBlock; - Icon icon = item.getItem().getIconFromDamage(0); + IIcon icon = item.getItem().getIconFromDamage(0); if (icon == null) icon = ((TextureMap) Minecraft.getMinecraft().getTextureManager().getTexture(TextureMap.locationBlocksTexture)).getAtlasSprite("missingno"); diff --git a/common/buildcraft/transport/render/PipeRendererTESR.java b/common/buildcraft/transport/render/PipeRendererTESR.java index 02f89974..04a039d0 100644 --- a/common/buildcraft/transport/render/PipeRendererTESR.java +++ b/common/buildcraft/transport/render/PipeRendererTESR.java @@ -8,32 +8,8 @@ */ package buildcraft.transport.render; -import buildcraft.BuildCraftCore; -import buildcraft.BuildCraftCore.RenderMode; -import buildcraft.BuildCraftTransport; -import buildcraft.api.gates.IGateExpansion; -import buildcraft.core.CoreConstants; -import buildcraft.core.DefaultProps; -import buildcraft.core.render.RenderEntityBlock; -import buildcraft.core.render.RenderEntityBlock.RenderInfo; -import buildcraft.core.utils.EnumColor; -import buildcraft.core.render.RenderUtils; -import buildcraft.core.utils.MatrixTranformations; -import buildcraft.transport.Pipe; -import buildcraft.api.transport.PipeWire; -import buildcraft.transport.PipeIconProvider; -import buildcraft.transport.PipeRenderState; -import buildcraft.transport.PipeTransportFluids; -import buildcraft.transport.PipeTransportItems; -import buildcraft.transport.PipeTransportPower; -import buildcraft.transport.TileGenericPipe; -import buildcraft.transport.TravelingItem; - -import com.google.common.collect.Maps; - import java.util.HashMap; -import net.minecraft.block.Block; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.renderer.GLAllocation; @@ -43,18 +19,42 @@ import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.entity.item.EntityItem; +import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Icon; +import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import org.lwjgl.opengl.GL11; +import buildcraft.BuildCraftCore; +import buildcraft.BuildCraftCore.RenderMode; +import buildcraft.BuildCraftTransport; +import buildcraft.api.gates.IGateExpansion; +import buildcraft.api.transport.PipeWire; +import buildcraft.core.CoreConstants; +import buildcraft.core.DefaultProps; +import buildcraft.core.render.RenderEntityBlock; +import buildcraft.core.render.RenderEntityBlock.RenderInfo; +import buildcraft.core.render.RenderUtils; +import buildcraft.core.utils.EnumColor; +import buildcraft.core.utils.MatrixTranformations; +import buildcraft.transport.Pipe; +import buildcraft.transport.PipeIconProvider; +import buildcraft.transport.PipeRenderState; +import buildcraft.transport.PipeTransportFluids; +import buildcraft.transport.PipeTransportItems; +import buildcraft.transport.PipeTransportPower; +import buildcraft.transport.TileGenericPipe; +import buildcraft.transport.TravelingItem; + +import com.google.common.collect.Maps; + public class PipeRendererTESR extends TileEntitySpecialRenderer { final static private int LIQUID_STAGES = 40; @@ -113,10 +113,10 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer { RenderInfo block = new RenderInfo(); Fluid fluid = FluidRegistry.getFluid(liquidId); - if (fluid.getBlockID() > 0) { - block.baseBlock = Block.blocksList[fluid.getBlockID()]; + if (fluid.getBlock() != null) { + block.baseBlock = fluid.getBlock(); } else { - block.baseBlock = Block.waterStill; + block.baseBlock = Blocks.water; } block.texture = fluid.getStillIcon(); @@ -267,13 +267,15 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer { @Override public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f) { - if (BuildCraftCore.render == RenderMode.NoDynamic) + if (BuildCraftCore.render == RenderMode.NoDynamic) { return; + } TileGenericPipe pipe = (TileGenericPipe) tileentity; - if (pipe.pipe == null) + if (pipe.pipe == null) { return; + } renderGatesWires(pipe, x, y, z); @@ -433,7 +435,7 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer { if (minZ != CoreConstants.PIPE_MIN_POS || maxZ != CoreConstants.PIPE_MAX_POS || !found) { box.setBounds(cx == CoreConstants.PIPE_MIN_POS ? cx - 0.05F : cx, cy == CoreConstants.PIPE_MIN_POS ? cy - 0.05F : cy, minZ, cx == CoreConstants.PIPE_MIN_POS ? cx : cx + 0.05F, cy == CoreConstants.PIPE_MIN_POS ? cy : cy + 0.05F, maxZ); - RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true); + RenderEntityBlock.INSTANCE.renderBlock(box, pipe.getWorldObj(), 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true); } // X render @@ -441,7 +443,7 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer { if (minX != CoreConstants.PIPE_MIN_POS || maxX != CoreConstants.PIPE_MAX_POS || !found) { box.setBounds(minX, cy == CoreConstants.PIPE_MIN_POS ? cy - 0.05F : cy, cz == CoreConstants.PIPE_MIN_POS ? cz - 0.05F : cz, maxX, cy == CoreConstants.PIPE_MIN_POS ? cy : cy + 0.05F, cz == CoreConstants.PIPE_MIN_POS ? cz : cz + 0.05F); - RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true); + RenderEntityBlock.INSTANCE.renderBlock(box, pipe.getWorldObj(), 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true); } // Y render @@ -449,13 +451,13 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer { if (minY != CoreConstants.PIPE_MIN_POS || maxY != CoreConstants.PIPE_MAX_POS || !found) { box.setBounds(cx == CoreConstants.PIPE_MIN_POS ? cx - 0.05F : cx, minY, cz == CoreConstants.PIPE_MIN_POS ? cz - 0.05F : cz, cx == CoreConstants.PIPE_MIN_POS ? cx : cx + 0.05F, maxY, cz == CoreConstants.PIPE_MIN_POS ? cz : cz + 0.05F); - RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true); + RenderEntityBlock.INSTANCE.renderBlock(box, pipe.getWorldObj(), 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true); } if (center || !found) { box.setBounds(cx == CoreConstants.PIPE_MIN_POS ? cx - 0.05F : cx, cy == CoreConstants.PIPE_MIN_POS ? cy - 0.05F : cy, cz == CoreConstants.PIPE_MIN_POS ? cz - 0.05F : cz, cx == CoreConstants.PIPE_MIN_POS ? cx : cx + 0.05F, cy == CoreConstants.PIPE_MIN_POS ? cy : cy + 0.05F, cz == CoreConstants.PIPE_MIN_POS ? cz : cz + 0.05F); - RenderEntityBlock.INSTANCE.renderBlock(box, pipe.worldObj, 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true); + RenderEntityBlock.INSTANCE.renderBlock(box, pipe.getWorldObj(), 0, 0, 0, pipe.xCoord, pipe.yCoord, pipe.zCoord, true, true); } RenderHelper.enableStandardItemLighting(); @@ -478,7 +480,7 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer { bindTexture(TextureMap.locationBlocksTexture); - Icon iconLogic; + IIcon iconLogic; if (pipe.renderState.isGateLit()) iconLogic = pipe.pipe.gate.logic.getIconLit(); else @@ -505,7 +507,7 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer { renderGate(pipe, iconLogic, 0, 0.13F, translateCenter, translateCenter); } - Icon materialIcon = pipe.pipe.gate.material.getIconBlock(); + IIcon materialIcon = pipe.pipe.gate.material.getIconBlock(); if (materialIcon != null) renderGate(pipe, materialIcon, 1, 0.13F, translateCenter, translateCenter); @@ -519,7 +521,7 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer { GL11.glPopMatrix(); } - private void renderGate(TileGenericPipe tile, Icon icon, int layer, float trim, float translateCenter, float extraDepth) { + private void renderGate(TileGenericPipe tile, IIcon icon, int layer, float trim, float translateCenter, float extraDepth) { PipeRenderState state = tile.renderState; RenderInfo box = new RenderInfo(); @@ -555,8 +557,7 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer { if (layer != 0) box.setRenderSingleSide(direction.ordinal()); box.setBounds(rotated[0][0], rotated[1][0], rotated[2][0], rotated[0][1], rotated[1][1], rotated[2][1]); - RenderEntityBlock.INSTANCE.renderBlock(box, tile.worldObj, 0, 0, 0, tile.xCoord, tile.yCoord, tile.zCoord, true, true); - + RenderEntityBlock.INSTANCE.renderBlock(box, tile.getWorldObj(), 0, 0, 0, tile.xCoord, tile.yCoord, tile.zCoord, true, true); GL11.glPopMatrix(); } } @@ -564,7 +565,7 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer { private boolean shouldRenderNormalPipeSide(PipeRenderState state, ForgeDirection direction) { return !state.pipeConnectionMatrix.isConnected(direction) - && state.facadeMatrix.getFacadeBlockId(direction) == 0 + && state.facadeMatrix.getFacadeBlock(direction) == null && !state.plugMatrix.isConnected(direction) && !state.robotStationMatrix.isConnected(direction) && !isOpenOrientation(state, direction); @@ -594,7 +595,7 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer { public static final ResourceLocation STRIPES_TEXTURE = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_ENTITIES + "/stripes.png"); private void renderPower(Pipe pipe, double x, double y, double z) { - initializeDisplayPowerList(pipe.container.worldObj); + initializeDisplayPowerList(pipe.container.getWorldObj()); PipeTransportPower pow = pipe.transport; @@ -698,7 +699,7 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer { if (!pipe.container.isPipeConnected(side)) continue; - DisplayFluidList d = getListFromBuffer(fluidStack, pipe.container.worldObj); + DisplayFluidList d = getListFromBuffer(fluidStack, pipe.container.getWorldObj()); if (d == null) continue; @@ -740,7 +741,7 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer { FluidStack fluidStack = trans.renderCache[ForgeDirection.UNKNOWN.ordinal()]; if (fluidStack != null && fluidStack.amount > 0) { - DisplayFluidList d = getListFromBuffer(fluidStack, pipe.container.worldObj); + DisplayFluidList d = getListFromBuffer(fluidStack, pipe.container.getWorldObj()); if (d != null) { int stage = (int) ((float) fluidStack.amount / (float) (trans.getCapacity()) * (LIQUID_STAGES - 1)); @@ -777,7 +778,7 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer { GL11.glPushMatrix(); GL11.glDisable(2896 /* GL_LIGHTING */); - float light = pipe.container.worldObj.getLightBrightness(pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord); + float light = pipe.container.getWorldObj().getLightBrightness(pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord); int count = 0; for (TravelingItem item : pipe.transport.items) { @@ -795,8 +796,9 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer { public void doRenderItem(TravelingItem travellingItem, double x, double y, double z, float light, EnumColor color) { - if (travellingItem == null || travellingItem.getItemStack() == null) + if (travellingItem == null || travellingItem.getItemStack() == null) { return; + } float renderScale = 0.7f; ItemStack itemstack = travellingItem.getItemStack(); @@ -805,7 +807,8 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer { GL11.glTranslatef(0, 0.25F, 0); GL11.glScalef(renderScale, renderScale, renderScale); dummyEntityItem.setEntityItemStack(itemstack); - customRenderItem.doRenderItem(dummyEntityItem, 0, 0, 0, 0, 0); + customRenderItem.doRender(dummyEntityItem, 0, 0, 0, 0, 0); + if (color != null) { bindTexture(TextureMap.locationBlocksTexture); RenderInfo block = new RenderInfo(); @@ -829,6 +832,7 @@ public class PipeRendererTESR extends TileEntitySpecialRenderer { RenderUtils.setGLColorFromInt(color.getLightHex()); RenderEntityBlock.INSTANCE.renderBlock(block, null, 0, 0, 0, false, true); } + GL11.glPopMatrix(); } } diff --git a/common/buildcraft/transport/render/PipeRendererWorld.java b/common/buildcraft/transport/render/PipeRendererWorld.java index b83381c6..f4def035 100644 --- a/common/buildcraft/transport/render/PipeRendererWorld.java +++ b/common/buildcraft/transport/render/PipeRendererWorld.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.transport.render; import buildcraft.BuildCraftTransport; @@ -17,15 +25,17 @@ import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.IBlockAccess; -import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.common.util.ForgeDirection; public class PipeRendererWorld implements ISimpleBlockRenderingHandler { public void renderPipe(RenderBlocks renderblocks, IBlockAccess iblockaccess, BlockGenericPipe block, TileGenericPipe tile, int x, int y, int z) { PipeRenderState state = tile.renderState; IIconProvider icons = tile.getPipeIcons(); - if (icons == null) + + if (icons == null) { return; + } int connectivity = state.pipeConnectionMatrix.getMask(); float[] dim = new float[6]; @@ -43,8 +53,10 @@ public class PipeRendererWorld implements ISimpleBlockRenderingHandler { for (int dir = 0; dir < 6; dir++) { int mask = 1 << dir; - if ((connectivity & mask) == 0) + + if ((connectivity & mask) == 0) { continue; // no connection towards dir + } // center piece offsets resetToCenterDimensions(dim); @@ -73,6 +85,7 @@ public class PipeRendererWorld implements ISimpleBlockRenderingHandler { for (int i = 0; i < 3; i++) { dim[i] = CoreConstants.PIPE_MIN_POS; } + for (int i = 3; i < 6; i++) { dim[i] = CoreConstants.PIPE_MAX_POS; } @@ -98,10 +111,9 @@ public class PipeRendererWorld implements ISimpleBlockRenderingHandler { } private void pipePlugRenderer(RenderBlocks renderblocks, Block block, PipeRenderState state, int x, int y, int z) { - float zFightOffset = 1F / 4096F; - float[][] zeroState = new float[3][2]; + // X START - END zeroState[0][0] = 0.25F + zFightOffset; zeroState[0][1] = 0.75F - zFightOffset; @@ -253,18 +265,18 @@ public class PipeRendererWorld implements ISimpleBlockRenderingHandler { @Override public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { - TileEntity tile = world.getBlockTileEntity(x, y, z); + TileEntity tile = world.getTileEntity(x, y, z); if (tile instanceof TileGenericPipe) { TileGenericPipe pipeTile = (TileGenericPipe) tile; renderPipe(renderer, world, (BlockGenericPipe) block, pipeTile, x, y, z); } + return true; } @Override - public boolean shouldRender3DInInventory() { - // TODO Auto-generated method stub + public boolean shouldRender3DInInventory(int modelId) { return false; } diff --git a/common/buildcraft/transport/render/PlugItemRenderer.java b/common/buildcraft/transport/render/PlugItemRenderer.java index 88602f67..b75a41c4 100644 --- a/common/buildcraft/transport/render/PlugItemRenderer.java +++ b/common/buildcraft/transport/render/PlugItemRenderer.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.transport.render; import buildcraft.BuildCraftTransport; @@ -6,7 +14,7 @@ import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; import net.minecraft.item.ItemStack; -import net.minecraft.util.Icon; +import net.minecraft.util.IIcon; import net.minecraftforge.client.IItemRenderer; import static net.minecraftforge.client.IItemRenderer.ItemRenderType.EQUIPPED_FIRST_PERSON; import org.lwjgl.opengl.GL11; @@ -19,7 +27,7 @@ public class PlugItemRenderer implements IItemRenderer { Tessellator tessellator = Tessellator.instance; block = BuildCraftTransport.genericPipeBlock; - Icon textureID = BuildCraftTransport.instance.pipeIconProvider.getIcon(PipeIconProvider.TYPE.PipeStructureCobblestone.ordinal()); // Structure pipe + IIcon textureID = BuildCraftTransport.instance.pipeIconProvider.getIcon(PipeIconProvider.TYPE.PipeStructureCobblestone.ordinal()); // Structure pipe block.setBlockBounds(0.25F, 0.25F, 0.25F, 0.75F, 0.375F, 0.75F); block.setBlockBoundsForItemRender(); diff --git a/common/buildcraft/transport/render/RobotStationItemRenderer.java b/common/buildcraft/transport/render/RobotStationItemRenderer.java index 44271df4..c2473995 100755 --- a/common/buildcraft/transport/render/RobotStationItemRenderer.java +++ b/common/buildcraft/transport/render/RobotStationItemRenderer.java @@ -1,15 +1,17 @@ package buildcraft.transport.render; -import buildcraft.BuildCraftTransport; -import buildcraft.transport.PipeIconProvider; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; import net.minecraft.item.ItemStack; -import net.minecraft.util.Icon; +import net.minecraft.util.IIcon; import net.minecraftforge.client.IItemRenderer; + import org.lwjgl.opengl.GL11; +import buildcraft.BuildCraftTransport; +import buildcraft.transport.PipeIconProvider; + public class RobotStationItemRenderer implements IItemRenderer { private void renderPlugItem(RenderBlocks render, ItemStack item, float translateX, float translateY, float translateZ) { @@ -18,7 +20,7 @@ public class RobotStationItemRenderer implements IItemRenderer { Tessellator tessellator = Tessellator.instance; block = BuildCraftTransport.genericPipeBlock; - Icon textureID = BuildCraftTransport.instance.pipeIconProvider.getIcon(PipeIconProvider.TYPE.PipeRobotStation.ordinal()); // Structure pipe + IIcon textureID = BuildCraftTransport.instance.pipeIconProvider.getIcon(PipeIconProvider.TYPE.PipeRobotStation.ordinal()); // Structure pipe block.setBlockBounds(0.25F, 0.25F, 0.25F, 0.75F, 0.375F, 0.75F); block.setBlockBoundsForItemRender(); diff --git a/common/buildcraft/transport/render/TileEntityPickupFX.java b/common/buildcraft/transport/render/TileEntityPickupFX.java index d5ac1411..9e7c5a3e 100644 --- a/common/buildcraft/transport/render/TileEntityPickupFX.java +++ b/common/buildcraft/transport/render/TileEntityPickupFX.java @@ -1,5 +1,5 @@ /** - * Copyright (c) SpaceToad, 2011 + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com * * BuildCraft is distributed under the terms of the Minecraft Mod Public diff --git a/common/buildcraft/transport/triggers/ActionEnergyPulsar.java b/common/buildcraft/transport/triggers/ActionEnergyPulsar.java index 8b44fee3..4245b08d 100644 --- a/common/buildcraft/transport/triggers/ActionEnergyPulsar.java +++ b/common/buildcraft/transport/triggers/ActionEnergyPulsar.java @@ -1,21 +1,29 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.transport.triggers; -import net.minecraft.client.renderer.texture.IconRegister; -import net.minecraft.util.Icon; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.util.IIcon; import buildcraft.core.triggers.ActionTriggerIconProvider; import buildcraft.core.triggers.BCAction; import buildcraft.core.utils.StringUtils; public class ActionEnergyPulsar extends BCAction { - private Icon icon; + private IIcon icon; public ActionEnergyPulsar() { super("buildcraft:pulsar.constant", "buildcraft.pulser.constant"); } @Override - public Icon getIcon() { + public IIcon getIcon() { return icon; } @@ -25,7 +33,7 @@ public class ActionEnergyPulsar extends BCAction { } @Override - public void registerIcons(IconRegister iconRegister) { + public void registerIcons(IIconRegister iconRegister) { icon = iconRegister.registerIcon("buildcraft:triggers/action_pulsar"); } diff --git a/common/buildcraft/transport/triggers/ActionExtractionPreset.java b/common/buildcraft/transport/triggers/ActionExtractionPreset.java index cc6ceedc..d201c1e2 100644 --- a/common/buildcraft/transport/triggers/ActionExtractionPreset.java +++ b/common/buildcraft/transport/triggers/ActionExtractionPreset.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.transport.triggers; @@ -11,12 +12,12 @@ import buildcraft.core.triggers.BCAction; import buildcraft.core.utils.EnumColor; import buildcraft.core.utils.StringUtils; import java.util.Locale; -import net.minecraft.client.renderer.texture.IconRegister; -import net.minecraft.util.Icon; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.util.IIcon; public class ActionExtractionPreset extends BCAction { - private Icon icon; + private IIcon icon; public final EnumColor color; public ActionExtractionPreset(EnumColor color) { @@ -31,12 +32,12 @@ public class ActionExtractionPreset extends BCAction { } @Override - public Icon getIcon() { + public IIcon getIcon() { return icon; } @Override - public void registerIcons(IconRegister iconRegister) { + public void registerIcons(IIconRegister iconRegister) { icon = iconRegister.registerIcon("buildcraft:triggers/extraction_preset_" + color.name().toLowerCase(Locale.ENGLISH)); } } diff --git a/common/buildcraft/transport/triggers/ActionPipeColor.java b/common/buildcraft/transport/triggers/ActionPipeColor.java index d70fbe99..f7ec1741 100644 --- a/common/buildcraft/transport/triggers/ActionPipeColor.java +++ b/common/buildcraft/transport/triggers/ActionPipeColor.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.transport.triggers; @@ -11,12 +12,12 @@ import buildcraft.core.triggers.BCAction; import buildcraft.core.utils.EnumColor; import buildcraft.core.utils.StringUtils; import java.util.Locale; -import net.minecraft.client.renderer.texture.IconRegister; -import net.minecraft.util.Icon; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.util.IIcon; public class ActionPipeColor extends BCAction { - private Icon icon; + private IIcon icon; public final EnumColor color; public ActionPipeColor(EnumColor color) { @@ -31,12 +32,12 @@ public class ActionPipeColor extends BCAction { } @Override - public Icon getIcon() { + public IIcon getIcon() { return icon; } @Override - public void registerIcons(IconRegister iconRegister) { + public void registerIcons(IIconRegister iconRegister) { icon = iconRegister.registerIcon("buildcraft:triggers/color_" + color.name().toLowerCase(Locale.ENGLISH)); } } diff --git a/common/buildcraft/transport/triggers/ActionPipeDirection.java b/common/buildcraft/transport/triggers/ActionPipeDirection.java index 1759a1a3..602a0f1a 100644 --- a/common/buildcraft/transport/triggers/ActionPipeDirection.java +++ b/common/buildcraft/transport/triggers/ActionPipeDirection.java @@ -1,21 +1,22 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.transport.triggers; import buildcraft.core.triggers.BCAction; import java.util.Locale; -import net.minecraft.client.renderer.texture.IconRegister; -import net.minecraft.util.Icon; -import net.minecraftforge.common.ForgeDirection; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.util.IIcon; +import net.minecraftforge.common.util.ForgeDirection; public class ActionPipeDirection extends BCAction { - private Icon icon; + private IIcon icon; public final ForgeDirection direction; public ActionPipeDirection(ForgeDirection direction) { @@ -30,12 +31,12 @@ public class ActionPipeDirection extends BCAction { } @Override - public Icon getIcon() { + public IIcon getIcon() { return icon; } @Override - public void registerIcons(IconRegister iconRegister) { + public void registerIcons(IIconRegister iconRegister) { icon = iconRegister.registerIcon("buildcraft:triggers/trigger_dir_" + direction.name().toLowerCase(Locale.ENGLISH)); } } diff --git a/common/buildcraft/transport/triggers/ActionPowerLimiter.java b/common/buildcraft/transport/triggers/ActionPowerLimiter.java index cef377e9..63887870 100644 --- a/common/buildcraft/transport/triggers/ActionPowerLimiter.java +++ b/common/buildcraft/transport/triggers/ActionPowerLimiter.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.transport.triggers; @@ -10,12 +11,12 @@ package buildcraft.transport.triggers; import buildcraft.core.triggers.BCAction; import buildcraft.transport.pipes.PipePowerIron.PowerMode; import java.util.Locale; -import net.minecraft.client.renderer.texture.IconRegister; -import net.minecraft.util.Icon; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.util.IIcon; public class ActionPowerLimiter extends BCAction { - private Icon icon; + private IIcon icon; public final PowerMode limit; public ActionPowerLimiter(PowerMode limit) { @@ -30,12 +31,12 @@ public class ActionPowerLimiter extends BCAction { } @Override - public Icon getIcon() { + public IIcon getIcon() { return icon; } @Override - public void registerIcons(IconRegister iconRegister) { + public void registerIcons(IIconRegister iconRegister) { icon = iconRegister.registerIcon("buildcraft:triggers/trigger_limiter_" + limit.name().toLowerCase(Locale.ENGLISH)); } } diff --git a/common/buildcraft/transport/triggers/ActionRedstoneFaderOutput.java b/common/buildcraft/transport/triggers/ActionRedstoneFaderOutput.java index 6ec826fd..291422db 100644 --- a/common/buildcraft/transport/triggers/ActionRedstoneFaderOutput.java +++ b/common/buildcraft/transport/triggers/ActionRedstoneFaderOutput.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.transport.triggers; @@ -11,14 +12,14 @@ import buildcraft.core.triggers.BCAction; import buildcraft.core.utils.StringUtils; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.client.renderer.texture.IconRegister; -import net.minecraft.util.Icon; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.util.IIcon; public class ActionRedstoneFaderOutput extends BCAction { public final int level; @SideOnly(Side.CLIENT) - private Icon icon; + private IIcon icon; public ActionRedstoneFaderOutput(int level) { super(String.format("buildcraft:redstone.output.%02d", level)); @@ -33,13 +34,13 @@ public class ActionRedstoneFaderOutput extends BCAction { @Override @SideOnly(Side.CLIENT) - public Icon getIcon() { + public IIcon getIcon() { return icon; } @Override @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister iconRegister) { + public void registerIcons(IIconRegister iconRegister) { icon = iconRegister.registerIcon(String.format("buildcraft:triggers/redstone_%02d", level)); } } diff --git a/common/buildcraft/transport/triggers/ActionSignalOutput.java b/common/buildcraft/transport/triggers/ActionSignalOutput.java index 1efb4df9..45c093e5 100644 --- a/common/buildcraft/transport/triggers/ActionSignalOutput.java +++ b/common/buildcraft/transport/triggers/ActionSignalOutput.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.transport.triggers; diff --git a/common/buildcraft/transport/triggers/ActionSingleEnergyPulse.java b/common/buildcraft/transport/triggers/ActionSingleEnergyPulse.java index 6d9fc51b..673ce0b5 100644 --- a/common/buildcraft/transport/triggers/ActionSingleEnergyPulse.java +++ b/common/buildcraft/transport/triggers/ActionSingleEnergyPulse.java @@ -1,21 +1,29 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.transport.triggers; -import net.minecraft.client.renderer.texture.IconRegister; -import net.minecraft.util.Icon; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.util.IIcon; import buildcraft.core.triggers.ActionTriggerIconProvider; import buildcraft.core.triggers.BCAction; import buildcraft.core.utils.StringUtils; public class ActionSingleEnergyPulse extends BCAction { - private Icon icon; + private IIcon icon; public ActionSingleEnergyPulse() { super("buildcraft:pulsar.single", "buildcraft.pulser.single"); } @Override - public Icon getIcon() { + public IIcon getIcon() { return icon; } @@ -25,7 +33,7 @@ public class ActionSingleEnergyPulse extends BCAction { } @Override - public void registerIcons(IconRegister iconRegister) { + public void registerIcons(IIconRegister iconRegister) { icon = iconRegister.registerIcon("buildcraft:triggers/action_single_pulsar"); } diff --git a/common/buildcraft/transport/triggers/TriggerClockTimer.java b/common/buildcraft/transport/triggers/TriggerClockTimer.java index f9b88b16..88b35f03 100644 --- a/common/buildcraft/transport/triggers/TriggerClockTimer.java +++ b/common/buildcraft/transport/triggers/TriggerClockTimer.java @@ -1,11 +1,19 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.transport.triggers; import java.util.Locale; import buildcraft.core.triggers.BCTrigger; import buildcraft.core.utils.StringUtils; -import net.minecraft.client.renderer.texture.IconRegister; -import net.minecraft.util.Icon; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.util.IIcon; public class TriggerClockTimer extends BCTrigger { @@ -20,7 +28,7 @@ public class TriggerClockTimer extends BCTrigger { } } public final Time time; - private Icon icon; + private IIcon icon; public TriggerClockTimer(Time time) { super("buildcraft:timer." + time.name().toLowerCase(Locale.ENGLISH)); @@ -29,7 +37,7 @@ public class TriggerClockTimer extends BCTrigger { } @Override - public Icon getIcon() { + public IIcon getIcon() { return icon; } @@ -39,7 +47,7 @@ public class TriggerClockTimer extends BCTrigger { } @Override - public void registerIcons(IconRegister iconRegister) { + public void registerIcons(IIconRegister iconRegister) { icon = iconRegister.registerIcon("buildcraft:triggers/trigger_timer_" + time.name().toLowerCase(Locale.ENGLISH)); } } diff --git a/common/buildcraft/transport/triggers/TriggerPipeContents.java b/common/buildcraft/transport/triggers/TriggerPipeContents.java index 75574c8f..af0d66d8 100644 --- a/common/buildcraft/transport/triggers/TriggerPipeContents.java +++ b/common/buildcraft/transport/triggers/TriggerPipeContents.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.transport.triggers; @@ -20,9 +21,9 @@ import buildcraft.transport.pipes.PipePowerWood; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import java.util.Locale; -import net.minecraft.client.renderer.texture.IconRegister; -import net.minecraft.util.Icon; -import net.minecraftforge.common.ForgeDirection; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.util.IIcon; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; @@ -40,7 +41,7 @@ public class TriggerPipeContents extends BCTrigger implements IPipeTrigger { public BCTrigger trigger; }; private PipeContents kind; - private Icon icon; + private IIcon icon; public TriggerPipeContents(PipeContents kind) { super("buildcraft:pipe.contents." + kind.name().toLowerCase(Locale.ENGLISH), "buildcraft.pipe.contents." + kind.name()); @@ -74,7 +75,7 @@ public class TriggerPipeContents extends BCTrigger implements IPipeTrigger { else if (kind == PipeContents.containsItems) if (parameter != null && parameter.getItemStack() != null) { for (TravelingItem item : transportItems.items) { - if (item.getItemStack().itemID == parameter.getItemStack().itemID + if (item.getItemStack().getItem() == parameter.getItemStack().getItem() && item.getItemStack().getItemDamage() == parameter.getItemStack().getItemDamage()) return true; } @@ -136,13 +137,13 @@ public class TriggerPipeContents extends BCTrigger implements IPipeTrigger { } @Override - public Icon getIcon() { + public IIcon getIcon() { return icon; } @Override @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister iconRegister) { + public void registerIcons(IIconRegister iconRegister) { icon = iconRegister.registerIcon("buildcraft:triggers/trigger_pipecontents_" + kind.name().toLowerCase(Locale.ENGLISH)); } } diff --git a/common/buildcraft/transport/triggers/TriggerPipeSignal.java b/common/buildcraft/transport/triggers/TriggerPipeSignal.java index 146a2903..01744b82 100644 --- a/common/buildcraft/transport/triggers/TriggerPipeSignal.java +++ b/common/buildcraft/transport/triggers/TriggerPipeSignal.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.transport.triggers; diff --git a/common/buildcraft/transport/triggers/TriggerRedstoneFaderInput.java b/common/buildcraft/transport/triggers/TriggerRedstoneFaderInput.java index 34b14ca5..580c1b94 100644 --- a/common/buildcraft/transport/triggers/TriggerRedstoneFaderInput.java +++ b/common/buildcraft/transport/triggers/TriggerRedstoneFaderInput.java @@ -1,8 +1,9 @@ /** - * Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com * - * BuildCraft is distributed under the terms of the Minecraft Mod Public License - * 1.0, or MMPL. Please check the contents of the license located in + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ package buildcraft.transport.triggers; @@ -14,14 +15,14 @@ import buildcraft.transport.IPipeTrigger; import buildcraft.transport.Pipe; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import net.minecraft.client.renderer.texture.IconRegister; -import net.minecraft.util.Icon; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.util.IIcon; public class TriggerRedstoneFaderInput extends BCTrigger implements IPipeTrigger { public final int level; @SideOnly(Side.CLIENT) - private Icon icon; + private IIcon icon; public TriggerRedstoneFaderInput(int level) { super(String.format("buildcraft:redtone.input.%02d", level)); @@ -41,13 +42,13 @@ public class TriggerRedstoneFaderInput extends BCTrigger implements IPipeTrigger @Override @SideOnly(Side.CLIENT) - public Icon getIcon() { + public IIcon getIcon() { return icon; } @Override @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister iconRegister) { + public void registerIcons(IIconRegister iconRegister) { icon = iconRegister.registerIcon(String.format("buildcraft:triggers/redstone_%02d", level)); } } diff --git a/common/buildcraft/transport/utils/BitSetCodec.java b/common/buildcraft/transport/utils/BitSetCodec.java index c843c565..f22977fb 100644 --- a/common/buildcraft/transport/utils/BitSetCodec.java +++ b/common/buildcraft/transport/utils/BitSetCodec.java @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.transport.utils; import java.util.BitSet; diff --git a/common/buildcraft/transport/utils/ConnectionMatrix.java b/common/buildcraft/transport/utils/ConnectionMatrix.java index dff1f469..e7b0c97c 100644 --- a/common/buildcraft/transport/utils/ConnectionMatrix.java +++ b/common/buildcraft/transport/utils/ConnectionMatrix.java @@ -1,9 +1,20 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.transport.utils; +import io.netty.buffer.ByteBuf; + import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; -import net.minecraftforge.common.ForgeDirection; + +import net.minecraftforge.common.util.ForgeDirection; public class ConnectionMatrix { private int mask = 0; @@ -39,11 +50,11 @@ public class ConnectionMatrix { dirty = false; } - public void writeData(DataOutputStream data) throws IOException { + public void writeData(ByteBuf data) { data.writeByte(mask); } - public void readData(DataInputStream data) throws IOException { + public void readData(ByteBuf data) { byte newMask = data.readByte(); if (newMask != mask) { diff --git a/common/buildcraft/transport/utils/FacadeMatrix.java b/common/buildcraft/transport/utils/FacadeMatrix.java index b4ce11d4..7083ec9d 100644 --- a/common/buildcraft/transport/utils/FacadeMatrix.java +++ b/common/buildcraft/transport/utils/FacadeMatrix.java @@ -1,29 +1,41 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.transport.utils; +import io.netty.buffer.ByteBuf; + import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; -import net.minecraftforge.common.ForgeDirection; + +import net.minecraft.block.Block; +import net.minecraftforge.common.util.ForgeDirection; public class FacadeMatrix { - private final int[] _blockIds = new int[ForgeDirection.VALID_DIRECTIONS.length]; + private final Block[] _blocks = new Block[ForgeDirection.VALID_DIRECTIONS.length]; private final int[] _blockMetas = new int[ForgeDirection.VALID_DIRECTIONS.length]; private boolean dirty = false; public FacadeMatrix() { } - public void setFacade(ForgeDirection direction, int blockId, int blockMeta) { - if (_blockIds[direction.ordinal()] != blockId || _blockMetas[direction.ordinal()] != blockMeta) { - _blockIds[direction.ordinal()] = blockId; + public void setFacade(ForgeDirection direction, Block block, int blockMeta) { + if (_blocks[direction.ordinal()] != block || _blockMetas[direction.ordinal()] != blockMeta) { + _blocks[direction.ordinal()] = block; _blockMetas[direction.ordinal()] = blockMeta; dirty = true; } } - public int getFacadeBlockId(ForgeDirection direction) { - return _blockIds[direction.ordinal()]; + public Block getFacadeBlock(ForgeDirection direction) { + return _blocks[direction.ordinal()]; } public int getFacadeMetaId(ForgeDirection direction) { @@ -38,18 +50,32 @@ public class FacadeMatrix { dirty = false; } - public void writeData(DataOutputStream data) throws IOException { + public void writeData(ByteBuf data) { for (int i = 0; i < ForgeDirection.VALID_DIRECTIONS.length; i++) { - data.writeShort(_blockIds[i]); + if (_blocks [i] == null) { + data.writeShort(0); + } else { + data.writeShort(Block.blockRegistry.getIDForObject(_blocks[i])); + } + data.writeByte(_blockMetas[i]); } } - public void readData(DataInputStream data) throws IOException { + public void readData(ByteBuf data) { for (int i = 0; i < ForgeDirection.VALID_DIRECTIONS.length; i++) { short id = data.readShort(); - if (_blockIds[i] != id) { - _blockIds[i] = id; + + Block block; + + if (id == 0) { + block = null; + } else { + block = (Block) Block.blockRegistry.getObjectById(id); + } + + if (_blocks[i] != block) { + _blocks[i] = block; dirty = true; } byte meta = data.readByte(); diff --git a/common/buildcraft/transport/utils/TextureMatrix.java b/common/buildcraft/transport/utils/TextureMatrix.java index 2da1e5d7..5fee384d 100644 --- a/common/buildcraft/transport/utils/TextureMatrix.java +++ b/common/buildcraft/transport/utils/TextureMatrix.java @@ -1,9 +1,20 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.transport.utils; +import io.netty.buffer.ByteBuf; + import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; -import net.minecraftforge.common.ForgeDirection; + +import net.minecraftforge.common.util.ForgeDirection; public class TextureMatrix { @@ -29,13 +40,13 @@ public class TextureMatrix { dirty = false; } - public void writeData(DataOutputStream data) throws IOException { + public void writeData(ByteBuf data) { for (int i = 0; i < _iconIndexes.length; i++) { data.writeByte(_iconIndexes[i]); } } - public void readData(DataInputStream data) throws IOException { + public void readData(ByteBuf data) { for (int i = 0; i < _iconIndexes.length; i++) { int icon = data.readByte(); if (_iconIndexes[i] != icon) { diff --git a/common/buildcraft/transport/utils/TransportUtils.java b/common/buildcraft/transport/utils/TransportUtils.java index fb601108..20924920 100644 --- a/common/buildcraft/transport/utils/TransportUtils.java +++ b/common/buildcraft/transport/utils/TransportUtils.java @@ -1,7 +1,7 @@ -/* - * Copyright (c) SpaceToad, 2011-2012 +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team * http://www.mod-buildcraft.com - * + * * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt @@ -11,10 +11,6 @@ package buildcraft.transport.utils; import buildcraft.core.CoreConstants; import net.minecraft.item.ItemStack; -/** - * - * @author CovertJaguar - */ public class TransportUtils { /** diff --git a/common/buildcraft/transport/utils/WireMatrix.java b/common/buildcraft/transport/utils/WireMatrix.java index 1837278a..1e2c5ad0 100644 --- a/common/buildcraft/transport/utils/WireMatrix.java +++ b/common/buildcraft/transport/utils/WireMatrix.java @@ -1,12 +1,23 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ package buildcraft.transport.utils; import buildcraft.transport.Pipe; import buildcraft.api.transport.PipeWire; +import io.netty.buffer.ByteBuf; + import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.util.BitSet; -import net.minecraftforge.common.ForgeDirection; + +import net.minecraftforge.common.util.ForgeDirection; public class WireMatrix { @@ -72,7 +83,7 @@ public class WireMatrix { dirty = false; } - public void writeData(DataOutputStream data) throws IOException { + public void writeData(ByteBuf data) { data.writeByte(_bitSetCodec.encode(_hasWire)); for (int i = 0; i < PipeWire.values().length; i++) { @@ -81,7 +92,7 @@ public class WireMatrix { } } - public void readData(DataInputStream data) throws IOException { + public void readData(ByteBuf data) { _bitSetCodec.decode(data.readByte(), _hasWire); for (int i = 0; i < PipeWire.values().length; i++) { _wires[i].readData(data);