Skip to content

Instantly share code, notes, and snippets.

@Bogdan-G
Created June 11, 2017 22:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Bogdan-G/ca672d56175e216b76bf262afb5f6363 to your computer and use it in GitHub Desktop.
Save Bogdan-G/ca672d56175e216b76bf262afb5f6363 to your computer and use it in GitHub Desktop.
package gravestone.tileentity;
import gravestone.block.GraveStoneHelper;
import gravestone.block.enums.EnumGraves;
import gravestone.config.GraveStoneConfig;
import gravestone.core.TimeHelper;
import gravestone.core.event.GSRenderEventHandler;
import gravestone.core.event.GSTickEventHandler;
import gravestone.core.logger.GSLogger;
import gravestone.inventory.GraveInventory;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import java.util.Random;
/**
* GraveStone mod
*
* @author NightKosh
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
*/
public class TileEntityGSGraveStone extends TileEntityGSGrave {
protected GSGraveStoneSpawn gsSpawn;
protected ItemStack sword = null;
protected ItemStack flower = null;
public static final int FOG_RANGE = 30;
protected int intervalUpdate = 20;
protected EntityPlayer cache_player;
protected boolean cp_isNull;
public TileEntityGSGraveStone() {
super();
gsSpawn = new GSGraveStoneSpawn(this);
inventory = new GraveInventory(this);
}
public TileEntityGSGraveStone(World world) {
super();
this.worldObj = world;
gsSpawn = new GSGraveStoneSpawn(this);
inventory = new GraveInventory(this);
}
/**
* Allows the entity to update its state. Overridden in most subclasses,
* e.g. the mob spawner uses this to count ticks and creates a new spawn
* inside its implementation.
*/
@Override
public void updateEntity() {
//test for drop fps
--intervalUpdate;
if (intervalUpdate==0) {
gsSpawn.updateEntity();
intervalUpdate=20;
cache_player = this.worldObj.getClosestPlayer(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D, FOG_RANGE);
cp_isNull = cache_player != null;
}
if (GraveStoneConfig.isFogEnabled && this.worldObj.isRemote && GSRenderEventHandler.getFogTicCount() == 0) {
//EntityPlayer player = this.worldObj.getClosestPlayer(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D, FOG_RANGE);
if (cp_isNull && cache_player.getCommandSenderName().equals(Minecraft.getMinecraft().thePlayer.getCommandSenderName()) && TimeHelper.isFogTime(this.worldObj)) {
GSRenderEventHandler.addFog();
}
}
}
public static boolean isFogTime(World world) {
if (world.isRaining()) {
return TimeHelper.random.nextInt(10)==0;
} else {
long dayTime = TimeHelper.getDayTime(world);
return dayTime > TimeHelper.FOG_START_TIME && dayTime < TimeHelper.FOG_END_TIME;
}
}
/**
* Called when a client event is received with the event number and
* argument, see World.sendClientEvent
*/
@Override
public boolean receiveClientEvent(int par1, int par2) {
if (par1 == 1 && this.worldObj.isRemote) {
gsSpawn.setMinDelay();
}
return true;
}
/**
* Reads a tile entity from NBT.
*/
@Override
public void readFromNBT(NBTTagCompound nbtTag) {
super.readFromNBT(nbtTag);
// grave type
readType(nbtTag);
// grave loot
inventory.readItems(nbtTag);
// death text
gSDeathText.readText(nbtTag);
// age
if (nbtTag.hasKey("Age")) {
age = nbtTag.getInteger("Age");
}
// sword
readSwordInfo(nbtTag);
// read
// TODO
readFlowerInfo(nbtTag);
}
/**
* Writes a tile entity to NBT.
*/
@Override
public void writeToNBT(NBTTagCompound nbtTag) {
super.writeToNBT(nbtTag);
// grave type
saveType(nbtTag);
// grave loot
inventory.saveItems(nbtTag);
// death text
gSDeathText.saveText(nbtTag);
// age
nbtTag.setInteger("Age", age);
// sword
writeSwordInfo(nbtTag);
// flower
writeFlowerInfo(nbtTag);
}
private void readSwordInfo(NBTTagCompound nbtTag) {
// TODO temporary compatibility with old versions - must be removed in feature
if (this.graveType > 4 && this.graveType < 10 || nbtTag.hasKey("SwordGrave")) {
convertSword(nbtTag);
} else if (nbtTag.hasKey("Sword")) {
sword = ItemStack.loadItemStackFromNBT(nbtTag.getCompoundTag("Sword"));
}
}
private void writeSwordInfo(NBTTagCompound nbtTag) {
if (sword != null) {
NBTTagCompound swordNBT = new NBTTagCompound();
sword.writeToNBT(swordNBT);
nbtTag.setTag("Sword", swordNBT);
}
}
private void readFlowerInfo(NBTTagCompound nbtTag) {
if (nbtTag.hasKey("Flower")) {
flower = ItemStack.loadItemStackFromNBT(nbtTag.getCompoundTag("Flower"));
}
}
private void writeFlowerInfo(NBTTagCompound nbtTag) {
if (flower != null) {
NBTTagCompound flowerNBT = new NBTTagCompound();
flower.writeToNBT(flowerNBT);
nbtTag.setTag("Flower", flowerNBT);
}
}
public ItemStack getSword() {
return this.sword;
}
public void setSword(ItemStack sword) {
this.sword = sword;
}
public void dropSword() {
if (this.sword != null) {
this.inventory.dropItem(this.sword, this.worldObj, this.xCoord, this.yCoord, this.zCoord);
}
}
public boolean isSwordGrave() {
return sword != null;
}
public ItemStack getFlower() {
return this.flower;
}
public void setFlower(ItemStack flower) {
this.flower = flower;
}
public void dropFlower() {
if (this.flower != null) {
this.inventory.dropItem(this.flower, this.worldObj, this.xCoord, this.yCoord, this.zCoord);
}
}
public boolean hasFlower() {
return flower != null;
}
public EnumGraves getGraveType() {
return EnumGraves.getByID(graveType);
}
public boolean isEmpty() {
return inventory.isEmpty();
}
private void convertSword(NBTTagCompound nbtTag) {
GSLogger.logInfo("Start converting sword gravestone!");
try {
Item sword;
byte swordType = nbtTag.getByte("SwordType");
if (swordType == 0) {
swordType = (byte) (this.graveType - 4);
}
if (swordType==5) {
sword = Items.diamond_sword;
} else if (swordType==3) {
sword = Items.iron_sword;
} else if (swordType==2) {
sword = Items.stone_sword;
} else if (swordType==4) {
sword = Items.golden_sword;
} else {
sword = Items.wooden_sword;
}
GSLogger.logInfo("Sword type - " + nbtTag.getByte("SwordType") + ". Will be converted to " + sword.getUnlocalizedName());
int damage = 0;
if (nbtTag.hasKey("SwordDamage")) {
damage = nbtTag.getInteger("SwordDamage");
GSLogger.logInfo("Sword damage - " + damage);
}
ItemStack stack = new ItemStack(sword, 1, damage);
if (nbtTag.hasKey("SwordName")) {
stack.setStackDisplayName(nbtTag.getString("SwordName"));
GSLogger.logInfo("Sword name - " + nbtTag.getString("SwordName"));
}
if (nbtTag.hasKey("SwordNBT")) {
stack.setTagCompound(nbtTag.getCompoundTag("SwordNBT"));
}
this.sword = stack;
} catch (Exception e) {
GSLogger.logError("Something went wrong!!!");
e.printStackTrace();
}
GSLogger.logInfo("Gravestone converting complete!");
}
@Override
public void setGraveContent(Random random, boolean isPetGrave, boolean allLoot) {
super.setGraveContent(random, isPetGrave, allLoot);
setRandomFlower(random);
}
public void setRandomFlower(Random random) {
if (random.nextInt(4) == 0) {
ItemStack flower = new ItemStack(GraveStoneHelper.FLOWERS.get(random.nextInt(GraveStoneHelper.FLOWERS.size())), 1);
if (GraveStoneHelper.canFlowerBePlaced(this.worldObj, this.xCoord, this.yCoord, this.zCoord, flower, this)) {
setFlower(flower);
}
}
}
}
package gravestone.renderer.tileentity;
import com.google.common.collect.ImmutableMap;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import gravestone.block.enums.EnumGraves;
import gravestone.core.Resources;
import gravestone.models.block.ModelGraveStone;
import gravestone.models.block.graves.*;
import gravestone.tileentity.TileEntityGSGraveStone;
import net.minecraft.client.renderer.entity.*;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import java.util.Map;
import java.util.*;
import java.util.concurrent.*;
import org.bogdang.modifications.random.*;
//copy from RenderItem
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.*;
import net.minecraft.client.renderer.texture.*;
import net.minecraft.crash.*;
import net.minecraft.item.*;
import net.minecraft.util.*;
import org.lwjgl.opengl.GL12;
import net.minecraftforge.client.ForgeHooksClient;
/**
* GraveStone mod
*
* @author NightKosh
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
*/
@SideOnly(Side.CLIENT)
public class TileEntityGSGraveStoneRenderer extends TileEntityGSRenderer {
public static ModelGraveStone verticalPlate = new ModelVerticalPlateGraveStone();
public static ModelGraveStone cross = new ModelCrossGraveStone();
public static ModelGraveStone horisontalPlate = new ModelHorisontalPlateGraveStone();
public static ModelGraveStone dogStatue = new ModelDogStatueGraveStone();
public static ModelGraveStone catStatue = new ModelCatStatueGraveStone();
public static ModelGraveStone horseStatue = new ModelHorseGraveStone();
public static ModelGraveStone swordGrave = new ModelSwordGrave();
public static TileEntityGSGraveStoneRenderer instance;
private static final Map<EnumGraves, ModelGraveStone> MODELS_MAP = ImmutableMap.<EnumGraves, ModelGraveStone>builder()
.put(EnumGraves.STONE_VERTICAL_PLATE, verticalPlate)
.put(EnumGraves.STONE_CROSS, cross)
.put(EnumGraves.STONE_HORISONTAL_PLATE, horisontalPlate)
.put(EnumGraves.STONE_DOG_STATUE, dogStatue)
.put(EnumGraves.STONE_CAT_STATUE, catStatue)
.put(EnumGraves.WOODEN_SWORD, swordGrave)
.put(EnumGraves.STONE_SWORD, swordGrave)
.put(EnumGraves.IRON_SWORD, swordGrave)
.put(EnumGraves.GOLDEN_SWORD, swordGrave)
.put(EnumGraves.DIAMOND_SWORD, swordGrave)
.put(EnumGraves.STONE_HORSE_STATUE, horseStatue)
// VERTICAL PLATES
.put(EnumGraves.WOODEN_VERTICAL_PLATE, verticalPlate)
.put(EnumGraves.SANDSTONE_VERTICAL_PLATE, verticalPlate)
.put(EnumGraves.IRON_VERTICAL_PLATE, verticalPlate)
.put(EnumGraves.GOLDEN_VERTICAL_PLATE, verticalPlate)
.put(EnumGraves.DIAMOND_VERTICAL_PLATE, verticalPlate)
.put(EnumGraves.EMERALD_VERTICAL_PLATE, verticalPlate)
.put(EnumGraves.LAPIS_VERTICAL_PLATE, verticalPlate)
.put(EnumGraves.REDSTONE_VERTICAL_PLATE, verticalPlate)
.put(EnumGraves.OBSIDIAN_VERTICAL_PLATE, verticalPlate)
.put(EnumGraves.QUARTZ_VERTICAL_PLATE, verticalPlate)
.put(EnumGraves.ICE_VERTICAL_PLATE, verticalPlate)
.put(EnumGraves.MOSSY_VERTICAL_PLATE, verticalPlate)
// CROSSES
.put(EnumGraves.WOODEN_CROSS, cross)
.put(EnumGraves.SANDSTONE_CROSS, cross)
.put(EnumGraves.IRON_CROSS, cross)
.put(EnumGraves.GOLDEN_CROSS, cross)
.put(EnumGraves.DIAMOND_CROSS, cross)
.put(EnumGraves.EMERALD_CROSS, cross)
.put(EnumGraves.LAPIS_CROSS, cross)
.put(EnumGraves.REDSTONE_CROSS, cross)
.put(EnumGraves.OBSIDIAN_CROSS, cross)
.put(EnumGraves.QUARTZ_CROSS, cross)
.put(EnumGraves.ICE_CROSS, cross)
.put(EnumGraves.MOSSY_CROSS, cross)
// HORISONTAL PLATES
.put(EnumGraves.WOODEN_HORISONTAL_PLATE, horisontalPlate)
.put(EnumGraves.SANDSTONE_HORISONTAL_PLATE, horisontalPlate)
.put(EnumGraves.IRON_HORISONTAL_PLATE, horisontalPlate)
.put(EnumGraves.GOLDEN_HORISONTAL_PLATE, horisontalPlate)
.put(EnumGraves.DIAMOND_HORISONTAL_PLATE, horisontalPlate)
.put(EnumGraves.EMERALD_HORISONTAL_PLATE, horisontalPlate)
.put(EnumGraves.LAPIS_HORISONTAL_PLATE, horisontalPlate)
.put(EnumGraves.REDSTONE_HORISONTAL_PLATE, horisontalPlate)
.put(EnumGraves.OBSIDIAN_HORISONTAL_PLATE, horisontalPlate)
.put(EnumGraves.QUARTZ_HORISONTAL_PLATE, horisontalPlate)
.put(EnumGraves.ICE_HORISONTAL_PLATE, horisontalPlate)
.put(EnumGraves.MOSSY_HORISONTAL_PLATE, horisontalPlate)
// DOGS GRAVES
.put(EnumGraves.WOODEN_DOG_STATUE, dogStatue)
.put(EnumGraves.SANDSTONE_DOG_STATUE, dogStatue)
.put(EnumGraves.IRON_DOG_STATUE, dogStatue)
.put(EnumGraves.GOLDEN_DOG_STATUE, dogStatue)
.put(EnumGraves.DIAMOND_DOG_STATUE, dogStatue)
.put(EnumGraves.EMERALD_DOG_STATUE, dogStatue)
.put(EnumGraves.LAPIS_DOG_STATUE, dogStatue)
.put(EnumGraves.REDSTONE_DOG_STATUE, dogStatue)
.put(EnumGraves.OBSIDIAN_DOG_STATUE, dogStatue)
.put(EnumGraves.QUARTZ_DOG_STATUE, dogStatue)
.put(EnumGraves.ICE_DOG_STATUE, dogStatue)
.put(EnumGraves.MOSSY_DOG_STATUE, dogStatue)
// CATS GRAVES
.put(EnumGraves.WOODEN_CAT_STATUE, catStatue)
.put(EnumGraves.SANDSTONE_CAT_STATUE, catStatue)
.put(EnumGraves.IRON_CAT_STATUE, catStatue)
.put(EnumGraves.GOLDEN_CAT_STATUE, catStatue)
.put(EnumGraves.DIAMOND_CAT_STATUE, catStatue)
.put(EnumGraves.EMERALD_CAT_STATUE, catStatue)
.put(EnumGraves.LAPIS_CAT_STATUE, catStatue)
.put(EnumGraves.REDSTONE_CAT_STATUE, catStatue)
.put(EnumGraves.OBSIDIAN_CAT_STATUE, catStatue)
.put(EnumGraves.QUARTZ_CAT_STATUE, catStatue)
.put(EnumGraves.ICE_CAT_STATUE, catStatue)
.put(EnumGraves.MOSSY_CAT_STATUE, catStatue)
// HORSES GRAVES
.put(EnumGraves.WOODEN_HORSE_STATUE, horseStatue)
.put(EnumGraves.SANDSTONE_HORSE_STATUE, horseStatue)
.put(EnumGraves.IRON_HORSE_STATUE, horseStatue)
.put(EnumGraves.GOLDEN_HORSE_STATUE, horseStatue)
.put(EnumGraves.DIAMOND_HORSE_STATUE, horseStatue)
.put(EnumGraves.EMERALD_HORSE_STATUE, horseStatue)
.put(EnumGraves.LAPIS_HORSE_STATUE, horseStatue)
.put(EnumGraves.REDSTONE_HORSE_STATUE, horseStatue)
.put(EnumGraves.OBSIDIAN_HORSE_STATUE, horseStatue)
.put(EnumGraves.QUARTZ_HORSE_STATUE, horseStatue)
.put(EnumGraves.ICE_HORSE_STATUE, horseStatue)
.put(EnumGraves.MOSSY_HORSE_STATUE, horseStatue)
.put(EnumGraves.SWORD, swordGrave).build();// TODO заменить на null
public TileEntityGSGraveStoneRenderer() {
instance = this;
}
public static final Map<Item, ResourceLocation> swordsTextureMap = ImmutableMap.<Item, ResourceLocation>builder()
.put(Items.wooden_sword, Resources.GRAVE_WOODEN_SWORD)
.put(Items.stone_sword, Resources.GRAVE_STONE_SWORD)
.put(Items.iron_sword, Resources.GRAVE_IRON_SWORD)
.put(Items.golden_sword, Resources.GRAVE_GOLDEN_SWORD)
.put(Items.diamond_sword, Resources.GRAVE_DIAMOND_SWORD).build();
/*public static final Map<Item, ResourceLocation> swordsTextureMap = new HashMap<>();
static {
swordsTextureMap.put(Items.wooden_sword, Resources.GRAVE_WOODEN_SWORD);
swordsTextureMap.put(Items.stone_sword, Resources.GRAVE_STONE_SWORD);
swordsTextureMap.put(Items.iron_sword, Resources.GRAVE_IRON_SWORD);
swordsTextureMap.put(Items.golden_sword, Resources.GRAVE_GOLDEN_SWORD);
swordsTextureMap.put(Items.diamond_sword, Resources.GRAVE_DIAMOND_SWORD);
}*/
public static final Map<ItemStack, Object[]> EntityItemMap = new ConcurrentHashMap(500);
//public static Map<EntityItem, boolean[]> EntityItemMapRenderValues = new ConcurrentHashMap();
public static int renderFlower_calls = 0;
public static Random random = new XSTR(new XSTR().getSeed()*(new GeneratorEntropy().getSeed()));
public static RenderBlocks field_147909_c = new RenderBlocks();
public static final Map<TileEntity, TileEntityGSGraveStone> TileEntityMap = new ConcurrentHashMap(1000);
public static int renderTileEntityAt_calls = 0;
@Override
public void renderTileEntityAt(TileEntity te, double x, double y, double z, float f) {
renderTileEntityAt_calls++;
if (renderTileEntityAt_calls==1200000) {
renderTileEntityAt_calls=0;
TileEntityMap.clear();
}
TileEntityGSGraveStone tileEntity = TileEntityMap.get(te);
if (tileEntity==null) {
tileEntity = (TileEntityGSGraveStone) te;
TileEntityMap.put(te, tileEntity);
}
//TileEntityGSGraveStone tileEntity = (TileEntityGSGraveStone) te;
EnumGraves graveType = tileEntity.getGraveType();
int meta = 0;
boolean tegWO = tileEntity.getWorldObj() != null;
if (tegWO) {
meta = tileEntity.getBlockMetadata();
}
if (graveType != EnumGraves.SWORD) {
bindTextureByName(graveType.getTexture());
}
//texture
GL11.glPushMatrix();
if (!tegWO && tileEntity.isSwordGrave()) {
GL11.glTranslatef((float) x + 0.5F, (float) y + 2, (float) z + 0.5F);
GL11.glScalef(1.5F, -1.5F, -1.5F);
} else {
GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);
GL11.glScalef(1.0F, -1F, -1F);
}
//int gGD = getGraveDirection(meta))
if (meta==0) GL11.glRotatef(0, 0, 1, 0);
else if (meta==3) GL11.glRotatef(90, 0, 1, 0);
else if (meta==2) GL11.glRotatef(270, 0, 1, 0);
else GL11.glRotatef(180, 0, 1, 0);
if (tileEntity.isSwordGrave()) {
//renderSword(tileEntity);
//ResourceLocation swordTexture = swordsTextureMap.get(tileEntity.getSword().getItem());
//ModelGraveStone model = MODELS_MAP.get(graveType);
bindTextureByName(swordsTextureMap.get(tileEntity.getSword().getItem()));
if (tileEntity.isEnchanted()) {
MODELS_MAP.get(graveType).renderEnchanted();
} else {
MODELS_MAP.get(graveType).renderAll();
}
} else {
if (tileEntity.isEnchanted()) {
MODELS_MAP.get(graveType).renderEnchanted();
} else {
MODELS_MAP.get(graveType).renderAll();
}
if (tileEntity.hasFlower()) {
renderFlower(tileEntity);
renderFlower_calls++;
if (renderFlower_calls==600000) {
renderFlower_calls=0;
EntityItemMap.clear();
//EntityItemMapRenderValues.clear();
}
}
}
GL11.glPopMatrix();
}
/**
* Return grave direction by metadata
*/
/*private static int getGraveDirection(int meta) {
// S
if (meta==0) return 0;
// E
if (meta==2) return 3;
// W
if (meta==3) return 1;
// N
//if (meta==1) return 2;
//default
return 2;
}*/
/*private void renderSword(TileEntityGSGraveStone te) {
ItemStack sword = te.getSword();
if (te.isEnchanted()) {
if (!sword.isItemEnchanted()) {
if (!sword.hasTagCompound()) {
sword.setTagCompound(new NBTTagCompound());
}
sword.getTagCompound().setTag("ench", new NBTTagList());
}
}
EntityItem entityitem = new EntityItem(te.getWorldObj(), 0, 0, 0, sword);
entityitem.hoverStart = 0;
GL11.glTranslatef(0.24F, 0.83F, 0);
GL11.glScalef(1.5F, -1.5F, -1.5F);
GL11.glRotatef(135, 0, 0, 1);
renderItem(entityitem, 0, 0, 0, 0, 0);
}*/
private void renderFlower(TileEntityGSGraveStone te) {
Object[] objects = EntityItemMap.get(te.getFlower());
if (objects==null) {
EntityItem entityitem = new EntityItem(te.getWorldObj(), 0, 0, 0, te.getFlower());
RenderItem render = (RenderItem)RenderManager.instance.getEntityClassRenderObject(entityitem.getClass());
entityitem.hoverStart = 0;
entityitem.lifespan=Integer.MAX_VALUE;
Object[] objects0 = new Object[]{entityitem, new boolean[]{render.renderInFrame, render.renderWithColor}};
EntityItemMap.put(te.getFlower(), objects0);
objects=objects0;
}
//((EntityItem)objects[0]).hoverStart = 0;
GL11.glTranslatef(0, 1.45F, -0.1F);
GL11.glScalef(1, -1F, -1F);
GL11.glRotatef(45, 0, 1, 0);
//renderItem(entityitem, 0, 0, 0, 0, 0);
//render.doRender(entityitem, 0, 0, 0, 0, 0);
doRender(objects, 0, 0, 0, 0, 0);
GL11.glRotatef(-90, 0, 1, 0);
//renderItem(entityitem, 0, 0, 0, 0, 0);
//render.doRender(entityitem, 0, 0, 0, 0, 0);
doRender(objects, 0, 0, 0, 0, 0);
}
/*public void renderItem(Entity p_147939_1_, double p_147939_2_, double p_147939_4_, double p_147939_6_, float p_147939_8_, float p_147939_9_) {
Render render = null;
try {
render = RenderManager.instance.getEntityClassRenderObject(p_147939_1_.getClass());
if (render != null && !render.isStaticEntity()) {
render.doRender(p_147939_1_, p_147939_2_, p_147939_4_, p_147939_6_, p_147939_8_, p_147939_9_);
//render.doRenderShadowAndFire(p_147939_1_, p_147939_2_, p_147939_4_, p_147939_6_, p_147939_8_, p_147939_9_);//if commited +10fps
}
}
catch (Throwable e) {
cpw.mods.fml.common.FMLLog.log(org.apache.logging.log4j.Level.WARN, e, "GraveStone stacktrace: %s", e);
}
}*/
public void doRender(Object[] objects, double p_76986_2_, double p_76986_4_, double p_76986_6_, float p_76986_8_, float p_76986_9_) {
EntityItem p_76986_1_ = (EntityItem)objects[0];
boolean[] renderValues = (boolean[])objects[1];
ItemStack itemstack = p_76986_1_.getEntityItem();
if (itemstack.getItem() != null) {
Item item = itemstack.getItem();
TextureManager re = RenderManager.instance.renderEngine;
int gISN = itemstack.getItemSpriteNumber();
re.bindTexture(re.getResourceLocation(gISN));
TextureUtil.func_152777_a(false, false, 1.0F);
random.setSeed(187L);
GL11.glPushMatrix();
float f2 = 0F;
float f3 = 6152086455.86365F;
byte b0 = 1;
GL11.glTranslatef((float)p_76986_2_, f2, (float)p_76986_6_);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
float f6;
float f7;
int k;
if (ForgeHooksClient.renderEntityItem(p_76986_1_, itemstack, f2, f3, random, re, field_147909_c, b0))
{
;
}
else
{
float f5;
if (item.requiresMultipleRenderPasses())
{
if (renderValues[0])
{
GL11.glScalef(0.5128205F, 0.5128205F, 0.5128205F);
GL11.glTranslatef(0.0F, -0.05F, 0.0F);
}
else
{
GL11.glScalef(0.5F, 0.5F, 0.5F);
}
for (int j = 0; j < item.getRenderPasses(itemstack.getItemDamage()); ++j)
{
random.setSeed(187L);
IIcon iicon1 = item.getIcon(itemstack, j);
if (renderValues[1])
{
k = item.getColorFromItemStack(itemstack, j);
f5 = (float)(k >> 16 & 255) / 255.0F;
f6 = (float)(k >> 8 & 255) / 255.0F;
f7 = (float)(k & 255) / 255.0F;
GL11.glColor4f(f5, f6, f7, 1.0F);
renderDroppedItem(iicon1, f5, f6, f7);
}
else
{
renderDroppedItem(iicon1, 1.0F, 1.0F, 1.0F);
}
}
}
else
{
if (renderValues[0])
{
GL11.glScalef(0.5128205F, 0.5128205F, 0.5128205F);
GL11.glTranslatef(0.0F, -0.05F, 0.0F);
}
else
{
GL11.glScalef(0.5F, 0.5F, 0.5F);
}
IIcon iicon = itemstack.getIconIndex();
if (renderValues[1])
{
int i = item.getColorFromItemStack(itemstack, 0);
float f4 = (float)(i >> 16 & 255) / 255.0F;
f5 = (float)(i >> 8 & 255) / 255.0F;
f6 = (float)(i & 255) / 255.0F;
renderDroppedItem(iicon, f4, f5, f6);
}
else
{
renderDroppedItem(iicon, 1.0F, 1.0F, 1.0F);
}
}
}
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
GL11.glPopMatrix();
re.bindTexture(re.getResourceLocation(gISN));
TextureUtil.func_147945_b();
}
}
public void renderDroppedItem(IIcon p_77020_2_, float p_77020_5_, float p_77020_6_, float p_77020_7_) {
Tessellator tessellator = Tessellator.instance;
float f14 = ((IIcon)p_77020_2_).getMinU();
float f15 = ((IIcon)p_77020_2_).getMaxU();
float f4 = ((IIcon)p_77020_2_).getMinV();
float f5 = ((IIcon)p_77020_2_).getMaxV();
GL11.glPushMatrix();
GL11.glColor4f(p_77020_5_, p_77020_6_, p_77020_7_, 1.0F);
tessellator.startDrawingQuads();
tessellator.setNormal(0.0F, 1.0F, 0.0F);
tessellator.addVertexWithUV(-0.5D, -0.25D, 0.0D, (double)f14, (double)f5);
tessellator.addVertexWithUV(0.5D, -0.25D, 0.0D, (double)f15, (double)f5);
tessellator.addVertexWithUV(0.5D, 0.75D, 0.0D, (double)f15, (double)f4);
tessellator.addVertexWithUV(-0.5D, 0.75D, 0.0D, (double)f14, (double)f4);
tessellator.draw();
GL11.glPopMatrix();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment