Jump to content

Recommended Posts

Posted

Hi, I'm trying to make a transparent block with an item inside. I want the item to have the same animation as a dropped item. I made the model and a tesr for it so I can render the item but I have no clue how do what I want. I tried looking into the TileEntityItemStackRenderer class to see how they are rendering the items on the ground (I believe it's the right class) and the only thing I found is this line:

 

 

            else if (block != Blocks.CHEST) net.minecraftforge.client.ForgeHooksClient.renderTileItem(itemStackIn.getItem(), itemStackIn.getMetadata());

 

 

So I went into the ForgeHooksClient class and found the above function but I couldn't find where the render is done.

 

 

An image of the block:

 

315b0b3be1c2b53cbf2a9c1e4fd4242b.png

 

 

 

My classes:

 

Block:

 

package com.wartimepvp.blocks;


import com.wartimepvp.tileentities.BlockShowcaseTileEntity;


import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumBlockRenderType;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;


public class BlockShowcase extends BlockContainer 
{


   public BlockShowcase(Material material) 
   {
      super(material);
      this.setResistance(5.0F);
      this.setHardness(1.0F);
      this.setCreativeTab(CreativeTabs.BUILDING_BLOCKS);
   }
   
   @SideOnly(Side.CLIENT)
    public BlockRenderLayer getBlockLayer()
    {
        return BlockRenderLayer.CUTOUT;
    }
   
   @Override
   public boolean isOpaqueCube(IBlockState state)
    {
        return false;
    }
   
   @Override
   public EnumBlockRenderType getRenderType(IBlockState state)
    {
        return EnumBlockRenderType.MODEL;
    }


    public boolean isFullCube(IBlockState state)
    {
        return true;
    }


   @Override
   public TileEntity createNewTileEntity(World worldIn, int meta) {
      return new BlockShowcaseTileEntity();
   }


}

 

 

 

 

TileEntitySpecialRenderer:

 

package com.wartimepvp.tesr;


import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;


public class BlockShowcaseTileEntitySpecialRenderer extends TileEntitySpecialRenderer 
{
   @Override
   public void renderTileEntityAt(TileEntity te, double x, double y, double z, float partialTicks, int destroyStage) 
   {
       GlStateManager.pushMatrix();
       GlStateManager.translate(x, y + 0.2, z);


       GlStateManager.popMatrix();
   }
}

 

Posted

Look at

RenderEntityItem

to see how it renders items on the ground.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

