diff --git a/src/main/java/com/hbm/blocks/machine/BlockMassStorage.java b/src/main/java/com/hbm/blocks/machine/BlockMassStorage.java index 03fc8c597..261c36736 100644 --- a/src/main/java/com/hbm/blocks/machine/BlockMassStorage.java +++ b/src/main/java/com/hbm/blocks/machine/BlockMassStorage.java @@ -33,6 +33,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; import net.minecraft.world.World; import net.minecraftforge.client.event.RenderGameOverlayEvent.Pre; @@ -40,7 +41,8 @@ public class BlockMassStorage extends BlockContainer implements IBlockMulti, ILo @SideOnly(Side.CLIENT) private IIcon[] iconTop; @SideOnly(Side.CLIENT) private IIcon[] iconSide; - + @SideOnly(Side.CLIENT) private IIcon[] iconFront; + public BlockMassStorage() { super(Material.iron); } @@ -50,15 +52,23 @@ public class BlockMassStorage extends BlockContainer implements IBlockMulti, ILo public void registerBlockIcons(IIconRegister iconRegister) { this.iconTop = new IIcon[4]; this.iconSide = new IIcon[4]; + this.iconFront = new IIcon[4]; this.iconTop[0] = iconRegister.registerIcon(RefStrings.MODID + ":mass_storage_top_iron"); this.iconSide[0] = iconRegister.registerIcon(RefStrings.MODID + ":mass_storage_side_iron"); + this.iconFront[0] = iconRegister.registerIcon(RefStrings.MODID + ":mass_storage_front_iron"); + this.iconTop[1] = iconRegister.registerIcon(RefStrings.MODID + ":mass_storage_top_desh"); this.iconSide[1] = iconRegister.registerIcon(RefStrings.MODID + ":mass_storage_side_desh"); + this.iconFront[1] = iconRegister.registerIcon(RefStrings.MODID + ":mass_storage_front_desh"); + this.iconTop[2] = iconRegister.registerIcon(RefStrings.MODID + ":mass_storage_top"); this.iconSide[2] = iconRegister.registerIcon(RefStrings.MODID + ":mass_storage_side"); + this.iconFront[2] = iconRegister.registerIcon(RefStrings.MODID + ":mass_storage_front"); + this.iconTop[3] = iconRegister.registerIcon(RefStrings.MODID + ":mass_storage_top_wood"); this.iconSide[3] = iconRegister.registerIcon(RefStrings.MODID + ":mass_storage_side_wood"); + this.iconFront[3] = iconRegister.registerIcon(RefStrings.MODID + ":mass_storage_front_wood"); } @Override @@ -74,20 +84,24 @@ public class BlockMassStorage extends BlockContainer implements IBlockMulti, ILo @SideOnly(Side.CLIENT) public IIcon getIcon(int side, int metadata) { int meta = this.rectify(metadata); - return side == 1 ? this.iconTop[meta] : (side == 0 ? this.iconTop[meta] : this.iconSide[meta]); + int dir = (metadata / getSubCount()) + 2; + if(side == 0 || side == 1) return iconTop[meta]; + if(side == dir) return iconFront[meta]; + return iconSide[meta]; } @Override public int damageDropped(int meta) { - return meta; + return rectify(meta); } @Override public TileEntity createNewTileEntity(World world, int meta) { return new TileEntityMassStorage(getCapacity(meta)); } - + public int getCapacity(int meta) { + meta = rectify(meta); return meta == 3 ? 100 : meta == 0 ? 10_000 : meta == 1 ? 100_000 : meta == 2 ? 1_000_000 : 0; } @@ -108,121 +122,129 @@ public class BlockMassStorage extends BlockContainer implements IBlockMulti, ILo return false; } } - + private static boolean dropInv = true; - + @Override public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) { - + if(!player.capabilities.isCreativeMode && !world.isRemote && willHarvest) { - - ItemStack drop = new ItemStack(this, 1, world.getBlockMetadata(x, y, z)); + + ItemStack drop = new ItemStack(this, 1, rectify(world.getBlockMetadata(x, y, z))); ISidedInventory inv = (ISidedInventory)world.getTileEntity(x, y, z); - + NBTTagCompound nbt = new NBTTagCompound(); - + if(inv != null) { - + for(int i = 0; i < inv.getSizeInventory(); i++) { - + ItemStack stack = inv.getStackInSlot(i); if(stack == null) continue; - + NBTTagCompound slot = new NBTTagCompound(); stack.writeToNBT(slot); nbt.setTag("slot" + i, slot); } } - + if(inv instanceof TileEntityLockableBase) { TileEntityLockableBase lockable = (TileEntityLockableBase) inv; - + if(lockable.isLocked()) { nbt.setInteger("lock", lockable.getPins()); nbt.setDouble("lockMod", lockable.getMod()); } } - + if(inv instanceof TileEntityMassStorage && nbt.func_150296_c().size() > 0) { TileEntityMassStorage storage = (TileEntityMassStorage) inv; nbt.setInteger("stack", storage.getStockpile()); } - + if(!nbt.hasNoTags()) { drop.stackTagCompound = nbt; } - + world.spawnEntityInWorld(new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, drop)); } - + dropInv = false; boolean flag = world.setBlockToAir(x, y, z); dropInv = true; - + return flag; } @Override public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) { - + ISidedInventory inv = (ISidedInventory)world.getTileEntity(x, y, z); - + if(inv != null && stack.hasTagCompound()) { - + for(int i = 0; i < inv.getSizeInventory(); i++) { inv.setInventorySlotContents(i, ItemStack.loadItemStackFromNBT(stack.stackTagCompound.getCompoundTag("slot" + i))); } - + if(inv instanceof TileEntityMassStorage) { TileEntityMassStorage storage = (TileEntityMassStorage) inv; - + if(stack.stackTagCompound.hasKey("lock")) { storage.setPins(stack.stackTagCompound.getInteger("lock")); storage.setMod(stack.stackTagCompound.getDouble("lockMod")); storage.lock(); } - + storage.setStockpile(stack.stackTagCompound.getInteger("stack")); } } super.onBlockPlacedBy(world, x, y, z, player, stack); + + int i = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3; + int meta = stack.getItemDamage(); + + if(i == 0) world.setBlockMetadataWithNotify(x, y, z, meta, 2); + if(i == 1) world.setBlockMetadataWithNotify(x, y, z, meta + 3 * getSubCount(), 2); + if(i == 2) world.setBlockMetadataWithNotify(x, y, z, meta + 1 * getSubCount(), 2); + if(i == 3) world.setBlockMetadataWithNotify(x, y, z, meta + 2 * getSubCount(), 2); } - + @Override public void breakBlock(World world, int x, int y, int z, Block block, int meta) { if(dropInv) { ISidedInventory sided = (ISidedInventory) world.getTileEntity(x, y, z); Random rand = world.rand; - + if(sided != null) { for(int i1 = 0; i1 < sided.getSizeInventory(); ++i1) { - + if(i1 == 1) continue; //do NOT drop the filter item - + ItemStack itemstack = sided.getStackInSlot(i1); - + if(itemstack != null) { float f = rand.nextFloat() * 0.8F + 0.1F; float f1 = rand.nextFloat() * 0.8F + 0.1F; float f2 = rand.nextFloat() * 0.8F + 0.1F; - + while(itemstack.stackSize > 0) { int j1 = rand.nextInt(21) + 10; - + if(j1 > itemstack.stackSize) { j1 = itemstack.stackSize; } - + itemstack.stackSize -= j1; EntityItem entityitem = new EntityItem(world, x + f, y + f1, z + f2, new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage())); - + if(itemstack.hasTagCompound()) { entityitem.getEntityItem().setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy()); } - + float f3 = 0.05F; entityitem.motionX = (float) rand.nextGaussian() * f3; entityitem.motionY = (float) rand.nextGaussian() * f3 + 0.2F; @@ -231,7 +253,7 @@ public class BlockMassStorage extends BlockContainer implements IBlockMulti, ILo } } } - + world.func_147453_f(x, y, z, block); } } @@ -251,51 +273,51 @@ public class BlockMassStorage extends BlockContainer implements IBlockMulti, ILo @Override public void printHook(Pre event, World world, int x, int y, int z) { - + TileEntity te = world.getTileEntity(x, y, z); - + if(!(te instanceof TileEntityMassStorage)) return; - + TileEntityMassStorage storage = (TileEntityMassStorage) te; - + List text = new ArrayList(); String title = "Empty"; boolean full = storage.type != null; - + if(full) { - + title = storage.type.getDisplayName(); text.add(String.format(Locale.US, "%,d", storage.getStockpile()) + " / " + String.format(Locale.US, "%,d", storage.getCapacity())); - + double percent = (double) storage.getStockpile() / (double) storage.getCapacity(); int charge = (int) Math.floor(percent * 10_000D); int color = ((int) (0xFF - 0xFF * percent)) << 16 | ((int)(0xFF * percent) << 8); - + text.add("&[" + color + "&]" + (charge / 100D) + "%"); } - + ILookOverlay.printGeneric(event, title, full ? 0xffff00 : 0x00ffff, full ? 0x404000 : 0x004040, text); } @Override public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean ext) { - + if(!stack.hasTagCompound()) return; - + ItemStack type = ItemStack.loadItemStackFromNBT(stack.stackTagCompound.getCompoundTag("slot1")); - + if(type != null) { list.add(EnumChatFormatting.GOLD + type.getDisplayName()); list.add(String.format(Locale.US, "%,d", stack.stackTagCompound.getInteger("stack")) + " / " + String.format(Locale.US, "%,d", getCapacity(stack.getItemDamage()))); } } - + @Override public boolean hasComparatorInputOverride() { return true; } - + @Override public int getComparatorInputOverride(World world, int x, int y, int z, int side) { return ((TileEntityMassStorage) world.getTileEntity(x, y, z)).redstone; diff --git a/src/main/java/com/hbm/main/ClientProxy.java b/src/main/java/com/hbm/main/ClientProxy.java index 1ddbfce2c..b39761e3e 100644 --- a/src/main/java/com/hbm/main/ClientProxy.java +++ b/src/main/java/com/hbm/main/ClientProxy.java @@ -443,6 +443,8 @@ public class ClientProxy extends ServerProxy { ClientRegistry.bindTileEntitySpecialRenderer(TileEntityVaultDoor.class, new RenderVaultDoor()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityBlastDoor.class, new RenderBlastDoor()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityDoorGeneric.class, new RenderDoorGeneric()); + //storage + ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMassStorage.class, new RenderMassStorage()); //NBTStructure ClientRegistry.bindTileEntitySpecialRenderer(TileEntityWandStructure.class, new RenderWandStructure()); } diff --git a/src/main/java/com/hbm/render/tileentity/RenderMassStorage.java b/src/main/java/com/hbm/render/tileentity/RenderMassStorage.java new file mode 100644 index 000000000..274dd10ae --- /dev/null +++ b/src/main/java/com/hbm/render/tileentity/RenderMassStorage.java @@ -0,0 +1,136 @@ +package com.hbm.render.tileentity; + +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +import com.hbm.render.util.RenderDecoItem; +import com.hbm.tileentity.machine.storage.TileEntityMassStorage; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.entity.RenderItem; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.tileentity.TileEntity; + +@SideOnly(Side.CLIENT) +public class RenderMassStorage extends TileEntitySpecialRenderer { + + private RenderItem itemRenderer = new RenderDecoItem(this); + + @Override + public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float interp) { + if(!(tile instanceof TileEntityMassStorage)) return; + TileEntityMassStorage storage = (TileEntityMassStorage) tile; + + if(storage.type == null) return; + + Minecraft mc = Minecraft.getMinecraft(); + int dir = storage.getBlockMetadata() / 4; + + // fuck this shit, push pop the whole ass lighting state then for all I fucken care + GL11.glPushAttrib(GL11.GL_ENABLE_BIT | GL11.GL_LIGHTING_BIT | GL11.GL_COLOR_BUFFER_BIT | GL11.GL_TRANSFORM_BIT); + + GL11.glDisable(GL12.GL_RESCALE_NORMAL); + GL11.glDisable(GL11.GL_NORMALIZE); + + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240, 240); + + GL11.glPushMatrix(); + { + + // align to block + GL11.glTranslated(x, y, z); + + // align item (and flip) + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + GL11.glRotatef(180.0F, 0, 0, 1); + switch(dir) { + case 1: GL11.glRotatef(180.0F, 0, 1, 0); break; + case 2: GL11.glRotatef(-90.0F, 0, 1, 0); break; + case 3: GL11.glRotatef(90.0F, 0, 1, 0); break; + } + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + + + GL11.glTranslatef(0, 0, -0.005F); // offset to prevent z-fighting + GL11.glScalef(1.0F / 16.0F, 1.0F / 16.0F, -0.0001F); // scale to block size + + + GL11.glPushMatrix(); + { + + GL11.glTranslatef(4.0F, 2.5F, 0); // adjust to centered location + GL11.glScalef(8.0F / 16.0F, 8.0F / 16.0F, 1); // scale to 8 pixels across + + if(mc.gameSettings.fancyGraphics) { + itemRenderer.renderItemAndEffectIntoGUI(mc.fontRenderer, mc.renderEngine, storage.type, 0, 0); + } else { + itemRenderer.renderItemIntoGUI(mc.fontRenderer, mc.renderEngine, storage.type, 0, 0, true); + } + + } + GL11.glPopMatrix(); + + GL11.glColor3f(1, 1, 1); + + String text = getTextForCount(storage.getStockpile(), mc.fontRenderer.getUnicodeFlag()); + + int textX = 32 - mc.fontRenderer.getStringWidth(text) / 2; + int textY = 44; + + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glPushMatrix(); + { + + GL11.glScalef(4.0F / 16.0F, 4.0F / 16.0F, 4.0F / 16.0F); + + int fontColor = 0x00FF00; + + // funky text shadow rendering with no z-fighting and alpha testing still enabled + mc.fontRenderer.drawString(text, textX + 1, textY + 1, (fontColor & 16579836) >> 2 | fontColor & -16777216); + GL11.glTranslatef(0, 0, 1); + mc.fontRenderer.drawString(text, textX, textY, 0x00FF00); + + } + GL11.glPopMatrix(); + + GL11.glDisable(GL11.GL_TEXTURE_2D); + + double fraction = (double) storage.getStockpile() / (double) storage.getCapacity(); + + GL11.glColor3d(1.0 - fraction, fraction, 0.0); + + double bMinX = 2; + double bMaxX = 2 + fraction * 12; + double bMinY = 13.5; + double bMaxY = 14; + + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.addVertex(bMinX, bMaxY, 0); + tessellator.addVertex(bMaxX, bMaxY, 0); + tessellator.addVertex(bMaxX, bMinY, 0); + tessellator.addVertex(bMinX, bMinY, 0); + tessellator.draw(); + + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glEnable(GL11.GL_LIGHTING); + + } + GL11.glPopMatrix(); + + GL11.glPopAttrib(); + } + + private String getTextForCount(int stackSize, boolean isUnicode) { + if(stackSize >= 100000000 || (stackSize >= 1000000 && isUnicode)) return String.format("%.0fM", stackSize / 1000000f); + if(stackSize >= 1000000) return String.format("%.1fM", stackSize / 1000000f); + if(stackSize >= 100000 || (stackSize >= 10000 && isUnicode)) return String.format("%.0fK", stackSize / 1000f); + if(stackSize >= 10000) return String.format("%.1fK", stackSize / 1000f); + return String.valueOf(stackSize); + } + +} diff --git a/src/main/java/com/hbm/render/util/RenderDecoItem.java b/src/main/java/com/hbm/render/util/RenderDecoItem.java index b7e6d2a70..2a3b8f59c 100644 --- a/src/main/java/com/hbm/render/util/RenderDecoItem.java +++ b/src/main/java/com/hbm/render/util/RenderDecoItem.java @@ -1,16 +1,29 @@ package com.hbm.render.util; +import org.lwjgl.opengl.GL11; + +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.entity.RenderItem; import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.renderer.texture.TextureManager; +import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; /** * For small items as part of a TESR, e.g. items in a press * @author hbm */ public class RenderDecoItem extends RenderItem { - + public RenderDecoItem(TileEntitySpecialRenderer render) { this.setRenderManager(RenderManager.instance); } @@ -34,4 +47,147 @@ public class RenderDecoItem extends RenderItem { public boolean shouldSpreadItems() { return false; } + + + /** + * Fixes z-fighting issues with item glints when using GUI (flat) rendering in world, from StorageDrawers 1.7.10 + */ + + private static final ResourceLocation RES_ITEM_GLINT = new ResourceLocation("textures/misc/enchanted_item_glint.png"); + private RenderBlocks renderBlocksRi = new RenderBlocks(); + + @Override + public void renderItemIntoGUI(FontRenderer fontRenderer, TextureManager texManager, ItemStack itemStack, int x, int y, boolean renderEffect) { + if(itemStack.getItemSpriteNumber() == 0 && RenderBlocks.renderItemIn3d(Block.getBlockFromItem(itemStack.getItem()).getRenderType())) { + renderItemIntoGUIBlock(fontRenderer, texManager, itemStack, x, y, renderEffect); + return; + } + + Item item = itemStack.getItem(); + int meta = itemStack.getItemDamage(); + + ResourceLocation loc = itemStack.getItem().requiresMultipleRenderPasses() + ? (item.getSpriteNumber() == 0 ? TextureMap.locationBlocksTexture : TextureMap.locationItemsTexture) + : (texManager.getResourceLocation(itemStack.getItemSpriteNumber())); + + for(int i = 0; i < item.getRenderPasses(meta); ++i) { + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + texManager.bindTexture(loc); + + IIcon icon = itemStack.getItem().requiresMultipleRenderPasses() + ? item.getIcon(itemStack, i) + : itemStack.getIconIndex(); + + if(icon == null) continue; + + int color = itemStack.getItem().getColorFromItemStack(itemStack, i); + float r = (float)(color >> 16 & 255) / 255.0F; + float g = (float)(color >> 8 & 255) / 255.0F; + float b = (float)(color & 255) / 255.0F; + + if(renderWithColor) + GL11.glColor4f(r, g, b, 1.0F); + + GL11.glEnable(GL11.GL_POLYGON_OFFSET_FILL); + GL11.glPolygonOffset(-1f, -1); + + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_ALPHA_TEST); + + renderIcon(x, y, icon, 16, 16); + + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_LIGHTING); + + if(renderEffect && itemStack.hasEffect(i)) + renderEffect(texManager, x, y); + + GL11.glDisable(GL11.GL_POLYGON_OFFSET_FILL); + } + } + + @Override + public void renderEffect(TextureManager manager, int x, int y) { + GL11.glDepthFunc(GL11.GL_EQUAL); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDepthMask(false); + manager.bindTexture(RES_ITEM_GLINT); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_BLEND); + GL11.glColor4f(0.5F, 0.25F, 0.8F, 1.0F); + renderGlint(x, y, 16, 16); + GL11.glDepthMask(true); + GL11.glDisable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glDepthFunc(GL11.GL_LEQUAL); + } + + private void renderGlint(int x, int y, int w, int h) { + for(int i = 0; i < 2; ++i) { + OpenGlHelper.glBlendFunc(772, 1, 0, 0); + float uScale = 0.00390625F; + float vScale = 0.00390625F; + float u = (Minecraft.getSystemTime() % (3000 + i * 1873)) / (3000.0F + i * 1873) * 256.0F; + float v = 0.0F; + + float hScale = (i < 1) ? 4.0F : -1.0F; + + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.addVertexWithUV(x + 0, y + h, 0, (u + (float)h * hScale) * uScale, (v + (float)h) * vScale); + tessellator.addVertexWithUV(x + w, y + h, 0, (u + (float)w + (float)h * hScale) * uScale, (v + (float)h) * vScale); + tessellator.addVertexWithUV(x + w, y + 0, 0, (u + (float)w) * uScale, (v + 0.0F) * vScale); + tessellator.addVertexWithUV(x + 0, y + 0, 0, (u + 0.0F) * uScale, (v + 0.0F) * vScale); + tessellator.draw(); + } + } + + private void renderItemIntoGUIBlock(FontRenderer fontRenderer, TextureManager texManager, ItemStack itemStack, int x, int y, boolean renderEffect) { + texManager.bindTexture(TextureMap.locationBlocksTexture); + Block block = Block.getBlockFromItem(itemStack.getItem()); + + if(block.getRenderBlockPass() != 0) { + GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + } else { + GL11.glAlphaFunc(GL11.GL_GREATER, 0.5F); + GL11.glDisable(GL11.GL_BLEND); + } + + GL11.glPushMatrix(); + GL11.glTranslatef(x - 2, y + 3, zLevel - 3); + GL11.glScalef(10, 10, 10); + GL11.glTranslatef(1, 0.5f, 1); + GL11.glScalef(1, 1, -1); + GL11.glRotatef(210, 1, 0, 0); + GL11.glRotatef(45, 0, 1, 0); + + int color = itemStack.getItem().getColorFromItemStack(itemStack, 0); + float r = (float)(color >> 16 & 255) / 255.0F; + float g = (float)(color >> 8 & 255) / 255.0F; + float b = (float)(color & 255) / 255.0F; + + if(this.renderWithColor) + GL11.glColor4f(r * 1, g * 1, b * 1, 1.0F); + + GL11.glRotatef(-90, 0, 1, 0); + GL11.glEnable(GL11.GL_POLYGON_OFFSET_FILL); + GL11.glPolygonOffset(-1f, -1f); + + this.renderBlocksRi.useInventoryTint = this.renderWithColor; + this.renderBlocksRi.renderBlockAsItem(block, itemStack.getItemDamage(), 1); + this.renderBlocksRi.useInventoryTint = true; + + GL11.glDisable(GL11.GL_POLYGON_OFFSET_FILL); + + if(block.getRenderBlockPass() == 0) + GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); + + GL11.glPopMatrix(); + } + } diff --git a/src/main/java/com/hbm/tileentity/machine/storage/TileEntityMassStorage.java b/src/main/java/com/hbm/tileentity/machine/storage/TileEntityMassStorage.java index cba7bf1f0..75ebceb3a 100644 --- a/src/main/java/com/hbm/tileentity/machine/storage/TileEntityMassStorage.java +++ b/src/main/java/com/hbm/tileentity/machine/storage/TileEntityMassStorage.java @@ -3,7 +3,6 @@ package com.hbm.tileentity.machine.storage; import com.hbm.inventory.container.ContainerMassStorage; import com.hbm.inventory.gui.GUIMassStorage; import com.hbm.items.ModItems; -import com.hbm.tileentity.IBufPacketReceiver; import com.hbm.tileentity.IControlReceiverFilter; import com.hbm.util.BufferUtil; @@ -21,7 +20,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.Vec3; import net.minecraft.world.World; -public class TileEntityMassStorage extends TileEntityCrateBase implements IBufPacketReceiver, IControlReceiverFilter, IRORValueProvider, IRORInteractive { +public class TileEntityMassStorage extends TileEntityCrateBase implements IControlReceiverFilter, IRORValueProvider, IRORInteractive { private int stack = 0; public boolean output = false; @@ -92,7 +91,7 @@ public class TileEntityMassStorage extends TileEntityCrateBase implements IBufPa } } - networkPackNT(15); + networkPackNT(32); // TE render distance } } @@ -129,7 +128,7 @@ public class TileEntityMassStorage extends TileEntityCrateBase implements IBufPa } // Note: the following three methods are used for AE2 integration, and aren't meant to be called in any other context by default - + public int getTotalStockpile() { ItemStack type = getType(); if(type == null) return 0; @@ -174,7 +173,7 @@ public class TileEntityMassStorage extends TileEntityCrateBase implements IBufPa } amount -= depositStockpile; } - + int inputAvail = 0; ItemStack inStack = slots[0]; if(inStack != null && ItemStackUtil.areStacksCompatible(type, inStack)) { @@ -197,7 +196,7 @@ public class TileEntityMassStorage extends TileEntityCrateBase implements IBufPa } amount -= depositInput; } - + int outputAvail = 0; ItemStack outStack = slots[2]; if(outStack != null && ItemStackUtil.areStacksCompatible(type, outStack)) { @@ -224,7 +223,7 @@ public class TileEntityMassStorage extends TileEntityCrateBase implements IBufPa if(actually) { this.markDirty(); } - + return amount; } @@ -295,6 +294,11 @@ public class TileEntityMassStorage extends TileEntityCrateBase implements IBufPa nbt.setByte("redstone", (byte) redstone); } + @SideOnly(Side.CLIENT) + public double getMaxRenderDistanceSquared() { + return 1024.0D; // only render mass storage info 32 blocks away, for performance + } + @Override public void nextMode(int i) { @@ -389,12 +393,12 @@ public class TileEntityMassStorage extends TileEntityCrateBase implements IBufPa @Override public String runRORFunction(String name, String[] params) { - + if((PREFIX_FUNCTION + "toggleoutput").equals(name)) { this.output = !this.output; this.markDirty(); } - + return null; } } diff --git a/src/main/resources/assets/hbm/textures/blocks/mass_storage_front.png b/src/main/resources/assets/hbm/textures/blocks/mass_storage_front.png new file mode 100644 index 000000000..47eca2890 Binary files /dev/null and b/src/main/resources/assets/hbm/textures/blocks/mass_storage_front.png differ diff --git a/src/main/resources/assets/hbm/textures/blocks/mass_storage_front_desh.png b/src/main/resources/assets/hbm/textures/blocks/mass_storage_front_desh.png new file mode 100644 index 000000000..1e6134282 Binary files /dev/null and b/src/main/resources/assets/hbm/textures/blocks/mass_storage_front_desh.png differ diff --git a/src/main/resources/assets/hbm/textures/blocks/mass_storage_front_iron.png b/src/main/resources/assets/hbm/textures/blocks/mass_storage_front_iron.png new file mode 100644 index 000000000..2a3f5210e Binary files /dev/null and b/src/main/resources/assets/hbm/textures/blocks/mass_storage_front_iron.png differ diff --git a/src/main/resources/assets/hbm/textures/blocks/mass_storage_front_wood.png b/src/main/resources/assets/hbm/textures/blocks/mass_storage_front_wood.png new file mode 100644 index 000000000..913dcd7cc Binary files /dev/null and b/src/main/resources/assets/hbm/textures/blocks/mass_storage_front_wood.png differ