mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
draw the rest of the owl
This commit is contained in:
parent
18a4d7a25a
commit
b77633b152
@ -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));
|
||||
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<String> 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;
|
||||
|
||||
@ -2,190 +2,22 @@ package com.hbm.render.tileentity;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
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.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.RenderHelper;
|
||||
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.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class RenderMassStorage extends TileEntitySpecialRenderer {
|
||||
|
||||
private static final ResourceLocation RES_ITEM_GLINT = new ResourceLocation("textures/misc/enchanted_item_glint.png");
|
||||
|
||||
private RenderItem itemRenderer = new RenderItem() {
|
||||
|
||||
private RenderBlocks renderBlocksRi = new RenderBlocks();
|
||||
|
||||
@Override
|
||||
public byte getMiniBlockCount(ItemStack stack, byte original) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldBob() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldSpreadItems() {
|
||||
return false;
|
||||
}
|
||||
|
||||
// The default Mojang code for item render does not handle glinted or multi-pass items gracefully in a non-UI
|
||||
// setting. This modified implementation will render these items without unsightly Z-fighting.
|
||||
|
||||
@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();
|
||||
}
|
||||
};
|
||||
private RenderItem itemRenderer = new RenderDecoItem(this);
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float interp) {
|
||||
@ -195,15 +27,9 @@ public class RenderMassStorage extends TileEntitySpecialRenderer {
|
||||
if(storage.type == null) return;
|
||||
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
World world = tile.getWorldObj();
|
||||
ForgeDirection dir = storage.getDirection();
|
||||
int dir = storage.getBlockMetadata() / 4;
|
||||
|
||||
itemRenderer.setRenderManager(RenderManager.instance);
|
||||
|
||||
int ambLight = world.getLightBrightnessForSkyBlocks(tile.xCoord + dir.offsetX, tile.yCoord + dir.offsetY, tile.zCoord + dir.offsetZ, 0);
|
||||
int lu = ambLight % 65536;
|
||||
int lv = ambLight / 65536;
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lu, lv);
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240, 240);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
{
|
||||
@ -214,16 +40,67 @@ public class RenderMassStorage extends TileEntitySpecialRenderer {
|
||||
// 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);
|
||||
|
||||
// move and scale item
|
||||
GL11.glTranslatef(0, 0, -0.005F);
|
||||
GL11.glScalef(1.0F / 16.0F, 1.0F / 16.0F, -0.0001F);
|
||||
|
||||
itemRenderer.renderItemIntoGUI(mc.fontRenderer, mc.renderEngine, storage.type, 0, 0, true);
|
||||
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, 3, 0); // adjust up one pixel
|
||||
GL11.glScalef(8.0F / 16.0F, 8.0F / 16.0F, 1); // scale to 8 pixels across
|
||||
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
|
||||
itemRenderer.renderItemIntoGUI(mc.fontRenderer, mc.renderEngine, storage.type, 0, 0, true);
|
||||
itemRenderer.renderItemOverlayIntoGUI(mc.fontRenderer, mc.renderEngine, storage.type, 0, 0);
|
||||
|
||||
}
|
||||
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 = 46;
|
||||
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glPushMatrix();
|
||||
{
|
||||
|
||||
GL11.glScalef(4.0F / 16.0F, 4.0F / 16.0F, 4.0F / 16.0F);
|
||||
|
||||
int fontColor = 0x00FF00;
|
||||
|
||||
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.glEnable(GL11.GL_LIGHTING);
|
||||
|
||||
}
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -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;
|
||||
@ -20,9 +19,8 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
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;
|
||||
@ -259,10 +257,6 @@ public class TileEntityMassStorage extends TileEntityCrateBase implements IBufPa
|
||||
this.stack = stack;
|
||||
}
|
||||
|
||||
public ForgeDirection getDirection() {
|
||||
return ForgeDirection.NORTH;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(EntityPlayer player) {
|
||||
return Vec3.createVectorHelper(xCoord - player.posX, yCoord - player.posY, zCoord - player.posZ).lengthVector() < 20;
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 335 B |
Binary file not shown.
|
After Width: | Height: | Size: 343 B |
Binary file not shown.
|
After Width: | Height: | Size: 329 B |
Binary file not shown.
|
After Width: | Height: | Size: 455 B |
Loading…
x
Reference in New Issue
Block a user