From 9f20575875b70077fd58eb78140b4a0eca8347cc Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Wed, 15 Jul 2015 01:53:04 +0200 Subject: [PATCH] Finished XP Solidifier --- InterModCommsInfo.md | 9 +++++---- .../ellpeck/actuallyadditions/blocks/InitBlocks.java | 6 +++--- .../actuallyadditions/inventory/gui/GuiXPSolidifier.java | 4 ++-- .../actuallyadditions/tile/TileEntityXPSolidifier.java | 8 ++++++-- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/InterModCommsInfo.md b/InterModCommsInfo.md index 8befdd7a3..8b63610e8 100644 --- a/InterModCommsInfo.md +++ b/InterModCommsInfo.md @@ -5,11 +5,12 @@ Actually Additions adds an InterModCommunications Feature that allows you to add To use these Features, just send an InterModComms Message in your preInit or init like this: FMLInterModComms.sendMessage("ActuallyAdditions", [X], [Y]); +This Message has to be sent BEFORE FMLPostInitializationEvent! The two Brackets will have to get replaced with one of the parts of Information below. ##### Crusher Recipes - Create an NBTTagCompound -- To the Compound, add an NBTTagCompound with the name "input" that contains the Input ItemStack saved to NBT (To do this, just use ItemStack.saveToNBT) +- To the Compound, add an NBTTagCompound with the name "input" that contains the Input ItemStack saved to NBT (To do this, just use ItemStack.writeToNBT) - To the Compound, add an NBTTagCompound with the name "outputOne" that contains the first Output saved to NBT - To the Compound, add an NBTTagCompound with the name "outputTwo" that contains the second Output saved to NBT - To the Compound, add an int with the name "secondChance" that contains the Chance for the second Output to appear @@ -17,7 +18,7 @@ The two Brackets will have to get replaced with one of the parts of Information ##### Coffee Machine Recipes - Create an NBTTagCompound -- To the Compound, add an NBTTagCompound with the name "input" that contains the Input ItemStack saved to NBT (To do this, just use ItemStack.saveToNBT) +- To the Compound, add an NBTTagCompound with the name "input" that contains the Input ItemStack saved to NBT (To do this, just use ItemStack.writeToNBT) - To the Compound, add an int with the name "id" that contains the ID of the Effect the Coffee should have (Look up the Effects in Minecraft's Potion Class!) - To the Compound, add an int with the name "duration" that contains the Duration the Effect should have - To the Compound, add an int with the name "amplifier" that contains the Amplifier the Effect should have (Remember: 0 = Level 1!) @@ -26,13 +27,13 @@ The two Brackets will have to get replaced with one of the parts of Information ##### Ball of Hair Recipes - Create an NBTTagCompound -- To the Compound, add an NBTTagCompound with the name "output" that contains the Input ItemStack saved to NBT (To do this, just use ItemStack.saveToNBT) +- To the Compound, add an NBTTagCompound with the name "output" that contains the Input ItemStack saved to NBT (To do this, just use ItemStack.writeToNBT) - To the Compound, add an int with the name "chance" that contains the Chance of the Item appearing - Send the Message with "registerBallOfHairRecipe" as the [X] Argument, the Compound as the [Y] Argument. ##### Treasure Chest Recipes - Create an NBTTagCompound -- To the Compound, add an NBTTagCompound with the name "output" that contains the Input ItemStack saved to NBT (To do this, just use ItemStack.saveToNBT) +- To the Compound, add an NBTTagCompound with the name "output" that contains the Input ItemStack saved to NBT (To do this, just use ItemStack.writeToNBT) - To the Compound, add an int with the name "chance" that contains the Chance of the Item appearing - To the Compound, add an int with the name "minAmount" that contains the minimum size of the ItemStack - To the Compound, add an int with the name "maxAmount" that contains the maximum size of the ItemStack diff --git a/src/main/java/ellpeck/actuallyadditions/blocks/InitBlocks.java b/src/main/java/ellpeck/actuallyadditions/blocks/InitBlocks.java index a4fdac8cc..241169fb6 100644 --- a/src/main/java/ellpeck/actuallyadditions/blocks/InitBlocks.java +++ b/src/main/java/ellpeck/actuallyadditions/blocks/InitBlocks.java @@ -80,13 +80,13 @@ public class InitBlocks{ public static Block blockTreasureChest; - //public static Block blockXPSolidifier; + public static Block blockXPSolidifier; public static void init(){ ModUtil.LOGGER.info("Initializing Blocks..."); - //blockXPSolidifier = new BlockXPSolidifier(); - //BlockUtil.register(blockXPSolidifier, BlockXPSolidifier.TheItemBlock.class); + blockXPSolidifier = new BlockXPSolidifier(); + BlockUtil.register(blockXPSolidifier, BlockXPSolidifier.TheItemBlock.class); blockTestifiBucksGreenWall = new BlockGeneric("blockTestifiBucksGreenWall"); BlockUtil.register(blockTestifiBucksGreenWall, BlockGeneric.TheItemBlock.class); diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiXPSolidifier.java b/src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiXPSolidifier.java index bdc921ac1..a790dec2b 100644 --- a/src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiXPSolidifier.java +++ b/src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiXPSolidifier.java @@ -53,7 +53,7 @@ public class GuiXPSolidifier extends GuiContainer{ GuiButton buttonForty = new GuiInputter.SmallerButton(5, guiLeft+99, guiTop+61, "40"); GuiButton buttonFifty = new GuiInputter.SmallerButton(6, guiLeft+62, guiTop+78, "50"); GuiButton buttonSixtyFour = new GuiInputter.SmallerButton(7, guiLeft+80, guiTop+78, "64"); - GuiButton buttonThousandTwentyEight = new GuiInputter.SmallerButton(8, guiLeft+99, guiTop+78, "All"); + GuiButton buttonAll = new GuiInputter.SmallerButton(8, guiLeft+99, guiTop+78, "All"); this.buttonList.add(buttonOne); this.buttonList.add(buttonFive); @@ -63,7 +63,7 @@ public class GuiXPSolidifier extends GuiContainer{ this.buttonList.add(buttonForty); this.buttonList.add(buttonFifty); this.buttonList.add(buttonSixtyFour); - this.buttonList.add(buttonThousandTwentyEight); + this.buttonList.add(buttonAll); } @Override diff --git a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityXPSolidifier.java b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityXPSolidifier.java index c4a2f8eab..0414ce095 100644 --- a/src/main/java/ellpeck/actuallyadditions/tile/TileEntityXPSolidifier.java +++ b/src/main/java/ellpeck/actuallyadditions/tile/TileEntityXPSolidifier.java @@ -76,14 +76,18 @@ public class TileEntityXPSolidifier extends TileEntityInventoryBase implements I @Override public void onButtonPressed(int buttonID, EntityPlayer player){ if(buttonID < this.buttonAmounts.length){ - if(buttonAmounts[buttonID] != -999){ + if(this.buttonAmounts[buttonID] != -999){ if(this.amount < Short.MAX_VALUE-this.buttonAmounts[buttonID] && this.getPlayerXP(player) >= ItemSpecialDrop.SOLID_XP_AMOUNT*this.buttonAmounts[buttonID]){ this.addPlayerXP(player, -(ItemSpecialDrop.SOLID_XP_AMOUNT*this.buttonAmounts[buttonID])); this.amount += this.buttonAmounts[buttonID]; } } else{ - + int xp = this.getPlayerXP(player)/ItemSpecialDrop.SOLID_XP_AMOUNT; + if(this.amount < Short.MAX_VALUE-xp){ + this.addPlayerXP(player, -(xp*ItemSpecialDrop.SOLID_XP_AMOUNT)); + this.amount += xp; + } } } }