Or if you want to be super lazy, create an item entity (don't spawn it) and tell the render engine to render it normally.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

I would you do that? I created a new instance of EntityItem but how do I render it? I never did this before, sorry if it seems obvious to you.

 

 

 

	EntityItem item;

public BlockShowcaseTileEntitySpecialRenderer() 
{
	item = new EntityItem(Minecraft.getMinecraft().theWorld, 0, 0, 0, new ItemStack(Items.APPLE));
}

@Override
public void renderTileEntityAt(TileEntity te, double x, double y, double z, float partialTicks, int destroyStage) 
{
	item.setPosition(x + 0.5, y + 0.1, z + 0.5);
    GlStateManager.pushMatrix();
    
    GlStateManager.popMatrix();
}

 

Posted

Ok so I looked at the RenderEntityItem class and tried to make something from this.

 

 

What it looks like:

1cc72b636752b15dbf8731127f404a49.png

 

 

Tesr:

public class BlockShowcaseTileEntitySpecialRenderer extends TileEntitySpecialRenderer 
{
   private EntityItem item;
   private final Random random = new Random();
   
   public BlockShowcaseTileEntitySpecialRenderer() 
   {
      item = new EntityItem(Minecraft.getMinecraft().theWorld, 0, 0, 0, new ItemStack(Items.APPLE));
   }
   
   @Override
   public void renderTileEntityAt(TileEntity te, double x, double y, double z, float partialTicks, int destroyStage) 
   {
      boolean flag = false;
      if (this.bindEntityTexture(item))
        {
            Minecraft.getMinecraft().getRenderManager().renderEngine.getTexture(this.getEntityTexture(item)).setBlurMipmap(false, false);
            flag = true;
        }
      GlStateManager.enableRescaleNormal();
        GlStateManager.alphaFunc(516, 0.1F);
        GlStateManager.enableBlend();
        RenderHelper.enableStandardItemLighting();
        GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
        GlStateManager.pushMatrix();
       IBakedModel ibakedmodel = Minecraft.getMinecraft().getRenderItem().getItemModelWithOverrides(new ItemStack(Items.APPLE), te.getWorld(), (EntityLivingBase)null);
       int j = this.transformModelCount(item, x, y, z, partialTicks, ibakedmodel);
       
       boolean flag1 = ibakedmodel.isGui3d();

        if (!flag1)
        {
            float f3 = -0.0F * (float)(j - 1) * 0.5F;
            float f4 = -0.0F * (float)(j - 1) * 0.5F;
            float f5 = -0.09375F * (float)(j - 1) * 0.5F;
            GlStateManager.translate(f3, f4, f5);
        }
        
        for (int k = 0; k < j; ++k)
        {
            if (flag1)
            {
                GlStateManager.pushMatrix();

                if (k > 0)
                {
                    float f7 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.15F;
                    float f9 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.15F;
                    float f6 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.15F;
                    GlStateManager.translate(shouldSpreadItems() ? f7 : 0, shouldSpreadItems() ? f9 : 0, f6);
                }

                ibakedmodel = net.minecraftforge.client.ForgeHooksClient.handleCameraTransforms(ibakedmodel, ItemCameraTransforms.TransformType.GROUND, false);
                Minecraft.getMinecraft().getRenderItem().renderItem(new ItemStack(Items.APPLE), ibakedmodel);
                GlStateManager.popMatrix();
            }
            else
            {
                GlStateManager.pushMatrix();

                if (k > 0)
                {
                    float f8 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.15F * 0.5F;
                    float f10 = (this.random.nextFloat() * 2.0F - 1.0F) * 0.15F * 0.5F;
                    GlStateManager.translate(f8, f10, 0.0F);
                }

                ibakedmodel = net.minecraftforge.client.ForgeHooksClient.handleCameraTransforms(ibakedmodel, ItemCameraTransforms.TransformType.GROUND, false);
                Minecraft.getMinecraft().getRenderItem().renderItem(new ItemStack(Items.APPLE), ibakedmodel);
                GlStateManager.popMatrix();
                GlStateManager.translate(0.0F, 0.0F, 0.09375F);
            }
        }
        
        GlStateManager.popMatrix();
        GlStateManager.disableRescaleNormal();
        GlStateManager.disableBlend();
        this.bindEntityTexture(item);

        if (flag)
        {
           Minecraft.getMinecraft().renderEngine.getTexture(this.getEntityTexture(item)).restoreLastBlurMipmap();
        }
   }
   
   protected boolean bindEntityTexture(EntityItem entity)
    {
        ResourceLocation resourcelocation = this.getEntityTexture(entity);

        if (resourcelocation == null)
        {
            return false;
        }
        else
        {
            this.bindTexture(resourcelocation);
            return true;
        }
    }
   
   protected ResourceLocation getEntityTexture(EntityItem entity)
    {
        return TextureMap.LOCATION_BLOCKS_TEXTURE;
    }
   
   private int transformModelCount(EntityItem itemIn, double p_177077_2_, double p_177077_4_, double p_177077_6_, float p_177077_8_, IBakedModel p_177077_9_)
    {
        ItemStack itemstack = itemIn.getEntityItem();
        Item item = itemstack.getItem();

        if (item == null)
        {
            return 0;
        }
        else
        {
            boolean flag = p_177077_9_.isGui3d();
            int i = 1;
            float f = 0.25F;
            float f1 = shouldBob() ? MathHelper.sin(((float)itemIn.getAge() + p_177077_8_) / 10.0F + itemIn.hoverStart) * 0.1F + 0.1F : 0;
            float f2 = p_177077_9_.getItemCameraTransforms().getTransform(ItemCameraTransforms.TransformType.GROUND).scale.y;
            GlStateManager.translate((float)p_177077_2_, (float)p_177077_4_ + f1 + 0.25F * f2, (float)p_177077_6_);

            if (flag || Minecraft.getMinecraft().getRenderManager().options != null)
            {
                float f3 = (((float)itemIn.getAge() + p_177077_8_) / 20.0F + itemIn.hoverStart) * (180F / (float)Math.PI);
                GlStateManager.rotate(f3, 0.0F, 1.0F, 0.0F);
            }

            GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
            return i;
        }
    }
   
    public boolean shouldSpreadItems()
    {
        return true;
    }

    public boolean shouldBob()
    {
        return true;
    }
   
}

 

 

Even if the apple is dark, we can see that the texture is applied. Also, I can't show you with a picture but the apple is shaking a bit. It looks like it's trying to rotate but due to the fact that the function is called every tick, the position is reset. I should be able to fix this by myself but I'm going to need help to fix the color of the apple as I don't even know where to look.

Posted

Ok, so I tried to look into the RenderEntityItem to see how they animate the entity but I couldn't find anything about the animation. Now, my item is rendering in the block but the problem is that it's shacking. It looks like the item is trying to animate but the position is reset every tick so I guess the animation is achieved by modifying the x y z but I couldn't find where the doRender function is called. Any ideas?

 

 

My code:

 

private EntityItem item;
   private final Random random = new Random();


   public BlockShowcaseTileEntitySpecialRenderer() {
      item = new EntityItem(Minecraft.getMinecraft().theWorld, 0, 0, 0, new ItemStack(Items.BAKED_POTATO));
   }


   @Override
   public void renderTileEntityAt(TileEntity te, double x, double y, double z, float partialTicks, int destroyStage) {
      ItemStack itemstack = new ItemStack(Items.BAKED_POTATO);
      x += 0.5;
      y += 0.0;
      z += 0.5;
      
      int i;


        if (itemstack != null && itemstack.getItem() != null)
        {
            i = Item.getIdFromItem(itemstack.getItem()) + itemstack.getMetadata();
        }
        else
        {
            i = 187;
        }


        this.random.setSeed((long)i);


      boolean flag = false;
      if (this.bindEntityTexture(item)) {
         Minecraft.getMinecraft().getRenderManager().renderEngine.getTexture(this.getEntityTexture(item)).setBlurMipmap(false, false);
         flag = true;
      }
      GlStateManager.enableRescaleNormal();
      GlStateManager.alphaFunc(516, 0.1F);
      GlStateManager.enableBlend();
      RenderHelper.enableStandardItemLighting();
      GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA,GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE,GlStateManager.DestFactor.ZERO);
      GlStateManager.pushMatrix();
      IBakedModel ibakedmodel = Minecraft.getMinecraft().getRenderItem().getItemModelWithOverrides(new ItemStack(Items.BAKED_POTATO), te.getWorld(), (EntityLivingBase) null);
      int j = this.transformModelCount(item, x, y, z, partialTicks, ibakedmodel);


      boolean flag1 = ibakedmodel.isGui3d();


      
      if (!flag1) 
      { 
         float f3 = -0.0F * (float)(j - 1) * 0.5F; float f4 = -0.0F * (float)(j - 1) * 0.5F; float f5 = -0.09375F * (float)(j - 1) * 0.5F; 
         GlStateManager.translate(f3, f4, f5); 
      }
       


      if (flag1) 
      {
         GlStateManager.pushMatrix();


         ibakedmodel = net.minecraftforge.client.ForgeHooksClient.handleCameraTransforms(ibakedmodel,ItemCameraTransforms.TransformType.GROUND, false);
         Minecraft.getMinecraft().getRenderItem().renderItem(new ItemStack(Items.BAKED_POTATO), ibakedmodel);
         GlStateManager.popMatrix();
      } 
      else 
      {
         GlStateManager.pushMatrix();


         ibakedmodel = net.minecraftforge.client.ForgeHooksClient.handleCameraTransforms(ibakedmodel,ItemCameraTransforms.TransformType.GROUND, false);
         Minecraft.getMinecraft().getRenderItem().renderItem(new ItemStack(Items.BAKED_POTATO), ibakedmodel);
         GlStateManager.popMatrix();
         GlStateManager.translate(0.0F, 0.0F, 0.09375F);
      }


      GlStateManager.popMatrix();
      GlStateManager.disableRescaleNormal();
      GlStateManager.disableBlend();
      this.bindEntityTexture(item);


      if (flag) {
         Minecraft.getMinecraft().renderEngine.getTexture(this.getEntityTexture(item)).restoreLastBlurMipmap();
      }
   }


   protected boolean bindEntityTexture(EntityItem entity) {
      ResourceLocation resourcelocation = this.getEntityTexture(entity);


      if (resourcelocation == null) {
         return false;
      } else {
         this.bindTexture(resourcelocation);
         return true;
      }
   }


   protected ResourceLocation getEntityTexture(EntityItem entity) {
      return TextureMap.LOCATION_BLOCKS_TEXTURE;
   }


   private int transformModelCount(EntityItem itemIn, double p_177077_2_, double p_177077_4_, double p_177077_6_, float p_177077_8_, IBakedModel p_177077_9_) {
      ItemStack itemstack = itemIn.getEntityItem();
      Item item = itemstack.getItem();


      if (item == null) {
         return 0;
      } else {
         boolean flag = p_177077_9_.isGui3d();
         int i = 1;
         float f = 0.25F;
         float f1 = shouldBob() ? MathHelper.sin(((float) itemIn.getAge() + p_177077_8_) / 10.0F + itemIn.hoverStart) * 0.1F + 0.1F : 0;
         float f2 = p_177077_9_.getItemCameraTransforms().getTransform(ItemCameraTransforms.TransformType.GROUND).scale.y;
         GlStateManager.translate((float) p_177077_2_, (float) p_177077_4_ + f1 + 0.25F * f2, (float) p_177077_6_);


         if (flag || Minecraft.getMinecraft().getRenderManager().options != null) {
            float f3 = (((float) itemIn.getAge() + p_177077_8_) / 20.0F + itemIn.hoverStart) * (180F / (float) Math.PI);
            GlStateManager.rotate(f3, 0.0F, 1.0F, 0.0F);
         }


         GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
         return i;
      }
   }


   public boolean shouldSpreadItems() {
      return true;
   }


   public boolean shouldBob() {
      return true;
   }

 

 

 

