From 996de5673fa69397b5a062ab997c5e7917837c39 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Thu, 16 Jul 2015 16:52:28 +0200 Subject: [PATCH] Made the Drill recharge if you put Batteries into the Upgrade Slots. --- .../ellpeck/actuallyadditions/PLANNED.txt | 2 +- .../inventory/ContainerDrill.java | 5 ++-- .../actuallyadditions/items/InitItems.java | 12 +++++++-- .../actuallyadditions/items/ItemBattery.java | 9 ++++--- .../actuallyadditions/items/ItemDrill.java | 24 +++++++++++++++++- .../assets/actuallyadditions/lang/en_US.lang | 1 + .../blocks/blockColoredLampOrange.png | Bin 484 -> 470 bytes .../blocks/blockColoredLampOrangeOn.png | Bin 567 -> 514 bytes 8 files changed, 44 insertions(+), 9 deletions(-) diff --git a/src/main/java/ellpeck/actuallyadditions/PLANNED.txt b/src/main/java/ellpeck/actuallyadditions/PLANNED.txt index 51ac53d5c..9179031c3 100644 --- a/src/main/java/ellpeck/actuallyadditions/PLANNED.txt +++ b/src/main/java/ellpeck/actuallyadditions/PLANNED.txt @@ -77,7 +77,7 @@ -Ring of Aquadive: Fast underwater movement -Ring of Suction: Sucks up Items in the area -Ring of Water Absorption: Removes Water around - -Ring of Striptease (Or something like that): Attacker lose parts of their Armor + -Ring of Unarmoring: Attacker lose parts of their Armor -Food Cannon -Shoots Food Items diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/ContainerDrill.java b/src/main/java/ellpeck/actuallyadditions/inventory/ContainerDrill.java index e13662db8..679f7048b 100644 --- a/src/main/java/ellpeck/actuallyadditions/inventory/ContainerDrill.java +++ b/src/main/java/ellpeck/actuallyadditions/inventory/ContainerDrill.java @@ -1,5 +1,6 @@ package ellpeck.actuallyadditions.inventory; +import cofh.api.energy.IEnergyContainerItem; import ellpeck.actuallyadditions.inventory.slot.SlotImmovable; import ellpeck.actuallyadditions.items.ItemDrill; import ellpeck.actuallyadditions.items.ItemDrillUpgrade; @@ -26,7 +27,7 @@ public class ContainerDrill extends Container{ this.addSlotToContainer(new Slot(drillInventory, i, 44+i*18, 19){ @Override public boolean isItemValid(ItemStack stack){ - return stack.getItem() instanceof ItemDrillUpgrade; + return stack.getItem() instanceof ItemDrillUpgrade || stack.getItem() instanceof IEnergyContainerItem; } }); } @@ -86,7 +87,7 @@ public class ContainerDrill extends Container{ //Other Slots in Inventory excluded if(slot >= inventoryStart){ //Shift from Inventory - if(newStack.getItem() instanceof ItemDrillUpgrade){ + if(newStack.getItem() instanceof ItemDrillUpgrade || newStack.getItem() instanceof IEnergyContainerItem){ if(!this.mergeItemStack(newStack, 0, 5, false)) return null; } // diff --git a/src/main/java/ellpeck/actuallyadditions/items/InitItems.java b/src/main/java/ellpeck/actuallyadditions/items/InitItems.java index 899bd6748..4830e9642 100644 --- a/src/main/java/ellpeck/actuallyadditions/items/InitItems.java +++ b/src/main/java/ellpeck/actuallyadditions/items/InitItems.java @@ -90,6 +90,10 @@ public class InitItems{ public static Item itemDrillUpgradeBlockPlacing; public static Item itemBattery; + public static Item itemBatteryDouble; + public static Item itemBatteryTriple; + public static Item itemBatteryQuadruple; + public static Item itemBatteryQuintuple; public static Item itemTeleStaff; @@ -114,8 +118,12 @@ public class InitItems{ itemDrill = new ItemDrill(); ItemUtil.register(itemDrill); - itemBattery = new ItemBattery(); - ItemUtil.register(itemBattery); + itemBattery = new ItemBattery("itemBattery", 1000000, 5000); + itemBatteryDouble = new ItemBattery("itemBatteryDouble", 2000000, 10000); + itemBatteryTriple = new ItemBattery("itemBatteryTriple", 3000000, 15000); + itemBatteryQuadruple = new ItemBattery("itemBatteryQuadruple", 4000000, 20000); + itemBatteryQuintuple = new ItemBattery("itemBatteryQuintuple", 5000000, 25000); + ItemUtil.registerItems(new Item[]{itemBattery, itemBatteryDouble, itemBatteryTriple, itemBatteryQuadruple, itemBatteryQuintuple}); itemDrillUpgradeSpeed = new ItemDrillUpgrade(ItemDrillUpgrade.UpgradeType.SPEED, "itemDrillUpgradeSpeed"); itemDrillUpgradeSpeedII = new ItemDrillUpgrade(ItemDrillUpgrade.UpgradeType.SPEED_II, "itemDrillUpgradeSpeedII"); diff --git a/src/main/java/ellpeck/actuallyadditions/items/ItemBattery.java b/src/main/java/ellpeck/actuallyadditions/items/ItemBattery.java index cc76e4cd9..e7f4f69ff 100644 --- a/src/main/java/ellpeck/actuallyadditions/items/ItemBattery.java +++ b/src/main/java/ellpeck/actuallyadditions/items/ItemBattery.java @@ -11,9 +11,12 @@ import net.minecraft.util.IIcon; public class ItemBattery extends ItemEnergy implements INameableItem{ - public ItemBattery(){ - super(1000000, 10000, 1); + private String name; + + public ItemBattery(String name, int capacity, int transfer){ + super(capacity, transfer, 1); this.setMaxStackSize(1); + this.name = name; } @Override @@ -34,6 +37,6 @@ public class ItemBattery extends ItemEnergy implements INameableItem{ @Override public String getName(){ - return "itemBattery"; + return name; } } diff --git a/src/main/java/ellpeck/actuallyadditions/items/ItemDrill.java b/src/main/java/ellpeck/actuallyadditions/items/ItemDrill.java index 6f623647d..95b5ed155 100644 --- a/src/main/java/ellpeck/actuallyadditions/items/ItemDrill.java +++ b/src/main/java/ellpeck/actuallyadditions/items/ItemDrill.java @@ -1,5 +1,6 @@ package ellpeck.actuallyadditions.items; +import cofh.api.energy.IEnergyContainerItem; import com.google.common.collect.Multimap; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -15,6 +16,7 @@ import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.attributes.AttributeModifier; @@ -38,7 +40,7 @@ import java.util.Set; public class ItemDrill extends ItemEnergy implements INameableItem{ public ItemDrill(){ - super(500000, 5000, 3); + super(500000, 5000, 4); } public static float defaultEfficiency = ConfigFloatValues.DRILL_DAMAGE.getValue(); @@ -73,6 +75,26 @@ public class ItemDrill extends ItemEnergy implements INameableItem{ return false; } + public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5){ + NBTTagCompound compound = stack.getTagCompound(); + if(compound == null) return; + + ItemStack[] slots = this.getSlotsFromNBT(stack); + if(slots != null && slots.length > 0){ + for(ItemStack slotStack : slots){ + if(slotStack != null && slotStack.getItem() instanceof IEnergyContainerItem){ + if(this.getEnergyStored(stack) < this.getMaxEnergyStored(stack)){ + int energy = ((IEnergyContainerItem)slotStack.getItem()).getEnergyStored(slotStack); + if(energy > 0){ + int received = ((IEnergyContainerItem)stack.getItem()).receiveEnergy(stack, energy, false); + ((IEnergyContainerItem)slotStack.getItem()).extractEnergy(slotStack, received, false); + } + } + } + } + } + } + public float getEfficiencyFromUpgrade(ItemStack stack){ float efficiency = defaultEfficiency; if(this.getHasUpgrade(stack, ItemDrillUpgrade.UpgradeType.SPEED)){ diff --git a/src/main/resources/assets/actuallyadditions/lang/en_US.lang b/src/main/resources/assets/actuallyadditions/lang/en_US.lang index d9d74a6cb..bb84c199f 100644 --- a/src/main/resources/assets/actuallyadditions/lang/en_US.lang +++ b/src/main/resources/assets/actuallyadditions/lang/en_US.lang @@ -23,6 +23,7 @@ item.actuallyadditions.itemDrill.name=Drill tooltip.actuallyadditions.itemDrill.desc.1=Mines all the Blocks! tooltip.actuallyadditions.itemDrill.desc.2=Powered by RF! Charge in an Energizer! Discharge in an Enervator! tooltip.actuallyadditions.itemDrill.desc.3=Drill Upgrades can be applied through Sneak-Right-Clicking! +tooltip.actuallyadditions.itemDrill.desc.4=Put in a filled Battery to make me recharge automatically! tile.actuallyadditions.blockMiscWoodCasing.name=Wood Casing tile.actuallyadditions.blockMiscStoneCasing.name=Stone Casing diff --git a/src/main/resources/assets/actuallyadditions/textures/blocks/blockColoredLampOrange.png b/src/main/resources/assets/actuallyadditions/textures/blocks/blockColoredLampOrange.png index 975d60c5de77bbc024ec05f2cdf3dc08d4c2e6d7..29990eb361a4c3e989a0d228739f70c7be106dfc 100644 GIT binary patch delta 455 zcmV;&0XY8T1J(nO8Gix*005AYXf^-<00DDSM?wIu&K&6g000DMK}|sb0I`n?{9y$E z000SaNLh0L01FZT01FZU(%pXi00007bV*G`2j2!969_O$Q@&6D000}wy7h47TkDGp0ZMa=Rr z?^a5|`Rz1TK0jO`jd20000TX;fHrLvL+uWo~o;00000Lvm$d zbY)~9cWHEJAV*0}P-HG;2LJ#8NJ&INR5;6Rle<#GKnz8XWPdUFfS6&@QZf7sd_DyO zwTnFH$$CX0t?evvBU!7ftEarZ@7#epgFC2(!~xkzLf0X635?AN9LGllOHfTGO<)C5 zC-l>K!W~Qm#{Cmc#q2p9H67{nkfnSv?hl+V6IyF9J=iPDCzctPg>emLn7x1qqU#ID zu(Ei`GS_Dq0DoJ8I;7pRDUy0?|pu9-7%O}i&>n+^i85*(v9Dlxk(BqVeZVFGe7r+{Y}{4hWD%RavAce zjMvHVcVl-gc$z*^>olq7*N~VYW@8si zY&bB{)zChJyaoa>wIc{7M@u5m7KA8fEs4njNU~J*gG#lD1QzTSyt?<(Lwx!%vTs)R zqMh1`6h_;G{U{&-r_9jRJq!e!%Y zK+Ud*97yS71TM_UR$->$qq(8rAZgRiirE;H@Gcl7GJhvT_RGap{aMVvq00_XRJXN2 zD4dol(r!RbA@%?qflSUJqR=d*Z(pI8dRbnfpADG314>GeYIVn&Nj5w$0bIkLt8~Bx zpxT8${mqzJbVQ-%CrrbICpx429XxCk(ZZ_!x5x=zO!jE rQi4+a%Od9NQ=^-+Z$2+2nw;SukKE#u&drMn00000NkvXXu0mjfn>^$(