mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-27 23:45:55 +00:00
Merge branch 'master' of https://github.com/CrazyPants/EnderIO
This commit is contained in:
commit
4fbaa11b69
2 files changed
+58
-8
No files matched your search
@@ -7,11 +7,12 @@ import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import cofh.api.energy.IEnergyContainerItem;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.EnderIOTab;
|
||||
import crazypants.enderio.power.PowerHandlerUtil;
|
||||
|
||||
public class BlockItemCapacitorBank extends ItemBlock {
|
||||
public class BlockItemCapacitorBank extends ItemBlock implements IEnergyContainerItem {
|
||||
|
||||
public static ItemStack createItemStackWithPower(int storedEnergy) {
|
||||
ItemStack res = new ItemStack(EnderIO.blockCapacitorBank);
|
||||
@@ -23,7 +24,7 @@ public class BlockItemCapacitorBank extends ItemBlock {
|
||||
super(EnderIO.blockCapacitorBank);
|
||||
setHasSubtypes(true);
|
||||
}
|
||||
|
||||
|
||||
public BlockItemCapacitorBank(Block block) {
|
||||
super(block);
|
||||
setHasSubtypes(true);
|
||||
@@ -39,12 +40,12 @@ public class BlockItemCapacitorBank extends ItemBlock {
|
||||
public String getUnlocalizedName(ItemStack par1ItemStack) {
|
||||
int meta = par1ItemStack.getItemDamage();
|
||||
String result = super.getUnlocalizedName(par1ItemStack);
|
||||
if(meta == 1) {
|
||||
if(meta == 1) {
|
||||
result += ".creative";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) {
|
||||
@@ -53,11 +54,59 @@ public class BlockItemCapacitorBank extends ItemBlock {
|
||||
|
||||
stack = createItemStackWithPower(TileCapacitorBank.BASE_CAP.getMaxEnergyStored());
|
||||
par3List.add(stack);
|
||||
|
||||
stack = createItemStackWithPower(TileCapacitorBank.BASE_CAP.getMaxEnergyStored()/2);
|
||||
|
||||
stack = createItemStackWithPower(TileCapacitorBank.BASE_CAP.getMaxEnergyStored() / 2);
|
||||
stack.setItemDamage(1);
|
||||
par3List.add(stack);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showDurabilityBar(ItemStack itemStack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDurabilityForDisplay(ItemStack itemStack) {
|
||||
double stored = this.getMaxEnergyStored(itemStack) - this.getEnergyStored(itemStack) + 1;
|
||||
double max = this.getMaxEnergyStored(itemStack) + 1;
|
||||
return stored / max;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int receiveEnergy(ItemStack container, int maxReceive, boolean simulate) {
|
||||
int energy = this.getEnergyStored(container);
|
||||
int maxInput = TileCapacitorBank.BASE_CAP.getMaxEnergyReceived();
|
||||
int energyReceived = Math.min(this.getMaxEnergyStored(container) - energy, Math.min(maxReceive, maxInput));
|
||||
|
||||
if(!simulate) {
|
||||
energy += energyReceived;
|
||||
PowerHandlerUtil.setStoredEnergyForItem(container, energy);
|
||||
}
|
||||
return energyReceived;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int extractEnergy(ItemStack container, int maxExtract, boolean simulate) {
|
||||
int energy = this.getEnergyStored(container);
|
||||
int maxOutput = TileCapacitorBank.BASE_CAP.getMaxEnergyExtracted();
|
||||
int energyExtracted = Math.min(energy, Math.min(maxExtract, maxOutput));
|
||||
|
||||
if(!simulate) {
|
||||
energy -= energyExtracted;
|
||||
PowerHandlerUtil.setStoredEnergyForItem(container, energy);
|
||||
}
|
||||
return energyExtracted;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored(ItemStack container) {
|
||||
return PowerHandlerUtil.getStoredEnergyForItem(container);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored(ItemStack container) {
|
||||
return TileCapacitorBank.BASE_CAP.getMaxEnergyStored();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,7 +9,6 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityClientPlayerMP;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
@@ -43,7 +42,6 @@ import crazypants.vecmath.Matrix4d;
|
||||
import crazypants.vecmath.VecmathUtil;
|
||||
import crazypants.vecmath.Vector2d;
|
||||
import crazypants.vecmath.Vector3d;
|
||||
import crazypants.vecmath.Vector4d;
|
||||
|
||||
public class TravelController {
|
||||
|
||||
@@ -510,6 +508,7 @@ public class TravelController {
|
||||
return block.getLightOpacity(w, x, y, z) < 2;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private void updateSelectedTarget(EntityClientPlayerMP player) {
|
||||
selectedCoord = null;
|
||||
if(candidates.isEmpty()) {
|
||||
@@ -607,6 +606,7 @@ public class TravelController {
|
||||
return scale;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private int getMaxTravelDistanceSqForPlayer(EntityClientPlayerMP player) {
|
||||
if(isTravelItemActive(player)) {
|
||||
return TravelSource.STAFF.maxDistanceTravelledSq;
|
||||
@@ -619,6 +619,7 @@ public class TravelController {
|
||||
PacketHandler.INSTANCE.sendToServer(p);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private BlockCoord getActiveTravelBlock(EntityClientPlayerMP player) {
|
||||
World world = Minecraft.getMinecraft().theWorld;
|
||||
if(world != null && player != null) {
|
||||
|
||||
Reference in new issue
Block a user