What it looks like:

Posted

What are you trying to animate exactly the rotation or the up and down motion. Because the rotation is messing with the yaw/pitch, and the up and down can be handled using the motionY. And don't set the position every tick when you create it is when you should set it.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted

I'm trying to make the same animation as a dropped item, I used the exact same code as in the RenderEntityItem but the item is not spinning up and down, it's shacking like I showed you in the video. I'm trying to find a way to fix this.

Posted

The render code doesn't handle the yaw/pitch changes or the motion changes it grabs those from the EntityItem. Create the EntityItem in your TileEntity and call EntityItem.update in your TE's update method.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted

So I tried to copy the update method of the EntityItem class and modify it to adapt it to my needs. I also tried to only set the position once but it didn't work, the item is following me and I don't even know why it does. I don't understand why the item is attached to the player but whatever. Also, I don't know if it's related but I can't take screenshots anymore, I'm getting an error:

 

[20:31:54] [Client thread/ERROR]: ########## GL ERROR ##########
[20:31:54] [Client thread/ERROR]: @ Pre render
[20:31:54] [Client thread/ERROR]: 1282: Invalid operation

 

My code:

 

private EntityItem item;
   private final Random random = new Random();
   private boolean first = true;


   public BlockShowcaseTileEntitySpecialRenderer() {
      item = new EntityItem(Minecraft.getMinecraft().theWorld, 0, 0, 0, new ItemStack(Items.BAKED_POTATO));
   }


   public void update()
   {
        if (item.getEntityItem() == null)
        {
            item.setDead();
        }
        else
        {
            item.prevPosX = item.posX;
            item.prevPosY = item.posY;
            item.prevPosZ = item.posZ;


            if (!item.hasNoGravity())
            {
               item.motionY -= 0.03999999910593033D;
            }


            float f = 0.98F;


            if (item.onGround)
            {
                f = item.worldObj.getBlockState(new BlockPos(MathHelper.floor_double(item.posX), MathHelper.floor_double(item.getEntityBoundingBox().minY) - 1, MathHelper.floor_double(item.posZ))).getBlock().slipperiness * 0.98F;
            }


            item.motionX *= (double)f;
            item.motionY *= 0.9800000190734863D;
            item.motionZ *= (double)f;


            if (item.onGround)
            {
               item.motionY *= -0.5D;
            }
        }
   }
   @Override
   public void renderTileEntityAt(TileEntity te, double x, double y, double z, float partialTicks, int destroyStage) {
      ItemStack itemstack = new ItemStack(Items.BAKED_POTATO);
      if(first)
      {
         item.setPosition(x, y, z);
         first = false;
      }
      x = item.posX;
      y = item.posY;
      z = item.posZ;
      z += 0.5;
      y += 0.0;
      z += 0.5;
      int i;


        if (itemstack != null && itemstack.getItem() != null)
        {
            i = Item.getIdFromItem(itemstack.getItem()) + itemstack.getMetadata();
        }
        else
        {
            i = 187;
        }


        this.random.setSeed((long)i);


      boolean flag = false;
      if (this.bindEntityTexture(item)) {
         Minecraft.getMinecraft().getRenderManager().renderEngine.getTexture(this.getEntityTexture(item)).setBlurMipmap(false, false);
         flag = true;
      }
      GlStateManager.enableRescaleNormal();
      GlStateManager.alphaFunc(516, 0.1F);
      GlStateManager.enableBlend();
      RenderHelper.enableStandardItemLighting();
      GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA,GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE,GlStateManager.DestFactor.ZERO);
      GlStateManager.pushMatrix();
      IBakedModel ibakedmodel = Minecraft.getMinecraft().getRenderItem().getItemModelWithOverrides(new ItemStack(Items.BAKED_POTATO), te.getWorld(), (EntityLivingBase) null);
      int j = this.transformModelCount(item, x, y, z, partialTicks, ibakedmodel);


      boolean flag1 = ibakedmodel.isGui3d();


      
      if (!flag1) 
      { 
         float f3 = -0.0F * (float)(j - 1) * 0.5F; float f4 = -0.0F * (float)(j - 1) * 0.5F; float f5 = -0.09375F * (float)(j - 1) * 0.5F; 
         GlStateManager.translate(f3, f4, f5); 
      }
       


      if (flag1) 
      {
         GlStateManager.pushMatrix();


         ibakedmodel = net.minecraftforge.client.ForgeHooksClient.handleCameraTransforms(ibakedmodel,ItemCameraTransforms.TransformType.GROUND, false);
         Minecraft.getMinecraft().getRenderItem().renderItem(new ItemStack(Items.BAKED_POTATO), ibakedmodel);
         GlStateManager.popMatrix();
      } 
      else 
      {
         GlStateManager.pushMatrix();


         ibakedmodel = net.minecraftforge.client.ForgeHooksClient.handleCameraTransforms(ibakedmodel,ItemCameraTransforms.TransformType.GROUND, false);
         Minecraft.getMinecraft().getRenderItem().renderItem(new ItemStack(Items.BAKED_POTATO), ibakedmodel);
         GlStateManager.popMatrix();
         GlStateManager.translate(0.0F, 0.0F, 0.09375F);
      }


      GlStateManager.popMatrix();
      GlStateManager.disableRescaleNormal();
      GlStateManager.disableBlend();
      this.bindEntityTexture(item);


      if (flag) {
         Minecraft.getMinecraft().renderEngine.getTexture(this.getEntityTexture(item)).restoreLastBlurMipmap();
      }
      
      this.update();
   }


   protected boolean bindEntityTexture(EntityItem entity) {
      ResourceLocation resourcelocation = this.getEntityTexture(entity);


      if (resourcelocation == null) {
         return false;
      } else {
         this.bindTexture(resourcelocation);
         return true;
      }
   }


   protected ResourceLocation getEntityTexture(EntityItem entity) {
      return TextureMap.LOCATION_BLOCKS_TEXTURE;
   }


   private int transformModelCount(EntityItem itemIn, double p_177077_2_, double p_177077_4_, double p_177077_6_, float p_177077_8_, IBakedModel p_177077_9_) {
      ItemStack itemstack = itemIn.getEntityItem();
      Item item = itemstack.getItem();


      if (item == null) {
         return 0;
      } else {
         boolean flag = p_177077_9_.isGui3d();
         int i = 1;
         float f = 0.25F;
         float f1 = shouldBob() ? MathHelper.sin(((float) itemIn.getAge() + p_177077_8_) / 10.0F + itemIn.hoverStart) * 0.1F + 0.1F : 0;
         float f2 = p_177077_9_.getItemCameraTransforms().getTransform(ItemCameraTransforms.TransformType.GROUND).scale.y;
         GlStateManager.translate((float) p_177077_2_, (float) p_177077_4_ + f1 + 0.25F * f2, (float) p_177077_6_);


         if (flag || Minecraft.getMinecraft().getRenderManager().options != null) {
            float f3 = (((float) itemIn.getAge() + p_177077_8_) / 20.0F + itemIn.hoverStart) * (180F / (float) Math.PI);
            GlStateManager.rotate(f3, 0.0F, 1.0F, 0.0F);
         }


         GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
         return i;
      }
   }


   public boolean shouldSpreadItems() {
      return true;
   }


   public boolean shouldBob() {
      return true;
   }

 

 

 

