mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-22 05:02:25 +00:00
More work on tanks.
This commit is contained in:
1 parent
8ec56a01d2
commit
a78c24d03d
30 files changed
+430
-108
No files matched your search
@@ -4,6 +4,7 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.MapColor;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
@@ -57,7 +58,7 @@ public abstract class BlockEio extends Block {
|
||||
blockIcon = iIconRegister.registerIcon("enderio:" + name);
|
||||
}
|
||||
|
||||
public String getUnlocalizedNameForTooltip() {
|
||||
public String getUnlocalizedNameForTooltip(ItemStack stack) {
|
||||
return getUnlocalizedName();
|
||||
}
|
||||
|
||||
|
||||
@@ -61,7 +61,9 @@ import crazypants.enderio.machine.reservoir.ReservoirRenderer;
|
||||
import crazypants.enderio.machine.reservoir.TileReservoir;
|
||||
import crazypants.enderio.machine.still.BlockVat;
|
||||
import crazypants.enderio.machine.still.VatRenderer;
|
||||
import crazypants.enderio.machine.tank.TankRenderer;
|
||||
import crazypants.enderio.machine.tank.BlockItemTank;
|
||||
import crazypants.enderio.machine.tank.TankFluidRenderer;
|
||||
import crazypants.enderio.machine.tank.TankItemRenderer;
|
||||
import crazypants.enderio.machine.tank.TileTank;
|
||||
import crazypants.enderio.material.BlockFusedQuartz;
|
||||
import crazypants.enderio.material.FusedQuartzFrameRenderer;
|
||||
@@ -197,7 +199,8 @@ public class ClientProxy extends CommonProxy {
|
||||
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockEnderIo), eior);
|
||||
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileReservoir.class, new ReservoirRenderer(EnderIO.blockReservoir));
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileTank.class, new TankRenderer());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileTank.class, new TankFluidRenderer());
|
||||
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(EnderIO.blockTank), new TankItemRenderer());
|
||||
|
||||
HyperCubeRenderer hcr = new HyperCubeRenderer();
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileHyperCube.class, hcr);
|
||||
|
||||
@@ -140,7 +140,7 @@ public class BlockEnderIO extends BlockEio implements IResourceTooltipProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedNameForTooltip() {
|
||||
public String getUnlocalizedNameForTooltip(ItemStack stack) {
|
||||
return getUnlocalizedName();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package crazypants.enderio.gui;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface IResourceTooltipProvider {
|
||||
|
||||
String getUnlocalizedNameForTooltip();
|
||||
String getUnlocalizedNameForTooltip(ItemStack itemStack);
|
||||
|
||||
}
|
||||
@@ -51,17 +51,19 @@ public class TooltipAddera {
|
||||
}
|
||||
}
|
||||
|
||||
if(evt.itemStack.getItem() instanceof IResourceTooltipProvider) {
|
||||
addInformation((IResourceTooltipProvider)evt.itemStack.getItem(), evt);
|
||||
} else if(evt.itemStack.getItem() instanceof IAdvancedTooltipProvider) {
|
||||
if(evt.itemStack.getItem() instanceof IAdvancedTooltipProvider) {
|
||||
IAdvancedTooltipProvider ttp = (IAdvancedTooltipProvider)evt.itemStack.getItem();
|
||||
addInformation(ttp, evt.itemStack, evt.entityPlayer, evt.toolTip, false);
|
||||
return;
|
||||
} else if(evt.itemStack.getItem() instanceof IResourceTooltipProvider) {
|
||||
addInformation((IResourceTooltipProvider)evt.itemStack.getItem(), evt);
|
||||
return;
|
||||
}
|
||||
|
||||
Block blk = Block.getBlockFromItem(evt.itemStack.getItem());
|
||||
if(blk instanceof IResourceTooltipProvider) {
|
||||
addInformation((IResourceTooltipProvider)blk, evt);
|
||||
return;
|
||||
} else if(blk instanceof IAdvancedTooltipProvider) {
|
||||
addInformation((IAdvancedTooltipProvider)blk, evt.itemStack, evt.entityPlayer, evt.toolTip, false);
|
||||
return;
|
||||
@@ -105,7 +107,7 @@ public class TooltipAddera {
|
||||
|
||||
public static void addInformation(IResourceTooltipProvider item, ItemTooltipEvent evt) {
|
||||
if(showAdvancedTooltips()) {
|
||||
addDetailedTooltipFromResources(evt.toolTip, item.getUnlocalizedNameForTooltip());
|
||||
addDetailedTooltipFromResources(evt.toolTip, item.getUnlocalizedNameForTooltip(evt.itemStack));
|
||||
} else {
|
||||
addShowDetailsTooltip(evt.toolTip);
|
||||
}
|
||||
@@ -163,10 +165,10 @@ public class TooltipAddera {
|
||||
return;
|
||||
}
|
||||
String unlock = null;
|
||||
Block blk = Block.getBlockFromItem(itemstack.getItem());
|
||||
if(blk != null && blk != Blocks.air) {
|
||||
unlock = blk.getUnlocalizedName();
|
||||
}
|
||||
// Block blk = Block.getBlockFromItem(itemstack.getItem());
|
||||
// if(blk != null && blk != Blocks.air) {
|
||||
// unlock = blk.getUnlocalizedName();
|
||||
// }
|
||||
if(unlock == null) {
|
||||
unlock = itemstack.getItem().getUnlocalizedName();
|
||||
}
|
||||
|
||||
@@ -171,10 +171,8 @@ public class ItemMagnet extends ItemEnergyContainer implements IResourceTooltipP
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedNameForTooltip() {
|
||||
public String getUnlocalizedNameForTooltip(ItemStack stack) {
|
||||
return getUnlocalizedName();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -88,7 +88,7 @@ public class ItemYetaWrench extends Item implements IToolWrench, IResourceToolti
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedNameForTooltip() {
|
||||
public String getUnlocalizedNameForTooltip(ItemStack stack) {
|
||||
return getUnlocalizedName();
|
||||
}
|
||||
|
||||
|
||||
@@ -221,7 +221,8 @@ public abstract class AbstractMachineBlock<T extends AbstractMachineEntity> exte
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if(te instanceof AbstractMachineEntity) {
|
||||
AbstractMachineEntity machineEntity = (AbstractMachineEntity) te;
|
||||
ItemStack itemStack = new ItemStack(this);
|
||||
int meta = damageDropped(world.getBlockMetadata(x, y, z));
|
||||
ItemStack itemStack = new ItemStack(this, 1, meta);
|
||||
machineEntity.writeToItemStack(itemStack);
|
||||
|
||||
float f = 0.7F;
|
||||
@@ -229,6 +230,7 @@ public abstract class AbstractMachineBlock<T extends AbstractMachineEntity> exte
|
||||
double d1 = world.rand.nextFloat() * f + (1.0F - f) * 0.5D;
|
||||
double d2 = world.rand.nextFloat() * f + (1.0F - f) * 0.5D;
|
||||
EntityItem entityitem = new EntityItem(world, x + d0, y + d1, z + d2, itemStack);
|
||||
|
||||
entityitem.delayBeforeCanPickup = 10;
|
||||
world.spawnEntityInWorld(entityitem);
|
||||
}
|
||||
@@ -320,7 +322,7 @@ public abstract class AbstractMachineBlock<T extends AbstractMachineEntity> exte
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedNameForTooltip() {
|
||||
public String getUnlocalizedNameForTooltip(ItemStack stack) {
|
||||
return getUnlocalizedName();
|
||||
}
|
||||
|
||||
|
||||
@@ -583,7 +583,7 @@ public abstract class AbstractMachineEntity extends TileEntityEio implements ISi
|
||||
if(stack.hasDisplayName()) {
|
||||
name = stack.getDisplayName();
|
||||
} else {
|
||||
name = getBlockType().getLocalizedName();
|
||||
name = Lang.localize(stack.getUnlocalizedName() + ".name", false);
|
||||
}
|
||||
name += " " + Lang.localize("machine.tooltip.configured");
|
||||
stack.setStackDisplayName(name);
|
||||
|
||||
@@ -3,6 +3,7 @@ package crazypants.enderio.machine.farm;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
@@ -95,7 +96,7 @@ public class BlockFarmStation extends AbstractMachineBlock<TileFarmStation> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedNameForTooltip() {
|
||||
public String getUnlocalizedNameForTooltip(ItemStack stack) {
|
||||
return getUnlocalizedName();
|
||||
}
|
||||
|
||||
|
||||
@@ -292,7 +292,7 @@ public class BlockHyperCube extends BlockEio implements IGuiHandler, IResourceTo
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedNameForTooltip() {
|
||||
public String getUnlocalizedNameForTooltip(ItemStack stack) {
|
||||
return getUnlocalizedName();
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package crazypants.enderio.machine.light;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.IIcon;
|
||||
@@ -199,7 +200,7 @@ public class BlockElectricLight extends BlockEio implements IResourceTooltipProv
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedNameForTooltip() {
|
||||
public String getUnlocalizedNameForTooltip(ItemStack stack) {
|
||||
return getUnlocalizedName();
|
||||
}
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ public class ItemConduitProbe extends Item implements IResourceTooltipProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedNameForTooltip() {
|
||||
public String getUnlocalizedNameForTooltip(ItemStack stack) {
|
||||
return getUnlocalizedName();
|
||||
}
|
||||
|
||||
|
||||
@@ -284,6 +284,9 @@ public class BlockCapacitorBank extends BlockEio implements IGuiHandler, IAdvanc
|
||||
if(!player.capabilities.isCreativeMode || "true".equalsIgnoreCase(System.getProperty("blockCapBankAllwaysDrop"))) {
|
||||
ItemStack itemStack =
|
||||
BlockItemCapacitorBank.createItemStackWithPower(cb.doGetEnergyStored());
|
||||
if(cb.isCreative()) {
|
||||
itemStack.setItemDamage(1);
|
||||
}
|
||||
float f = 0.7F;
|
||||
double d0 = world.rand.nextFloat() * f + (1.0F - f) * 0.5D;
|
||||
double d1 = world.rand.nextFloat() * f + (1.0F - f) * 0.5D;
|
||||
|
||||
@@ -287,7 +287,7 @@ public class BlockReservoir extends BlockContainer implements IResourceTooltipPr
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedNameForTooltip() {
|
||||
public String getUnlocalizedNameForTooltip(ItemStack stack) {
|
||||
return getUnlocalizedName();
|
||||
}
|
||||
|
||||
|
||||
@@ -106,12 +106,7 @@ public class BlockSolarPanel extends BlockEio implements IResourceTooltipProvide
|
||||
setBlockBoundsBasedOnState(par1World, par2, par3, par4);
|
||||
super.addCollisionBoxesToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedNameForTooltip() {
|
||||
return getUnlocalizedName();
|
||||
}
|
||||
|
||||
|
||||
public void breakBlock(World world, int x, int y, int z, Block block, int p_149749_6_) {
|
||||
super.breakBlock(world, x, y, z, block, p_149749_6_);
|
||||
world.removeTileEntity(x, y, z);
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
package crazypants.enderio.machine.tank;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemBlockWithMetadata;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.EnderIOTab;
|
||||
import crazypants.enderio.gui.IAdvancedTooltipProvider;
|
||||
import crazypants.enderio.machine.power.TileCapacitorBank;
|
||||
import crazypants.enderio.power.PowerHandlerUtil;
|
||||
|
||||
public class BlockItemTank extends ItemBlockWithMetadata implements IAdvancedTooltipProvider {
|
||||
|
||||
public BlockItemTank() {
|
||||
super(EnderIO.blockTank,EnderIO.blockTank);
|
||||
setHasSubtypes(true);
|
||||
setCreativeTab(EnderIOTab.tabEnderIO);
|
||||
}
|
||||
|
||||
public BlockItemTank(Block block) {
|
||||
super(block, block);
|
||||
setHasSubtypes(true);
|
||||
setCreativeTab(EnderIOTab.tabEnderIO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetadata(int par1) {
|
||||
return par1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack par1ItemStack) {
|
||||
int meta = par1ItemStack.getItemDamage();
|
||||
String result = super.getUnlocalizedName(par1ItemStack);
|
||||
if(meta == 1) {
|
||||
result += ".advanced";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) {
|
||||
ItemStack stack = new ItemStack(this, 1,0);
|
||||
par3List.add(stack);
|
||||
stack = new ItemStack(this, 1,1);
|
||||
par3List.add(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCommonEntries(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) {
|
||||
EnderIO.blockTank.addCommonEntries(itemstack, entityplayer, list, flag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addBasicEntries(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) {
|
||||
EnderIO.blockTank.addBasicEntries(itemstack, entityplayer, list, flag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addDetailedEntries(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) {
|
||||
EnderIO.blockTank.addDetailedEntries(itemstack, entityplayer, list, flag);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,21 +1,40 @@
|
||||
package crazypants.enderio.machine.tank;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import crazypants.enderio.ClientProxy;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.enderio.GuiHandler;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.gui.IAdvancedTooltipProvider;
|
||||
import crazypants.enderio.gui.TooltipAddera;
|
||||
import crazypants.enderio.machine.AbstractMachineBlock;
|
||||
import crazypants.enderio.machine.AbstractMachineEntity;
|
||||
import crazypants.enderio.machine.power.BlockItemCapacitorBank;
|
||||
import crazypants.enderio.machine.power.PowerDisplayUtil;
|
||||
import crazypants.enderio.machine.power.TileCapacitorBank;
|
||||
import crazypants.enderio.power.PowerHandlerUtil;
|
||||
import crazypants.util.FluidUtil;
|
||||
import crazypants.util.Lang;
|
||||
import crazypants.util.Util;
|
||||
|
||||
public class BlockTank extends AbstractMachineBlock<TileTank> {
|
||||
public class BlockTank extends AbstractMachineBlock<TileTank> implements IAdvancedTooltipProvider {
|
||||
|
||||
public static BlockTank create() {
|
||||
|
||||
@@ -31,10 +50,19 @@ public class BlockTank extends AbstractMachineBlock<TileTank> {
|
||||
|
||||
@Override
|
||||
protected void init() {
|
||||
super.init();
|
||||
GameRegistry.registerBlock(this, BlockItemTank.class, ModObject.blockTank.unlocalisedName);
|
||||
if(teClass != null) {
|
||||
GameRegistry.registerTileEntity(teClass, ModObject.blockTank.unlocalisedName + "TileEntity");
|
||||
}
|
||||
EnderIO.guiHandler.registerGuiHandler(GuiHandler.GUI_ID_TANK, this);
|
||||
setLightOpacity(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(int par1) {
|
||||
return par1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int par6, float par7, float par8, float par9) {
|
||||
|
||||
@@ -104,11 +132,16 @@ public class BlockTank extends AbstractMachineBlock<TileTank> {
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World var1, int var2) {
|
||||
return new TileTank(var2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if(!(te instanceof TileTank)) {
|
||||
System.out.println("BlockTank.getServerGuiElement: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
||||
return null;
|
||||
}
|
||||
return new ContainerTank(player.inventory, (TileTank)te);
|
||||
@@ -118,7 +151,6 @@ public class BlockTank extends AbstractMachineBlock<TileTank> {
|
||||
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
if(!(te instanceof TileTank)) {
|
||||
System.out.println("BlockTank.getClientGuiElement: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
||||
return null;
|
||||
}
|
||||
return new GuiTank(player.inventory, (TileTank)te);
|
||||
@@ -145,9 +177,39 @@ public boolean isOpaqueCube() {
|
||||
protected int getGuiId() {
|
||||
return GuiHandler.GUI_ID_TANK;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int blockSide) {
|
||||
|
||||
// used to render the block in the world
|
||||
TileEntity te = world.getTileEntity(x, y, z);
|
||||
int facing = 0;
|
||||
if(te instanceof AbstractMachineEntity) {
|
||||
AbstractMachineEntity me = (AbstractMachineEntity) te;
|
||||
facing = me.facing;
|
||||
}
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
meta = MathHelper.clamp_int(meta, 0, 1);
|
||||
if(meta == 1) {
|
||||
return iconBuffer[0][ClientProxy.sideAndFacingToSpriteOffset[blockSide][facing] + 6];
|
||||
} else {
|
||||
return iconBuffer[0][ClientProxy.sideAndFacingToSpriteOffset[blockSide][facing]];
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getMachineFrontIconKey(boolean active) {
|
||||
public IIcon getIcon(int blockSide, int blockMeta) {
|
||||
int offset = MathHelper.clamp_int(blockMeta, 0, 1) == 0 ? 0 : 6;
|
||||
return iconBuffer[0][blockSide + offset];
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected String getMachineFrontIconKey(boolean pressurized) {
|
||||
if(pressurized) {
|
||||
return "enderio:blockTankAdvanced";
|
||||
}
|
||||
return "enderio:blockTank";
|
||||
}
|
||||
|
||||
@@ -158,5 +220,42 @@ public boolean isOpaqueCube() {
|
||||
protected String getBackIconKey(boolean active) {
|
||||
return getMachineFrontIconKey(active);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTopIconKey(boolean pressurized) {
|
||||
if(pressurized) {
|
||||
return "enderio:blockTankTopAdvanced";
|
||||
}
|
||||
return "enderio:machineTop";
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addCommonEntries(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addBasicEntries(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) {
|
||||
if(itemstack.stackTagCompound != null && itemstack.stackTagCompound.hasKey("tankContents")) {
|
||||
FluidStack fl = FluidStack.loadFluidStackFromNBT((NBTTagCompound) itemstack.stackTagCompound.getTag("tankContents"));
|
||||
if(fl != null && fl.getFluid() != null) {
|
||||
String str = fl.amount + " " + Lang.localize("fluid.millibucket.abr") + " " + PowerDisplayUtil.ofStr() + " " + fl.getFluid().getLocalizedName();
|
||||
list.add(str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addDetailedEntries(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) {
|
||||
TooltipAddera.addDetailedTooltipFromResources(list, itemstack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedNameForTooltip(ItemStack stack) {
|
||||
System.out.println("BlockTank.getUnlocalizedNameForTooltip: ");
|
||||
return stack.getUnlocalizedName();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package crazypants.enderio.machine.tank;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import crazypants.render.BoundingBox;
|
||||
import crazypants.render.CubeRenderer;
|
||||
import crazypants.render.RenderUtil;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
public class TankFluidRenderer extends TileEntitySpecialRenderer {
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity te, double x, double y, double z, float partialTick) {
|
||||
|
||||
TileTank tank = (TileTank)te;
|
||||
if(tank.tank.getFluidAmount() <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
renderTankFluid(tank.tank, (float)x, (float)y, (float)z);
|
||||
// IIcon icon = tank.tank.getFluid().getFluid().getStillIcon();
|
||||
// if(icon != null) {
|
||||
// float fullness = tank.tank.getFilledRatio();
|
||||
//
|
||||
// float scale = 0.97f;
|
||||
// float yScale = 0.97f * fullness;
|
||||
// BoundingBox bb = BoundingBox.UNIT_CUBE.scale(scale, yScale , scale);
|
||||
// bb = bb.translate(0, -(1 - yScale)/2, 0);
|
||||
//
|
||||
// GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
|
||||
// GL11.glEnable(GL11.GL_CULL_FACE);
|
||||
// GL11.glDisable(GL11.GL_LIGHTING);
|
||||
// GL11.glEnable(GL11.GL_BLEND);
|
||||
// GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
//
|
||||
// RenderUtil.bindBlockTexture();
|
||||
//
|
||||
// Tessellator.instance.startDrawingQuads();
|
||||
// Tessellator.instance.addTranslation((float)x, (float)y, (float)z);
|
||||
// CubeRenderer.render(bb, icon);
|
||||
// Tessellator.instance.addTranslation(-(float)x, -(float)y, -(float)z);
|
||||
// Tessellator.instance.draw();
|
||||
//
|
||||
// GL11.glPopAttrib();
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
public static void renderTankFluid(FluidTankEio tank, float x, float y, float z) {
|
||||
if(tank == null || tank.getFluid() == null) {
|
||||
return;
|
||||
}
|
||||
IIcon icon = tank.getFluid().getFluid().getStillIcon();
|
||||
if(icon != null) {
|
||||
float fullness = tank.getFilledRatio();
|
||||
|
||||
float scale = 0.97f;
|
||||
float yScale = 0.97f * fullness;
|
||||
BoundingBox bb = BoundingBox.UNIT_CUBE.scale(scale, yScale , scale);
|
||||
bb = bb.translate(0, -(1 - yScale)/2, 0);
|
||||
|
||||
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
|
||||
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
RenderUtil.bindBlockTexture();
|
||||
|
||||
Tessellator.instance.startDrawingQuads();
|
||||
Tessellator.instance.addTranslation(x, y, z);
|
||||
CubeRenderer.render(bb, icon);
|
||||
Tessellator.instance.addTranslation(-x, -y, -z);
|
||||
Tessellator.instance.draw();
|
||||
|
||||
GL11.glPopAttrib();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package crazypants.enderio.machine.tank;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
import net.minecraftforge.client.IItemRenderer.ItemRenderType;
|
||||
import net.minecraftforge.client.IItemRenderer.ItemRendererHelper;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import cofh.api.energy.IEnergyContainerItem;
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.render.BoundingBox;
|
||||
import crazypants.render.ColorUtil;
|
||||
import crazypants.render.CubeRenderer;
|
||||
import crazypants.render.RenderUtil;
|
||||
|
||||
public class TankItemRenderer implements IItemRenderer {
|
||||
|
||||
private RenderItem ri = new RenderItem();
|
||||
|
||||
@Override
|
||||
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
|
||||
return type == ItemRenderType.INVENTORY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
|
||||
if(data != null && data.length > 0) {
|
||||
renderToInventory(item, (RenderBlocks) data[0]);
|
||||
}
|
||||
}
|
||||
|
||||
public void renderToInventory(ItemStack item, RenderBlocks renderBlocks) {
|
||||
|
||||
boolean hasFluid = false;
|
||||
if(item.stackTagCompound != null) {
|
||||
TileTank tt = new TileTank();
|
||||
tt.readCommon(item.stackTagCompound);
|
||||
|
||||
TankFluidRenderer.renderTankFluid(tt.tank, 0, -0.1f, 0);
|
||||
hasFluid = true;
|
||||
}
|
||||
|
||||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||
IIcon[] icons = new IIcon[6];
|
||||
int i = 0;
|
||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
// if(dir.offsetY == 0 && hasFluid) {
|
||||
// //icons[i] = EnderIO.blockFusedQuartz.getIcon(dir.ordinal(), 0);
|
||||
// icons[i] = Blocks.iron_bars.getIcon(0, 0);
|
||||
// } else {
|
||||
icons[i] = EnderIO.blockTank.getIcon(dir.ordinal(), item.getItemDamage());
|
||||
// }
|
||||
i++;
|
||||
}
|
||||
BoundingBox bb = BoundingBox.UNIT_CUBE.translate(0, -0.1f, 0);
|
||||
Tessellator.instance.startDrawingQuads();
|
||||
CubeRenderer.render(bb, icons, null, RenderUtil.getDefaultPerSideBrightness());
|
||||
Tessellator.instance.draw();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
package crazypants.enderio.machine.tank;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import crazypants.render.BoundingBox;
|
||||
import crazypants.render.CubeRenderer;
|
||||
import crazypants.render.RenderUtil;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
public class TankRenderer extends TileEntitySpecialRenderer {
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity te, double x, double y, double z, float partialTick) {
|
||||
|
||||
TileTank tank = (TileTank)te;
|
||||
if(tank.tank.getFluidAmount() <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
IIcon icon = tank.tank.getFluid().getFluid().getStillIcon();
|
||||
if(icon != null) {
|
||||
float fullness = tank.tank.getFilledRatio();
|
||||
|
||||
float scale = 0.97f;
|
||||
float yScale = 0.97f * fullness;
|
||||
BoundingBox bb = BoundingBox.UNIT_CUBE.scale(scale, yScale , scale);
|
||||
bb = bb.translate(0, -(1 - yScale)/2, 0);
|
||||
|
||||
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
|
||||
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
RenderUtil.bindBlockTexture();
|
||||
|
||||
Tessellator.instance.startDrawingQuads();
|
||||
Tessellator.instance.addTranslation((float)x, (float)y, (float)z);
|
||||
CubeRenderer.render(bb, icon);
|
||||
Tessellator.instance.addTranslation(-(float)x, -(float)y, -(float)z);
|
||||
Tessellator.instance.draw();
|
||||
|
||||
GL11.glPopAttrib();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import buildcraft.api.power.PowerHandler.PowerReceiver;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
@@ -24,9 +25,18 @@ public class TileTank extends AbstractMachineEntity implements IFluidHandler {
|
||||
|
||||
private static int IO_MB_TICK = 100;
|
||||
|
||||
protected FluidTankEio tank = new FluidTankEio(16000);
|
||||
protected FluidTankEio tank;// = new FluidTankEio(16000);
|
||||
protected int lastUpdateLevel = -1;
|
||||
|
||||
public TileTank(int meta) {
|
||||
super(new SlotDefinition(0, 1, 2, 3, -1, -1));
|
||||
if(meta == 1) {
|
||||
tank = new FluidTankEio(32000);
|
||||
} else {
|
||||
tank = new FluidTankEio(16000);
|
||||
}
|
||||
}
|
||||
|
||||
public TileTank() {
|
||||
super(new SlotDefinition(0, 1, 2, 3, -1, -1));
|
||||
}
|
||||
@@ -309,6 +319,7 @@ public class TileTank extends AbstractMachineEntity implements IFluidHandler {
|
||||
@Override
|
||||
public void writeCommon(NBTTagCompound nbtRoot) {
|
||||
super.writeCommon(nbtRoot);
|
||||
nbtRoot.setInteger("tankType",getBlockMetadata());
|
||||
if(tank.getFluidAmount() > 0) {
|
||||
NBTTagCompound fluidRoot = new NBTTagCompound();
|
||||
tank.getFluid().writeToNBT(fluidRoot);
|
||||
@@ -319,6 +330,14 @@ public class TileTank extends AbstractMachineEntity implements IFluidHandler {
|
||||
@Override
|
||||
public void readCommon(NBTTagCompound nbtRoot) {
|
||||
super.readCommon(nbtRoot);
|
||||
int tankType = nbtRoot.getInteger("tankType");
|
||||
tankType = MathHelper.clamp_int(tankType, 0, 1);
|
||||
if(tankType == 1) {
|
||||
tank = new FluidTankEio(32000);
|
||||
} else {
|
||||
tank = new FluidTankEio(16000);
|
||||
}
|
||||
|
||||
if(nbtRoot.hasKey("tankContents")) {
|
||||
FluidStack fl = FluidStack.loadFluidStackFromNBT((NBTTagCompound) nbtRoot.getTag("tankContents"));
|
||||
tank.setFluid(fl);
|
||||
|
||||
@@ -262,7 +262,7 @@ public class ItemTravelStaff extends ItemEnergyContainer implements IResourceToo
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedNameForTooltip() {
|
||||
public String getUnlocalizedNameForTooltip(ItemStack stack) {
|
||||
return getUnlocalizedName();
|
||||
}
|
||||
|
||||
|
||||
@@ -182,7 +182,7 @@ public final class CubeRenderer {
|
||||
tessellator.setColorOpaque_F(cm, cm, cm);
|
||||
}
|
||||
|
||||
tex = faceTextures[0];
|
||||
tex = faceTextures[ForgeDirection.NORTH.ordinal()];
|
||||
minU = tex.getMinU();
|
||||
maxU = tex.getMaxU();
|
||||
minV = tex.getMinV();
|
||||
@@ -197,7 +197,7 @@ public final class CubeRenderer {
|
||||
float cm = brightnessPerSide[ForgeDirection.SOUTH.ordinal()];
|
||||
tessellator.setColorOpaque_F(cm, cm, cm);
|
||||
}
|
||||
tex = faceTextures[1];
|
||||
tex = faceTextures[ForgeDirection.SOUTH.ordinal()];
|
||||
minU = tex.getMinU();
|
||||
maxU = tex.getMaxU();
|
||||
minV = tex.getMinV();
|
||||
@@ -212,7 +212,7 @@ public final class CubeRenderer {
|
||||
float cm = brightnessPerSide[ForgeDirection.UP.ordinal()];
|
||||
tessellator.setColorOpaque_F(cm, cm, cm);
|
||||
}
|
||||
tex = faceTextures[2];
|
||||
tex = faceTextures[ForgeDirection.UP.ordinal()];
|
||||
minU = tex.getMinU();
|
||||
maxU = tex.getMaxU();
|
||||
minV = tex.getMinV();
|
||||
@@ -227,7 +227,7 @@ public final class CubeRenderer {
|
||||
float cm = brightnessPerSide[ForgeDirection.DOWN.ordinal()];
|
||||
tessellator.setColorOpaque_F(cm, cm, cm);
|
||||
}
|
||||
tex = faceTextures[3];
|
||||
tex = faceTextures[ForgeDirection.DOWN.ordinal()];
|
||||
minU = tex.getMinU();
|
||||
maxU = tex.getMaxU();
|
||||
minV = tex.getMinV();
|
||||
@@ -242,7 +242,7 @@ public final class CubeRenderer {
|
||||
float cm = brightnessPerSide[ForgeDirection.EAST.ordinal()];
|
||||
tessellator.setColorOpaque_F(cm, cm, cm);
|
||||
}
|
||||
tex = faceTextures[4];
|
||||
tex = faceTextures[ForgeDirection.EAST.ordinal()];
|
||||
minU = tex.getMinU();
|
||||
maxU = tex.getMaxU();
|
||||
minV = tex.getMinV();
|
||||
@@ -257,7 +257,7 @@ public final class CubeRenderer {
|
||||
float cm = brightnessPerSide[ForgeDirection.WEST.ordinal()];
|
||||
tessellator.setColorOpaque_F(cm, cm, cm);
|
||||
}
|
||||
tex = faceTextures[5];
|
||||
tex = faceTextures[ForgeDirection.WEST.ordinal()];
|
||||
minU = tex.getMinU();
|
||||
maxU = tex.getMaxU();
|
||||
minV = tex.getMinV();
|
||||
|
||||
@@ -23,6 +23,7 @@ public class IconUtil {
|
||||
private static ArrayList<IIconProvider> iconProviders = new ArrayList<IIconProvider>();
|
||||
|
||||
public static IIcon whiteTexture;
|
||||
public static IIcon blankTexture;
|
||||
|
||||
static {
|
||||
MinecraftForge.EVENT_BUS.register(new IconUtil());
|
||||
|
||||
@@ -110,6 +110,14 @@ public class RenderUtil {
|
||||
return Minecraft.getMinecraft().fontRenderer;
|
||||
}
|
||||
|
||||
public static float[] getDefaultPerSideBrightness() {
|
||||
float[] brightnessPerSide = new float[6];
|
||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
brightnessPerSide[dir.ordinal()] = RenderUtil.getColorMultiplierForFace(dir);
|
||||
}
|
||||
return brightnessPerSide;
|
||||
}
|
||||
|
||||
public static float claculateTotalBrightnessForLocation(World worldObj, int xCoord, int yCoord, int zCoord) {
|
||||
int i = worldObj.getLightBrightnessForSkyBlocks(xCoord, yCoord, zCoord, 0);
|
||||
int j = i % 65536;
|
||||
@@ -177,11 +185,11 @@ public class RenderUtil {
|
||||
tessellator.draw();
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
|
||||
public static Matrix4d createBillboardMatrix(TileEntity te, EntityLivingBase entityPlayer) {
|
||||
return createBillboardMatrix(new Vector3d(te.xCoord + 0.5, te.yCoord + 0.5, te.zCoord + 0.5), entityPlayer);
|
||||
}
|
||||
|
||||
|
||||
public static Matrix4d createBillboardMatrix(Vector3d lookAt, EntityLivingBase entityPlayer) {
|
||||
Vector3d playerEye = new Vector3d(entityPlayer.posX, entityPlayer.posY + 1.62 - entityPlayer.yOffset, entityPlayer.posZ);
|
||||
Vector3d blockOrigin = new Vector3d(lookAt.x, lookAt.y, lookAt.z);
|
||||
@@ -190,7 +198,7 @@ public class RenderUtil {
|
||||
lookMat.invert();
|
||||
return lookMat;
|
||||
}
|
||||
|
||||
|
||||
public static void renderBillboard(Matrix4d lookMat, float minU, float maxU, float minV, float maxV, double size, int brightness) {
|
||||
Tessellator tes = Tessellator.instance;
|
||||
tes.startDrawingQuads();
|
||||
@@ -213,8 +221,6 @@ public class RenderUtil {
|
||||
tes.draw();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* left, bottom, right, top
|
||||
*
|
||||
@@ -336,13 +342,13 @@ public class RenderUtil {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static List<ForgeDirection> getNonConectedEdgesForFace(IBlockAccess blockAccess, int x, int y, int z, ForgeDirection face) {
|
||||
return getNonConectedEdgesForFace(blockAccess, x, y, z, face, false);
|
||||
}
|
||||
|
||||
|
||||
public static List<ForgeDirection> getNonConectedEdgesForFace(IBlockAccess blockAccess, int x, int y, int z, ForgeDirection face, boolean matchMetaData) {
|
||||
|
||||
|
||||
Block block = blockAccess.getBlock(x, y, z);
|
||||
if(block == null) {
|
||||
return Collections.emptyList();
|
||||
@@ -360,12 +366,12 @@ public class RenderUtil {
|
||||
for (EdgeNeighbour edge : edges) {
|
||||
boolean matchingNeighbour = blockAccess.getBlock(edge.bc.x, edge.bc.y, edge.bc.z) == block;
|
||||
if(matchingNeighbour && matchMetaData) {
|
||||
matchingNeighbour = blockAccess.getBlockMetadata(x, y, z) == blockAccess.getBlockMetadata(edge.bc.x, edge.bc.y, edge.bc.z) ;
|
||||
matchingNeighbour = blockAccess.getBlockMetadata(x, y, z) == blockAccess.getBlockMetadata(edge.bc.x, edge.bc.y, edge.bc.z);
|
||||
}
|
||||
if(!matchingNeighbour) {
|
||||
result.add(edge.dir);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -472,7 +478,7 @@ public class RenderUtil {
|
||||
}
|
||||
|
||||
public static void renderGuiTank(FluidTank tank, double x, double y, double zLevel, double width, double height) {
|
||||
renderGuiTank(tank.getFluid(),tank.getCapacity(),tank.getFluidAmount(), x, y, zLevel, width, height);
|
||||
renderGuiTank(tank.getFluid(), tank.getCapacity(), tank.getFluidAmount(), x, y, zLevel, width, height);
|
||||
}
|
||||
|
||||
public static void renderGuiTank(FluidStack fluid, int capacity, int amount, double x, double y, double zLevel, double width, double height) {
|
||||
@@ -488,7 +494,7 @@ public class RenderUtil {
|
||||
}
|
||||
}
|
||||
|
||||
double fullness = (double) amount/ (double) capacity;
|
||||
double fullness = (double) amount / (double) capacity;
|
||||
int fluidHeight = (int) Math.round(height * fullness);
|
||||
|
||||
RenderUtil.bindBlockTexture();
|
||||
@@ -509,7 +515,6 @@ public class RenderUtil {
|
||||
tessellator.draw();
|
||||
}
|
||||
|
||||
|
||||
private static class EdgeNeighbour {
|
||||
final ForgeDirection dir;
|
||||
final BlockCoord bc;
|
||||
|
||||
Reference in new issue
Block a user