Made the Drill recharge if you put Batteries into the Upgrade Slots.

This commit is contained in:
Ellpeck 2015-07-16 16:52:28 +02:00
parent 1465fab3d0
commit 996de5673f
8 changed files with 44 additions and 9 deletions

View file

@ -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

View file

@ -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;
}
//

View file

@ -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");

View file

@ -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;
}
}

View file

@ -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)){

View file

@ -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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 484 B

After

Width:  |  Height:  |  Size: 470 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 567 B

After

Width:  |  Height:  |  Size: 514 B