Screenshot:

484af53a84962dc122f6eb2f48cb3347.png

 

Posted

The entity item bobbing motion is handled by the entity's age.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

I did what you asked me and my EntityItem is now in my TE, but that didn't fix my problem. Also, you told me to set the position only once but I can't, that's the reason the item was following me. I found out that the xyz of renderTileEntityAt are dynamic and depends on the position of the player. The animation is not working and I honestly don't know what to do now.

 

 

TESR:

 

public class BlockShowcaseTileEntitySpecialRenderer extends TileEntitySpecialRenderer 
{
private final Random random = new Random();
private boolean first = true;


public BlockShowcaseTileEntitySpecialRenderer() {}


@Override
public void renderTileEntityAt(TileEntity te, double x, double y, double z, float partialTicks, int destroyStage) {
	EntityItem item = ((BlockShowcaseTileEntity) te).item;
	ItemStack itemstack = new ItemStack(Items.BAKED_POTATO);

	x += 0.5;
	y += 0.1;
	z += 0.5;
	int i;


        if (itemstack != null && itemstack.getItem() != null)
        {
            i = Item.getIdFromItem(itemstack.getItem()) + itemstack.getMetadata();
        }
        else
        {
            i = 187;
        }


        this.random.setSeed((long)i);


	boolean flag = false;
	if (this.bindEntityTexture(item)) {
		Minecraft.getMinecraft().getRenderManager().renderEngine.getTexture(this.getEntityTexture(item)).setBlurMipmap(false, false);
		flag = true;
	}
	GlStateManager.enableRescaleNormal();
	GlStateManager.alphaFunc(516, 0.1F);
	GlStateManager.enableBlend();
	RenderHelper.enableStandardItemLighting();
	GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA,GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE,GlStateManager.DestFactor.ZERO);
	GlStateManager.pushMatrix();
	IBakedModel ibakedmodel = Minecraft.getMinecraft().getRenderItem().getItemModelWithOverrides(new ItemStack(Items.BAKED_POTATO), te.getWorld(), (EntityLivingBase) null);
	int j = this.transformModelCount(item, x, y, z, partialTicks, ibakedmodel);


