Skip to content
This repository has been archived by the owner on Mar 9, 2024. It is now read-only.

Commit

Permalink
Updated for MC 1.11.2
Browse files Browse the repository at this point in the history
major changes were the item name, made it more consistent with vanilla (lower underscore separated).

Also tweaked the behaviour of the bench while holding to make it a bit more like the shield to hopefully stop some of the double hand bobbling, however it looks like some of that still exists with the shield as it sits.
  • Loading branch information
renevo committed Mar 8, 2017
1 parent bbbfd2d commit 4d66c01
Show file tree
Hide file tree
Showing 13 changed files with 171 additions and 160 deletions.
8 changes: 4 additions & 4 deletions build.properties
Original file line number Diff line number Diff line change
@@ -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.+
jei_version=4.2.+
10 changes: 5 additions & 5 deletions src/main/java/com/renevo/pcb/ClientProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
}
}
14 changes: 7 additions & 7 deletions src/main/java/com/renevo/pcb/CommonProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

public class CommonProxy {

public void postInitialization() {
}
public void initialization() {
}
public void postInitialization() {

}

public void initialization() {

}
}
92 changes: 46 additions & 46 deletions src/main/java/com/renevo/pcb/ContainerPortableCraftBench.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

}
44 changes: 22 additions & 22 deletions src/main/java/com/renevo/pcb/GuiPortableCraftBench.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

}
65 changes: 32 additions & 33 deletions src/main/java/com/renevo/pcb/ItemPortableCraftBench.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<ItemStack> 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<ItemStack> 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<ItemStack>(EnumActionResult.SUCCESS, item);
}
}
32 changes: 16 additions & 16 deletions src/main/java/com/renevo/pcb/PortableCraftBenchGuiHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
46 changes: 23 additions & 23 deletions src/main/java/com/renevo/pcb/PortableCraftBenchMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Loading

0 comments on commit 4d66c01

Please sign in to comment.