Fixed tank texture

This commit is contained in:
Calclavia 2014-01-14 22:12:40 +08:00
parent 053a62f358
commit 5cdf1602bb
2 changed files with 101 additions and 91 deletions

View file

@ -2,7 +2,10 @@ package resonantinduction.mechanical.fluid.pipe;
import java.util.List; import java.util.List;
import calclavia.lib.utility.LanguageUtility;
import codechicken.lib.vec.Translation;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.client.resources.Language;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemBlock;
@ -24,102 +27,109 @@ import universalelectricity.api.vector.Vector3;
public class ItemBlockFluidContainer extends ItemBlock public class ItemBlockFluidContainer extends ItemBlock
{ {
public ItemBlockFluidContainer(int id) public ItemBlockFluidContainer(int id)
{ {
super(id); super(id);
this.setMaxDamage(0); this.setMaxDamage(0);
this.setHasSubtypes(true); this.setHasSubtypes(true);
} }
@Override @Override
public int getMetadata(int damage) public int getMetadata(int damage)
{ {
return damage; return damage;
} }
@Override @Override
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4)
{ {
if (stack.getTagCompound() != null && stack.getTagCompound().hasKey("fluid")) if (stack.getTagCompound() != null && stack.getTagCompound().hasKey("fluid"))
{ {
FluidStack fluid = FluidStack.loadFluidStackFromNBT(stack.getTagCompound().getCompoundTag("fluid")); FluidStack fluid = FluidStack.loadFluidStackFromNBT(stack.getTagCompound().getCompoundTag("fluid"));
if (fluid != null) if (fluid != null)
{ {
list.add("Fluid: " + fluid.getFluid().getLocalizedName()); list.add("Fluid: " + fluid.getFluid().getLocalizedName());
list.add("Volume: " + UnitDisplay.getDisplay(fluid.amount, Unit.LITER, UnitPrefix.MILLI)); list.add("Volume: " + UnitDisplay.getDisplay(fluid.amount, Unit.LITER, UnitPrefix.MILLI));
} }
} }
} }
public static ItemStack getWrenchedItem(World world, Vector3 vec) public static ItemStack getWrenchedItem(World world, Vector3 vec)
{ {
TileEntity entity = vec.getTileEntity(world); TileEntity entity = vec.getTileEntity(world);
if (entity instanceof TileTank && ((TileTank) entity).getTank() != null && ((TileTank) entity).getTank().getFluid() != null) if (entity instanceof TileTank && ((TileTank) entity).getTank() != null && ((TileTank) entity).getTank().getFluid() != null)
{ {
ItemStack itemStack = new ItemStack(Mechanical.blockTank); ItemStack itemStack = new ItemStack(Mechanical.blockTank);
FluidStack stack = ((TileTank) entity).getTank().getFluid(); FluidStack stack = ((TileTank) entity).getTank().getFluid();
if (itemStack.getTagCompound() == null) if (itemStack.getTagCompound() == null)
{ {
itemStack.setTagCompound(new NBTTagCompound()); itemStack.setTagCompound(new NBTTagCompound());
} }
if (stack != null) if (stack != null)
{ {
((TileTank) entity).drain(ForgeDirection.UNKNOWN, stack.amount, true); ((TileTank) entity).drain(ForgeDirection.UNKNOWN, stack.amount, true);
itemStack.getTagCompound().setCompoundTag("fluid", stack.writeToNBT(new NBTTagCompound())); itemStack.getTagCompound().setCompoundTag("fluid", stack.writeToNBT(new NBTTagCompound()));
} }
return itemStack; return itemStack;
} }
return null; return null;
} }
@Override @Override
public void onUpdate(ItemStack itemStack, World par2World, Entity entity, int par4, boolean par5) public void onUpdate(ItemStack itemStack, World par2World, Entity entity, int par4, boolean par5)
{ {
if (entity instanceof EntityPlayer) if (entity instanceof EntityPlayer)
{ {
EntityPlayer player = (EntityPlayer) entity; EntityPlayer player = (EntityPlayer) entity;
if (itemStack.getTagCompound() != null && !player.capabilities.isCreativeMode && itemStack.getTagCompound().hasKey("fluid")) if (itemStack.getTagCompound() != null && !player.capabilities.isCreativeMode && itemStack.getTagCompound().hasKey("fluid"))
{ {
player.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 5, 0)); player.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 5, 0));
} }
} }
} }
@Override @Override
public int getItemStackLimit(ItemStack stack) public int getItemStackLimit(ItemStack stack)
{ {
if (stack.getTagCompound() != null && stack.getTagCompound().hasKey("fluid")) if (stack.getTagCompound() != null && stack.getTagCompound().hasKey("fluid"))
{ {
return 1; return 1;
} }
return this.maxStackSize; return this.maxStackSize;
} }
@Override @Override
public String getUnlocalizedName(ItemStack itemStack) public String getUnlocalizedName(ItemStack itemStack)
{ {
return Block.blocksList[this.getBlockID()].getUnlocalizedName() + "." + itemStack.getItemDamage(); String translation = LanguageUtility.getLocal(Block.blocksList[this.getBlockID()].getUnlocalizedName() + "." + itemStack.getItemDamage());
}
@Override if (translation == null || translation.isEmpty())
public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata) {
{ return Block.blocksList[this.getBlockID()].getUnlocalizedName();
if (super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, (metadata / FluidContainerMaterial.spacing))) }
{
TileEntity tile = world.getBlockTileEntity(x, y, z); return Block.blocksList[this.getBlockID()].getUnlocalizedName() + "." + itemStack.getItemDamage();
if (tile instanceof TileFluidNetwork) }
{
((TileFluidNetwork) tile).setSubID(stack.getItemDamage()); @Override
if (stack.getTagCompound() != null && stack.getTagCompound().hasKey("fluid")) public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata)
{ {
((TileFluidNetwork) tile).fill(ForgeDirection.UNKNOWN, FluidStack.loadFluidStackFromNBT(stack.getTagCompound().getCompoundTag("fluid")), true); if (super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, (metadata / FluidContainerMaterial.spacing)))
} {
} TileEntity tile = world.getBlockTileEntity(x, y, z);
return true; if (tile instanceof TileFluidNetwork)
} {
return false; ((TileFluidNetwork) tile).setSubID(stack.getItemDamage());
} if (stack.getTagCompound() != null && stack.getTagCompound().hasKey("fluid"))
{
((TileFluidNetwork) tile).fill(ForgeDirection.UNKNOWN, FluidStack.loadFluidStackFromNBT(stack.getTagCompound().getCompoundTag("fluid")), true);
}
}
return true;
}
return false;
}
} }

View file

@ -23,14 +23,14 @@ tile.resonantinduction\:fluidPipe.1.name=Stone Trough
### Mechanical Module ### Mechanical Module
## Energy ## Energy
tile.resonantinduction\:gear.name=Gear item.resonantinduction\:gear.name=Gear
tile.resonantinduction\:gearShaft.name=Gear Shaft item.resonantinduction\:gearShaft.name=Gear Shaft
## Transport ## Transport
tile.resonantinduction\:pump.name=Pump tile.resonantinduction\:pump.name=Pump
tile.resonantinduction\:grate.name=Grate tile.resonantinduction\:grate.name=Grate
tile.resonantinduction\:conveyorBelt.name=Conveyor Belt tile.resonantinduction\:conveyorBelt.name=Conveyor Belt
tile.resonantinduction\:tank.0.name=Tank tile.resonantinduction\:tank.name=Tank
tile.resonantinduction\:detector.name=Detector tile.resonantinduction\:detector.name=Detector
tile.resonantinduction\:manipulator.name=Manipulator tile.resonantinduction\:manipulator.name=Manipulator
tile.resonantinduction\:rejector.name=Rejector tile.resonantinduction\:rejector.name=Rejector