	boolean flag1 = ibakedmodel.isGui3d();



	if (!flag1) 
	{ 
		float f3 = -0.0F * (float)(j - 1) * 0.5F; float f4 = -0.0F * (float)(j - 1) * 0.5F; float f5 = -0.09375F * (float)(j - 1) * 0.5F; 
		GlStateManager.translate(f3, f4, f5); 
	}



	if (flag1) 
	{
		GlStateManager.pushMatrix();


		ibakedmodel = net.minecraftforge.client.ForgeHooksClient.handleCameraTransforms(ibakedmodel,ItemCameraTransforms.TransformType.GROUND, false);
		Minecraft.getMinecraft().getRenderItem().renderItem(new ItemStack(Items.BAKED_POTATO), ibakedmodel);
		GlStateManager.popMatrix();
	} 
	else 
	{
		GlStateManager.pushMatrix();


		ibakedmodel = net.minecraftforge.client.ForgeHooksClient.handleCameraTransforms(ibakedmodel,ItemCameraTransforms.TransformType.GROUND, false);
		Minecraft.getMinecraft().getRenderItem().renderItem(new ItemStack(Items.BAKED_POTATO), ibakedmodel);
		GlStateManager.popMatrix();
		GlStateManager.translate(0.0F, 0.0F, 0.09375F);
	}


	GlStateManager.popMatrix();
	GlStateManager.disableRescaleNormal();
	GlStateManager.disableBlend();
	this.bindEntityTexture(item);


	if (flag) {
		Minecraft.getMinecraft().renderEngine.getTexture(this.getEntityTexture(item)).restoreLastBlurMipmap();
	}
}


protected boolean bindEntityTexture(EntityItem entity) {
	ResourceLocation resourcelocation = this.getEntityTexture(entity);


	if (resourcelocation == null) {
		return false;
	} else {
		this.bindTexture(resourcelocation);
		return true;
	}
}


protected ResourceLocation getEntityTexture(EntityItem entity) {
	return TextureMap.LOCATION_BLOCKS_TEXTURE;
}


private int transformModelCount(EntityItem itemIn, double p_177077_2_, double p_177077_4_, double p_177077_6_, float p_177077_8_, IBakedModel p_177077_9_) {
	ItemStack itemstack = itemIn.getEntityItem();
	Item item = itemstack.getItem();


	if (item == null) {
		return 0;
	} else {
		boolean flag = p_177077_9_.isGui3d();
		int i = 1;
		float f = 0.25F;
		float f1 = shouldBob() ? MathHelper.sin(((float) itemIn.getAge() + p_177077_8_) / 10.0F + itemIn.hoverStart) * 0.1F + 0.1F : 0;
		float f2 = p_177077_9_.getItemCameraTransforms().getTransform(ItemCameraTransforms.TransformType.GROUND).scale.y;
		GlStateManager.translate((float) p_177077_2_, (float) p_177077_4_ + f1 + 0.25F * f2, (float) p_177077_6_);


		if (flag || Minecraft.getMinecraft().getRenderManager().options != null) {
			float f3 = (((float) itemIn.getAge() + p_177077_8_) / 20.0F + itemIn.hoverStart) * (180F / (float) Math.PI);
			GlStateManager.rotate(f3, 0.0F, 1.0F, 0.0F);
		}


		GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
		return i;
	}
}


public boolean shouldSpreadItems() {
	return true;
}


public boolean shouldBob() {
	return true;
}


}

 

 

 

Tile Entity:

