diff --git a/build.properties b/build.properties index bf1323f..cb84560 100644 --- a/build.properties +++ b/build.properties @@ -1,6 +1,6 @@ mod_version=1.5.0 -minecraft_version=1.10.2 -forge_version=12.18.0.2007-1.10.0 -mappings=snapshot_20160518 +minecraft_version=1.11.2 +forge_version=13.20.0.2255 +mappings=snapshot_20161220 -jei_version=3.7.+ \ No newline at end of file +jei_version=4.2.+ \ No newline at end of file diff --git a/src/main/java/com/renevo/pcb/ClientProxy.java b/src/main/java/com/renevo/pcb/ClientProxy.java index c681923..224eded 100644 --- a/src/main/java/com/renevo/pcb/ClientProxy.java +++ b/src/main/java/com/renevo/pcb/ClientProxy.java @@ -4,9 +4,9 @@ import net.minecraft.client.renderer.block.model.ModelResourceLocation; public class ClientProxy extends CommonProxy { - - @Override - public void initialization() { - Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(ItemPortableCraftBench.portableCraftBench, 0, new ModelResourceLocation(PortableCraftBenchMod.MODID + ":" + "portableCraftBench", "inventory")); - } + + @Override + public void initialization() { + Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(ItemPortableCraftBench.portableCraftBench, 0, new ModelResourceLocation(PortableCraftBenchMod.MODID + ":" + "portable_craft_bench", "inventory")); + } } diff --git a/src/main/java/com/renevo/pcb/CommonProxy.java b/src/main/java/com/renevo/pcb/CommonProxy.java index 9e683bd..ce5e0b4 100644 --- a/src/main/java/com/renevo/pcb/CommonProxy.java +++ b/src/main/java/com/renevo/pcb/CommonProxy.java @@ -2,11 +2,11 @@ public class CommonProxy { - public void postInitialization() { - - } - - public void initialization() { - - } + public void postInitialization() { + + } + + public void initialization() { + + } } diff --git a/src/main/java/com/renevo/pcb/ContainerPortableCraftBench.java b/src/main/java/com/renevo/pcb/ContainerPortableCraftBench.java index 07b015e..6a45db0 100644 --- a/src/main/java/com/renevo/pcb/ContainerPortableCraftBench.java +++ b/src/main/java/com/renevo/pcb/ContainerPortableCraftBench.java @@ -9,60 +9,60 @@ public class ContainerPortableCraftBench extends net.minecraft.inventory.ContainerWorkbench { - public ContainerPortableCraftBench(InventoryPlayer inventoryPlayer, World world, BlockPos pos) { - super(inventoryPlayer, world, pos); - } + public ContainerPortableCraftBench(InventoryPlayer inventoryPlayer, World world, BlockPos pos) { + super(inventoryPlayer, world, pos); + } - /** - * Called to transfer a stack from one inventory to the other eg. when shift - * clicking. - */ - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotIndex) { - ItemStack var2 = null; - Slot var3 = (Slot) this.inventorySlots.get(slotIndex); + /** + * Called to transfer a stack from one inventory to the other eg. when shift + * clicking. + */ + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotIndex) { + ItemStack stack = null; + Slot slot = this.inventorySlots.get(slotIndex); - if (var3 != null && var3.getHasStack()) { - ItemStack var4 = var3.getStack(); - var2 = var4.copy(); + if (slot != null && slot.getHasStack()) { + ItemStack slotStack = slot.getStack(); + stack = slotStack.copy(); - if (slotIndex == 0) { - if (!this.mergeItemStack(var4, 10, 46, true)) { - return null; - } + if (slotIndex == 0) { + if (!this.mergeItemStack(slotStack, 10, 46, true)) { + return null; + } - var3.onSlotChange(var4, var2); - } else if (slotIndex >= 10 && slotIndex < 37) { - if (!this.mergeItemStack(var4, 1, 10, false)) { - return null; - } - } else if (slotIndex >= 37 && slotIndex < 46) { - if (!this.mergeItemStack(var4, 1, 10, false)) { - return null; - } - } else if (!this.mergeItemStack(var4, 10, 46, false)) { - return null; - } + slot.onSlotChange(slotStack, stack); + } else if (slotIndex >= 10 && slotIndex < 37) { + if (!this.mergeItemStack(slotStack, 1, 10, false)) { + return null; + } + } else if (slotIndex >= 37 && slotIndex < 46) { + if (!this.mergeItemStack(slotStack, 1, 10, false)) { + return null; + } + } else if (!this.mergeItemStack(slotStack, 10, 46, false)) { + return null; + } - if (var4.stackSize == 0) { - var3.putStack((ItemStack) null); - } else { - var3.onSlotChanged(); - } + if (slotStack.isEmpty()) { + slot.putStack(ItemStack.EMPTY); + } else { + slot.onSlotChanged(); + } - if (var4.stackSize == var2.stackSize) { - return null; - } + if (slotStack.getCount() == stack.getCount()) { + return null; + } - var3.onPickupFromSlot(player, var4); - } + slot.onTake(player, slotStack); + } - return var2; - } + return stack; + } - @Override - public boolean canInteractWith(EntityPlayer arg0) { - return true; - } + @Override + public boolean canInteractWith(EntityPlayer arg0) { + return true; + } } diff --git a/src/main/java/com/renevo/pcb/GuiPortableCraftBench.java b/src/main/java/com/renevo/pcb/GuiPortableCraftBench.java index 2a37687..8ff364b 100644 --- a/src/main/java/com/renevo/pcb/GuiPortableCraftBench.java +++ b/src/main/java/com/renevo/pcb/GuiPortableCraftBench.java @@ -10,27 +10,27 @@ public class GuiPortableCraftBench extends GuiContainer { - private static final ResourceLocation backgroundResourceLocation = new ResourceLocation("textures/gui/container/crafting_table.png"); - - public GuiPortableCraftBench(InventoryPlayer playerInventory, World world, BlockPos pos) { - super(new ContainerPortableCraftBench(playerInventory, world, pos)); - } - - @Override - protected void drawGuiContainerForegroundLayer(int par1, int par2) { - this.fontRendererObj.drawString(I18n.translateToLocal(ItemPortableCraftBench.portableCraftBench.getUnlocalizedName() + ".name"), 8, 6, 4210752); - this.fontRendererObj.drawString(I18n.translateToLocal("container.inventory"), 8, this.ySize - 96 + 2, 4210752); - } - - @Override - protected void drawGuiContainerBackgroundLayer(float arg0, int arg1, int arg2) { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - this.mc.renderEngine.bindTexture(backgroundResourceLocation); - - int j = (this.width - this.xSize) / 2; - int k = (this.height - this.ySize) / 2; - - this.drawTexturedModalRect(j, k, 0, 0, this.xSize, this.ySize); - } + private static final ResourceLocation backgroundResourceLocation = new ResourceLocation("textures/gui/container/crafting_table.png"); + + public GuiPortableCraftBench(InventoryPlayer playerInventory, World world, BlockPos pos) { + super(new ContainerPortableCraftBench(playerInventory, world, pos)); + } + + @Override + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + this.fontRendererObj.drawString(I18n.translateToLocal(ItemPortableCraftBench.portableCraftBench.getUnlocalizedName() + ".name"), 8, 6, 4210752); + this.fontRendererObj.drawString(I18n.translateToLocal("container.inventory"), 8, this.ySize - 96 + 2, 4210752); + } + + @Override + protected void drawGuiContainerBackgroundLayer(float arg0, int arg1, int arg2) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.renderEngine.bindTexture(backgroundResourceLocation); + + int j = (this.width - this.xSize) / 2; + int k = (this.height - this.ySize) / 2; + + this.drawTexturedModalRect(j, k, 0, 0, this.xSize, this.ySize); + } } diff --git a/src/main/java/com/renevo/pcb/ItemPortableCraftBench.java b/src/main/java/com/renevo/pcb/ItemPortableCraftBench.java index f419a1b..016699d 100644 --- a/src/main/java/com/renevo/pcb/ItemPortableCraftBench.java +++ b/src/main/java/com/renevo/pcb/ItemPortableCraftBench.java @@ -14,38 +14,37 @@ public class ItemPortableCraftBench extends Item { - public static Item portableCraftBench; - - public static void create() { - portableCraftBench = new ItemPortableCraftBench(); - portableCraftBench.setRegistryName("portableCraftBench"); + public static Item portableCraftBench; + + public static void create() { + portableCraftBench = new ItemPortableCraftBench(); + portableCraftBench.setRegistryName("portable_craft_bench"); GameRegistry.register(portableCraftBench); - GameRegistry.addShapelessRecipe( - new ItemStack(portableCraftBench), - new Object[] { - Blocks.CRAFTING_TABLE, - Items.STRING - }); - - // adds the pcb as a workbench in the Ore Dictionary - OreDictionary.registerOre("workbench", portableCraftBench); - } - - public ItemPortableCraftBench() { - super(); - - super.setMaxStackSize(1); - super.setUnlocalizedName("portableCraftBench"); - super.setCreativeTab(CreativeTabs.TOOLS); - } - - @Override - public ActionResult onItemRightClick(ItemStack itemStack, World world, EntityPlayer player, EnumHand hand) { - if (world.isRemote) { - return ActionResult.newResult(EnumActionResult.SUCCESS, itemStack); - } else { - player.openGui(PortableCraftBenchMod.instance, PortableCraftBenchMod.GUI_PORTABLE_CRAFT_BENCH_ID, world, 0, 0, 0); - return ActionResult.newResult(EnumActionResult.SUCCESS, itemStack); - } - } + GameRegistry.addShapelessRecipe( + new ItemStack(portableCraftBench), + Blocks.CRAFTING_TABLE, + Items.STRING); + + // adds the pcb as a workbench in the Ore Dictionary + OreDictionary.registerOre("workbench", portableCraftBench); + } + + public ItemPortableCraftBench() { + super(); + + super.setMaxStackSize(1); + super.setUnlocalizedName("portable_craft_bench"); + super.setCreativeTab(CreativeTabs.TOOLS); + } + + @Override + public ActionResult onItemRightClick(World world, EntityPlayer player, EnumHand hand) { + ItemStack item = player.getHeldItem(hand); + + if (!world.isRemote && item.getItem() == this) { + player.openGui(PortableCraftBenchMod.instance, PortableCraftBenchMod.GUI_PORTABLE_CRAFT_BENCH_ID, world, 0, 0, 0); + } + + return new ActionResult(EnumActionResult.SUCCESS, item); + } } diff --git a/src/main/java/com/renevo/pcb/PortableCraftBenchGuiHandler.java b/src/main/java/com/renevo/pcb/PortableCraftBenchGuiHandler.java index 35f2794..9f2bf1c 100644 --- a/src/main/java/com/renevo/pcb/PortableCraftBenchGuiHandler.java +++ b/src/main/java/com/renevo/pcb/PortableCraftBenchGuiHandler.java @@ -8,25 +8,25 @@ public class PortableCraftBenchGuiHandler implements IGuiHandler { - @Override - public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) { - if (id == PortableCraftBenchMod.GUI_PORTABLE_CRAFT_BENCH_ID && player.getHeldItemMainhand() != null && player.getHeldItemMainhand().getItem() == ItemPortableCraftBench.portableCraftBench) - return new GuiPortableCraftBench(player.inventory, world, new BlockPos(x, y, z)); + @Override + public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) { + if (id == PortableCraftBenchMod.GUI_PORTABLE_CRAFT_BENCH_ID && player.getHeldItemMainhand().getItem() == ItemPortableCraftBench.portableCraftBench) + return new GuiPortableCraftBench(player.inventory, world, new BlockPos(x, y, z)); - if (id == PortableCraftBenchMod.GUI_PORTABLE_CRAFT_BENCH_ID && player.getHeldItemOffhand() != null && player.getHeldItemOffhand().getItem() == ItemPortableCraftBench.portableCraftBench) - return new GuiPortableCraftBench(player.inventory, world, new BlockPos(x, y, z)); + if (id == PortableCraftBenchMod.GUI_PORTABLE_CRAFT_BENCH_ID && player.getHeldItemOffhand().getItem() == ItemPortableCraftBench.portableCraftBench) + return new GuiPortableCraftBench(player.inventory, world, new BlockPos(x, y, z)); - return null; - } + return null; + } - @Override - public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) { - if (id == PortableCraftBenchMod.GUI_PORTABLE_CRAFT_BENCH_ID && player.getHeldItemMainhand() != null && player.getHeldItemMainhand().getItem() == ItemPortableCraftBench.portableCraftBench) - return new ContainerPortableCraftBench(player.inventory, world, new BlockPos(x, y, z)); + @Override + public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) { + if (id == PortableCraftBenchMod.GUI_PORTABLE_CRAFT_BENCH_ID && player.getHeldItemMainhand().getItem() == ItemPortableCraftBench.portableCraftBench) + return new ContainerPortableCraftBench(player.inventory, world, new BlockPos(x, y, z)); - if (id == PortableCraftBenchMod.GUI_PORTABLE_CRAFT_BENCH_ID && player.getHeldItemOffhand() != null && player.getHeldItemOffhand().getItem() == ItemPortableCraftBench.portableCraftBench) - return new ContainerPortableCraftBench(player.inventory, world, new BlockPos(x, y, z)); + if (id == PortableCraftBenchMod.GUI_PORTABLE_CRAFT_BENCH_ID && player.getHeldItemOffhand().getItem() == ItemPortableCraftBench.portableCraftBench) + return new ContainerPortableCraftBench(player.inventory, world, new BlockPos(x, y, z)); - return null; - } + return null; + } } diff --git a/src/main/java/com/renevo/pcb/PortableCraftBenchMod.java b/src/main/java/com/renevo/pcb/PortableCraftBenchMod.java index e7f1366..cbdabed 100644 --- a/src/main/java/com/renevo/pcb/PortableCraftBenchMod.java +++ b/src/main/java/com/renevo/pcb/PortableCraftBenchMod.java @@ -11,44 +11,44 @@ @Mod(modid = PortableCraftBenchMod.MODID, version = PortableCraftBenchMod.VERSION) public class PortableCraftBenchMod { - + public static final String MODID = "pcb"; public static final String VERSION = "1.5.0"; - + public static Achievement achievementPcb = null; - + public static final int GUI_PORTABLE_CRAFT_BENCH_ID = 1; - + @Instance(PortableCraftBenchMod.MODID) public static PortableCraftBenchMod instance; - + @SidedProxy(clientSide = "com.renevo.pcb.ClientProxy", serverSide = "com.renevo.pcb.CommonProxy") public static CommonProxy proxy; - + @EventHandler public void init(FMLInitializationEvent event) { - ItemPortableCraftBench.create(); - - NetworkRegistry.INSTANCE.registerGuiHandler(instance, new PortableCraftBenchGuiHandler()); - - MinecraftForge.EVENT_BUS.register(this); - - // 6 left, 0 up/down - since we are just adding a new achievement, we don't need an achievement page, this somehow just works... - achievementPcb = new Achievement("achievement.pcb", "pcb", 5, -4, ItemPortableCraftBench.portableCraftBench, AchievementList.BUILD_WORK_BENCH); - achievementPcb.registerStat(); - - proxy.initialization(); + ItemPortableCraftBench.create(); + + NetworkRegistry.INSTANCE.registerGuiHandler(instance, new PortableCraftBenchGuiHandler()); + + MinecraftForge.EVENT_BUS.register(this); + + // 6 left, 0 up/down - since we are just adding a new achievement, we don't need an achievement page, this somehow just works... + achievementPcb = new Achievement("achievement.pcb", "pcb", 5, -4, ItemPortableCraftBench.portableCraftBench, AchievementList.BUILD_WORK_BENCH); + achievementPcb.registerStat(); + + proxy.initialization(); } - + @EventHandler public void postInit(FMLPostInitializationEvent event) { - proxy.postInitialization(); + proxy.postInitialization(); } - + @SubscribeEvent public void onCraftItem(PlayerEvent.ItemCraftedEvent event) { - if (event.crafting.getItem() == ItemPortableCraftBench.portableCraftBench) { - event.player.addStat(achievementPcb, 1); - } + if (event.crafting.getItem() == ItemPortableCraftBench.portableCraftBench) { + event.player.addStat(achievementPcb, 1); + } } } diff --git a/src/main/java/com/renevo/pcb/integration/PortableCraftBenchPlugin.java b/src/main/java/com/renevo/pcb/integration/PortableCraftBenchPlugin.java index 7b58658..1028fc8 100644 --- a/src/main/java/com/renevo/pcb/integration/PortableCraftBenchPlugin.java +++ b/src/main/java/com/renevo/pcb/integration/PortableCraftBenchPlugin.java @@ -4,13 +4,25 @@ import com.renevo.pcb.GuiPortableCraftBench; import mezz.jei.api.*; +import mezz.jei.api.ingredients.IModIngredientRegistration; import mezz.jei.api.recipe.VanillaRecipeCategoryUid; import mezz.jei.api.recipe.transfer.IRecipeTransferRegistry; @JEIPlugin public class PortableCraftBenchPlugin implements IModPlugin { @Override - public void onRuntimeAvailable(IJeiRuntime jeiRuntime) { } + public void onRuntimeAvailable(IJeiRuntime jeiRuntime) { + } + + @Override + public void registerItemSubtypes(ISubtypeRegistry subtypeRegistry) { + + } + + @Override + public void registerIngredients(IModIngredientRegistration registry) { + + } @Override public void register(IModRegistry registry) { diff --git a/src/main/resources/assets/pcb/lang/en_US.lang b/src/main/resources/assets/pcb/lang/en_US.lang index 9f81ae1..f270595 100644 --- a/src/main/resources/assets/pcb/lang/en_US.lang +++ b/src/main/resources/assets/pcb/lang/en_US.lang @@ -1,4 +1,4 @@ -item.portableCraftBench.name=Portable Crafting Bench +item.portable_craft_bench.name=Portable Crafting Bench achievement.pcb=Take it with you! achievement.pcb.desc=Craft a portable crafting bench with string and a workbench. \ No newline at end of file diff --git a/src/main/resources/assets/pcb/lang/ru_RU.lang b/src/main/resources/assets/pcb/lang/ru_RU.lang index c48bd18..58d7664 100644 --- a/src/main/resources/assets/pcb/lang/ru_RU.lang +++ b/src/main/resources/assets/pcb/lang/ru_RU.lang @@ -1,4 +1,4 @@ -item.portableCraftBench.name=Карманный верстак +item.portable_craft_bench.name=Карманный верстак achievement.pcb=Возьми его с собой! achievement.pcb.desc=Собери карманный верстак из обычного верстака и нитки diff --git a/src/main/resources/assets/pcb/models/item/portableCraftBench.json b/src/main/resources/assets/pcb/models/item/portable_craft_bench.json similarity index 52% rename from src/main/resources/assets/pcb/models/item/portableCraftBench.json rename to src/main/resources/assets/pcb/models/item/portable_craft_bench.json index 6fa5958..540c0e9 100644 --- a/src/main/resources/assets/pcb/models/item/portableCraftBench.json +++ b/src/main/resources/assets/pcb/models/item/portable_craft_bench.json @@ -1,6 +1,6 @@ { "parent": "item/generated", "textures": { - "layer0": "pcb:items/portableCraftBench" + "layer0": "pcb:items/portable_craft_bench" } } \ No newline at end of file diff --git a/src/main/resources/assets/pcb/textures/items/portableCraftBench.png b/src/main/resources/assets/pcb/textures/items/portable_craft_bench.png similarity index 100% rename from src/main/resources/assets/pcb/textures/items/portableCraftBench.png rename to src/main/resources/assets/pcb/textures/items/portable_craft_bench.png