public class BlockShowcaseTileEntity extends TileEntity implements ITickable
{
public EntityItem item;

public BlockShowcaseTileEntity()
{
	item = new EntityItem(Minecraft.getMinecraft().theWorld, this.pos.getX(), this.pos.getY(), this.pos.getZ(), new ItemStack(Items.BAKED_POTATO));
}

@Override
public void update() 
{
	if (item.getEntityItem() == null)
        {
            item.setDead();
        }
        else
        {
            item.prevPosX = item.posX;
            item.prevPosY = item.posY;
            item.prevPosZ = item.posZ;


            if (!item.hasNoGravity())
            {
            	item.motionY -= 0.03999999910593033D;
            }


            float f = 0.98F;


            if (item.onGround)
            {
                f = item.worldObj.getBlockState(new BlockPos(MathHelper.floor_double(item.posX), MathHelper.floor_double(item.getEntityBoundingBox().minY) - 1, MathHelper.floor_double(item.posZ))).getBlock().slipperiness * 0.98F;
            }


            item.motionX *= (double)f;
            item.motionY *= 0.9800000190734863D;
            item.motionZ *= (double)f;


            if (item.onGround)
            {
            	item.motionY *= -0.5D;
            }
        }
}
}

 

EDIT: Thanks to everyone, I finally found out why the item wasn't moving: the render uses the age of the item to animate it but the age of my item wasn't updating so I just created a int and I add 1 every tick.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • My apologies, it's a Postscript. I was able to play for an extended period of time right after generating the world without any problems. If I close it and reopen it, I get that message at random. Once it appears, I have to modify the Level.dat to open it.
    • Share logs/errors, and someone may know how to help. Make sure to read the FAQ on sharing logs.
    • Hello.  regarding Invalid player data.  First of all, my English is not good, so there might be mistakes. I am using Minecraft 1.20.1 forge 47.3.22 CurseForge and have over 250 mods in my modpack. Single-player. I can play the game after generating the world (about 5 hours) and restarting it, but there is no set timing and one day it suddenly shows ''Invalid player data''. Restarted the game several times after that, but the same message appears. Fix the level.dat file and play for a few hours, but the next day when I try to open the world I get the ''Invalid player data'' message again. Can open other worlds, but after some progress in the other worlds, the same message appears and I can't start them. Is there something wrong with the mod configuration? I would be very grateful if you could tell me how to solve this problem. ◉ErrorCode https://mclo.gs/4gcfPbY   ◉ModList AdvancementPlaques-forge-1.6.9.jar AI-Improvements-1.20-0.5.2.jar alexsmobs-1.22.9.jar alternate_current-mc1.20-1.7.0.jar AmbientSounds_FORGE_v6.1.6_mc1.20.1.jar amendments-1.20-1.2.18.jar Apotheosis-1.20.1-7.4.6.jar ApothicAttributes-1.20.1-1.3.7.jar appleskin-forge-mc1.20.1-2.5.1.jar aquamirae-6.API15.jar architectury-9.2.14-forge.jar ars_elemental-1.20.1-0.6.7.7.jar ars_extended_glyphs-1.20.1-1.9.jar ars_nouveau-1.20.1-4.12.6-all.jar AttributeFix-Forge-1.20.1-21.0.4.jar azurelib-neo-1.20.1-2.0.41.jar BadOptimizations-2.2.1-1.20.1.jar balm-forge-1.20.1-7.3.16-all.jar barbequesdelight-1.0.5.jar BattleArts-20.9.7.1.jar BattleArtsAPI-20.9.5.3.jar BEB-Forge-1.20.1-2.0.0.jar bendy-lib-forge-4.0.0.jar betterendcities-1.0.0-1.20.1.jar betterfpsdist-1.20.1-6.0.jar BetterThirdPerson-Forge-1.20-1.9.0.jar bettervillage-forge-1.20.1-3.2.0.jar biggerendcities-1.20.1-1.0.0.jar blockui-1.20.1-1.0.156-RELEASE.jar blueprint-1.20.1-7.1.1.jar blur-forge-3.1.1.jar BOMD-Forge-1.20.1-1.1.1.jar Bookshelf-Forge-1.20.1-20.2.13.jar BrewinAndChewin-1.20.1-3.1.2.jar BridgingMod-2.5.1+1.20.1.forge-release.jar caelus-forge-3.2.0+1.20.1.jar CarbonConfig-1.20-1.2.6.jar Cardiac-FORGE-0.5.3.2+1.20.1.jar carryon-forge-1.20.1-2.1.2.7.jar casualness_delight-1.20.1-0.4n.jar CerbonsApi-Forge-1.20.1-1.0.0.jar chat_heads-0.13.13-forge-1.20.jar cherishedworlds-forge-6.1.7+1.20.1.jar ChoiceTheorem's Overhauled Village-3.4.11.jar Chunk-Pregenerator-1.20-4.4.4.jar citadel-2.6.1-1.20.1.jar clean_tooltips-1.0-forge-1.20.1.jar cloth-config-11.1.136-forge.jar Clumps-forge-1.20.1-12.0.0.4.jar cobweb-forge-1.20.1-1.0.1.jar CocoaInput-1.20.5-fabric-4.4.1-EXPERIMENTAL.jar collective-1.20.1-7.91.jar cosmeticarmorreworked-1.20.1-v1a.jar create-1.20.1-0.5.1.j.jar create_easy_structures-0.1.2-forge-1.20.1.jar CreativeCore_FORGE_v2.12.31_mc1.20.1.jar creeperoverhaul-3.0.2-forge.jar cristellib-1.1.6-forge.jar cuisinedelight-1.1.16.jar cupboard-1.20.1-2.7.jar curios-forge-5.11.1+1.20.1.jar CutAllSMP_v2.5.2.jar default_skill_trees-1.1.jar DisenchantmentEditTable-1.20-1.1.2.jar DistantHorizons-2.2.1-a-1.20.1-forge-fabric.jar domesticationinnovation-1.7.1-1.20.1.jar domum_ornamentum-1.20.1-1.0.186-RELEASE-universal.jar dragonitegear-0.3.2.jar Dungeon Crawl-1.20.1-2.3.15.jar dungeons-and-taverns-ancient-city-overhaul-1 [Forge].jar DungeonsArise-1.20.x-2.1.58-release.jar dungeons_enhanced-1.20.1-5.3.0.jar dungeons_plus-1.20.1-1.5.0.jar ec_isasb_plugin-1.20.1-1.0.0-all.jar efiscompat-2.2.4.jar EFMCompat 20.2.0.1.jar embeddium-0.3.31+mc1.20.1.jar EnchantmentDescriptions-Forge-1.20.1-17.1.19.jar endermanoverhaul-forge-1.20.1-1.0.4.jar EnderWyrmlings-1.0.0-forge-1.20.1.jar endrem_forge-5.3.3-R-1.20.1.jar enhanced_boss_bars-1.20.1-1.0.0.jar entityculling-forge-1.7.2-mc1.20.1.jar entity_model_features_forge_1.20.1-2.4.1.jar entity_texture_features_forge_1.20.1-6.2.9.jar Epic-Knights-9.21.jar Epic-Knights-Addon-1.22.jar Epic-Knights-Slavic-Armory-1.5.jar epicfight-forge-20.9.7-1.20.1.jar essential_1-3-5-7_forge_1-20-1.jar ExCap-20.9.7.3.jar exoticbirds-1.20.1-1.0.0.jar expanded_combat-1.20.1-3.2.4-all.jar Explorify v1.6.2 f10-48.jar extrasounds-1.20.1-forge-1.3.jar falchionmoveset-20.8.2.jar Fallingleaves-1.20.1-2.1.0.jar FarmersDelight-1.20.1-1.2.7.jar farsight-1.20.1-3.7.jar FastFurnace-1.20.1-8.0.2.jar FastSuite-1.20.1-5.0.1.jar FastWorkbench-1.20.1-8.0.4.jar ferritecore-6.0.1-forge.jar forge-medievalend-1.0.1.jar framework-forge-1.20.1-0.7.12.jar frozen_zombie_castle-1.4.0-forge-1.20.1.jar fzzy_config-0.6.4+1.20.1+forge.jar geckolib-forge-1.20.1-4.7.jar globalxp-forge-1.20.1-1.12.jar goblintraders-forge-1.20.1-1.9.3.jar gravestone-forge-1.20.1-1.0.24.jar guardvillagers-1.20.1-1.6.10.jar harvest-with-ease-forge-1.20.1-9.4.0.jar Highlighter-1.20.1-forge-1.1.9.jar hole_filler_mod-1.2.8_mc-1.20.1_forge.jar Iceberg-1.20.1-forge-1.1.25.jar ImmediatelyFast-Forge-1.3.4+1.20.4.jar ImmersiveUI-FORGE-0.3.0.jar imst-2.1.0.jar infernalmobs-1.20.1.6.jar integrated_api-1.5.1+1.20.1-forge.jar integrated_villages-1.1.5+1.20.1-forge.jar inventoryhud.forge.1.20.1-3.4.26.jar InventoryProfilesNext-forge-1.20-1.10.14.jar inventorysorter-1.20.1-23.0.8.jar InventorySpam-1.20.1-1.5.6.jar ironchest-1.20.1-14.4.4.jar irons_spellbooks-1.20.1-3.4.0.7.jar iron_repair_kits-2.4.3-forge-1.20.1.jar ItemBorders-1.20.1-forge-1.2.2.jar ItemProductionLib-1.20.1-1.0.2a-all.jar Jade-1.20.1-Forge-11.12.3.jar jei-1.20.1-forge-15.20.0.106.jar journeymap-1.20.1-5.10.3-forge.jar justhammers-forge-2.0.3+mc1.20.1.jar Kobolds-2.12.0.jar kotlinforforge-4.11.0-all.jar LegendaryTooltips-1.20.1-forge-1.4.5.jar libIPN-forge-1.20-4.0.2.jar libraryferret-forge-1.20.1-4.0.0.jar lionfishapi-2.4-Fix.jar lithostitched-forge-1.20.1-1.4.4.jar lmft-1.0.4+1.20.1-forge.jar lootbeams-1.20.1-1.2.6.jar lootintegrations-1.20.1-4.0.jar lukis-grand-capitals-1.1.1.jar L_Enders_Cataclysm-2.54- 1.20.1.jar mes-1.3.4-1.20-forge.jar mexicans_delight-1.1.1-forge-1.20.1.jar MineAllSMP_v2.6.6.jar minecolonies-1.20.1-1.1.814-snapshot.jar mna-forge-1.20.1-3.1.0.4-all.jar modernfix-forge-5.20.2+mc1.20.1.jar ModernUI-Forge-1.20.1-3.11.1.6-universal.jar modlist.txt moonlight-1.20-2.13.65-forge.jar mowziesmobs-1.7.0.jar multipiston-1.20-1.2.43-RELEASE.jar MutantMonsters-v8.0.7-1.20.1-Forge.jar mutil-1.20.1-6.1.1.jar mvs-4.1.4-1.20-forge.jar NaturesCompass-1.20.1-1.11.2-forge.jar Neat-1.20.1-41-FORGE.jar netherportalfix-forge-1.20-13.0.1.jar notenoughanimations-forge-1.9.2-mc1.20.1.jar Obscure-Tooltips-2.2.jar obscure_api-15.jar OctoLib-FORGE-0.4.2+1.20.1.jar oculus-mc1.20.1-1.8.0.jar packetfixer-forge-2.0.0-1.19-to-1.20.1.jar PackingTape-1.20.1-0.14.3.jar PassiveSkillTree-1.20.1-BETA-0.6.14a-all.jar Patchouli-1.20.1-84.1-FORGE.jar phantasm-1.0.1.jar Placebo-1.20.1-8.6.2.jar player-animation-lib-forge-1.0.2-rc1+1.20.jar polymorph-forge-0.49.8+1.20.1.jar Prism-1.20.1-forge-1.0.5.jar projectvibrantjourneys-1.20.1-6.0.5.jar puffish_attributes-0.7.2-1.20-forge.jar puffish_skills-0.14.7-1.20-forge.jar PuzzlesLib-v8.1.25-1.20.1-Forge.jar QualityCrops-1.20.1-1.3.3.jar QualitysDelight-1.20.1-1.5.3.jar Quark-4.0-460.jar QUILT-2.0.0.jar repair_amulet-2.0-forge-1.20.1.jar repurposed_structures-7.1.15+1.20.1-forge.jar resourcefulconfig-forge-1.20.1-2.1.2.jar resourcefullib-forge-1.20.1-2.1.29.jar RPG-HUD-3.10.jar rpg_companions_tiny_dragons-0.0.4-forge-1.20.1.jar run.bat samurai_dynasty-0.0.48-1.20.1-neo.jar simplyswords-forge-1.56.0-1.20.1.jar SkyVillages-1.0.4-1.19.2-1.20.1-forge-release.jar smoothboot(reloaded)-mc1.20.1-0.0.4.jar sophisticatedbackpacks-1.20.1-3.23.5.1200.jar sophisticatedcore-1.20.1-1.2.12.872.jar sound-physics-remastered-forge-1.20.1-1.4.8.jar Stackable Potions-forge-1.20.1-1.0.0.jar StorageBox_v3.2.5.jar StorageDrawers-1.20.1-12.9.13.jar Structory_1.20.x_v1.3.5.jar Structory_Towers_1.20.x_v1.0.7.jar structure_gel-1.20.1-2.16.2.jar structurize-1.20.1-1.0.764-snapshot.jar SubtleEffects-forge-1.20.1-1.8.0.jar supermartijn642configlib-1.1.8-forge-mc1.20.jar supermartijn642corelib-1.1.18-forge-mc1.20.1.jar supplementaries-1.20-3.1.13.jar TaxCastlePillager+M.1.20.1+ForM.1.0.1.jar TaxTreeGiant+M.1.20.1+ForM.1.1.0.jar TerraBlender-forge-1.20.1-3.0.1.7.jar Terralith_1.20.x_v2.5.4.jar tetra-1.20.1-6.8.0.jar TheOuterEnd-1.0.10.jar tidal-towns-1.3.4.jar tlc_forge-1.0.3-R-1.20.X.jar toms_storage-1.20-1.7.0.jar toomanyglyphs-1.20.1-2.3.2.12345.jar totw_additions-1.3.1-1.20.x-forge.jar totw_modded-forge-1.20.1-1.0.5.jar Towns-and-Towers-1.12-Fabric+Forge.jar towntalk-1.20.1-1.1.0.jar trashcans-1.0.18b-forge-mc1.20.jar trashslot-forge-1.20-15.1.1.jar travelersbackpack-forge-1.20.1-9.1.16.jar TravelersTitles-1.20-Forge-4.0.2.jar tru.e-ending-v1.1.0c.jar uncrafter-forge-1.20.1-1.2.0.jar valarian_conquest-3.0-forge-1.20.1.jar valhelsia_core-forge-1.20.1-1.1.2.jar valhelsia_structures-forge-1.20.1-1.1.2.jar villagernames-1.20.1-8.2.jar visuality-forge-2.0.2.jar waystones-forge-1.20.1-14.1.9.jar WeaponsOfMiracles-20.1.8.5.6.jar XP From Harvest Reworked-1.20.x-1.2.4.jar YetAnotherConfigLib-3.6.2+1.20.1-forge.jar YungsApi-1.20-Forge-4.0.6.jar YungsBetterDesertTemples-1.20-Forge-3.0.3.jar YungsBetterDungeons-1.20-Forge-4.0.4.jar YungsBetterEndIsland-1.20-Forge-2.0.6.jar YungsBetterJungleTemples-1.20-Forge-2.0.5.jar YungsBetterMineshafts-1.20-Forge-4.0.4.jar YungsBetterNetherFortresses-1.20-Forge-2.0.6.jar YungsBetterOceanMonuments-1.20-Forge-3.0.4.jar YungsBetterWitchHuts-1.20-Forge-3.0.3.jar YungsBridges-1.20-Forge-4.0.3.jar YungsCaveBiomes-1.20.1-Forge-2.0.1.jar YungsExtras-1.20-Forge-4.0.3.jar Zeta-1.0-24.jar  
    • I did exactly like in the instruction , i even copied the build.gradle from alex mobs like he told in the instruction for citadel 1.7.0 and above, and i got 100 different error no matter what i changed in the build.gradle, i once managed to make a build succesfull but then the run client wasnt working I did exactly like in the instruction , i even copied the build.gradle from alex mobs like he told in the instruction for citadel 1.7.0 and above, and i got 100 different error no matter what i changed in the build.gradle, i once managed to make a build succesfull but then the run client wasnt working
    • Please share a link to your crash report on https://paste.ee, as explained in the FAQ
  • Topics

  • Who's Online (See full list)

    • There are no registered users currently online
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.