Jump to content

[Unsolved] [1.8] Can't get texture to show up for entity similar to TNTPrimed


Recommended Posts

Posted

I'm making a mod block called the "chaos block" which will explode suddenly under certain circumstances. When it's set off, it mimics the TNT block and creates an entity EntityBlockChaosPrimed which is very close to EntityTNTPrimed. It also uses its own entity render file called RenderBlockChaosPrimed which is also much like its TNT counterpart. Everything seems to be working fine except that I can't get the texture to show up. I've searched for many hours and tried different methods but so far nothing has worked. I considered making a second blockstate for BlockChaos and using that instead of netherrack in the render file but I don't know how to do that yet and if I can do it with a simple ResourceLocation I'd like to do that. The entity is registered and the rest of the render file works fine so I don't believe that's part of the problem.

 

Here is the relevant code:

 

EntityBlockChaosPrimed.java:

 

package com.samuel.chaosblock.entities;

 

import net.minecraft.entity.Entity;

import net.minecraft.entity.EntityLivingBase;

import net.minecraft.nbt.NBTTagCompound;

import net.minecraft.util.EnumParticleTypes;

import net.minecraft.world.World;

 

public class EntityBlockChaosPrimed extends Entity

{

    /** How long the fuse is */

    public int fuse;

    private EntityLivingBase tntPlacedBy;

 

    public EntityBlockChaosPrimed(World worldIn)

    {

        super(worldIn);

        this.preventEntitySpawning = true;

        this.setSize(0.98F, 0.98F);

    }

 

    public EntityBlockChaosPrimed(World worldIn, double posX, double posY, double posZ, EntityLivingBase elb)

    {

        this(worldIn);

        this.setPosition(posX, posY, posZ);

        float var9 = (float)(Math.random() * Math.PI * 2.0D);

        //this.motionX = (double)(-((float)Math.sin((double)var9)) * 0.02F);

        this.motionY = 0.20000000298023224D;

        //this.motionZ = (double)(-((float)Math.cos((double)var9)) * 0.02F);

        this.fuse = 20;

        //this.prevPosX = posX;

        this.prevPosY = posY;

        //this.prevPosZ = posZ;

        this.tntPlacedBy = elb;

    }

 

    protected void entityInit() {}

 

    /**

    * returns if this entity triggers Block.onEntityWalking on the blocks they walk on. used for spiders and wolves to

    * prevent them from trampling crops

    */

    protected boolean canTriggerWalking()

    {

        return false;

    }

 

    /**

    * Returns true if other Entities should be prevented from moving through this Entity.

    */

    public boolean canBeCollidedWith()

    {

        return !this.isDead;

    }

 

    /**

    * Called to update the entity's position/logic.

    */

    public void onUpdate()

    {

        //this.prevPosX = this.posX;

        this.prevPosY = this.posY;

        //this.prevPosZ = this.posZ;

        this.motionY -= 0.03999999910593033D;

        //this.moveEntity(this.motionX, this.motionY, this.motionZ);

        //this.motionX *= 0.9800000190734863D;

        this.motionY *= 0.9800000190734863D;

        //this.motionZ *= 0.9800000190734863D;

 

        if (this.onGround)

        {

            //this.motionX *= 0.699999988079071D;

            //this.motionZ *= 0.699999988079071D;

            this.motionY *= -0.5D;

        }

 

        if (this.fuse-- <= 0)

        {

            this.setDead();

 

            this.explode();

        }

        else

        {

            this.handleWaterMovement();

            this.worldObj.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, this.posX, this.posY + 0.5D, this.posZ, 0.0D, 0.0D, 0.0D, new int[0]);

        }

    }

 

    private void explode()

    {

        float var1 = 4.0F;

        this.worldObj.createExplosion(this, this.posX, this.posY + (double)(this.height / 2.0F), this.posZ, var1, true);

    }

 

    /**

    * (abstract) Protected helper method to write subclass entity data to NBT.

    */

    protected void writeEntityToNBT(NBTTagCompound tagCompound)

    {

        tagCompound.setByte("Fuse", (byte)this.fuse);

    }

 

    /**

    * (abstract) Protected helper method to read subclass entity data from NBT.

    */

    protected void readEntityFromNBT(NBTTagCompound tagCompund)

    {

        this.fuse = tagCompund.getByte("Fuse");

    }

 

    /**

    * returns null or the entityliving it was placed or ignited by

    */

    public EntityLivingBase getTntPlacedBy()

    {

        return this.tntPlacedBy;

    }

 

    public float getEyeHeight()

    {

        return 0.0F;

    }

}

 

 

RenderBlockChaosPrimed.java:

 

package com.samuel.chaosblock.client.render.entities;

 

import com.samuel.chaosblock.BlockChaos;

import com.samuel.chaosblock.ChaosBlock;

import com.samuel.chaosblock.entities.EntityBlockChaosPrimed;

 

import net.minecraft.client.Minecraft;

import net.minecraft.client.renderer.BlockRendererDispatcher;

import net.minecraft.client.renderer.GlStateManager;

import net.minecraft.client.renderer.entity.Render;

import net.minecraft.client.renderer.entity.RenderManager;

import net.minecraft.client.renderer.texture.TextureMap;

import net.minecraft.entity.Entity;

import net.minecraft.init.Blocks;

import net.minecraft.util.MathHelper;

import net.minecraft.util.ResourceLocation;

 

public class RenderBlockChaosPrimed extends Render {

 

    private static final ResourceLocation Texture = new ResourceLocation("chaosblock:textures/entities/chaos_block_primed.png");

 

    public RenderBlockChaosPrimed(RenderManager p_i46134_1_)

    {

        super(p_i46134_1_);

        this.shadowSize = 0.5F;

    }

 

    /**

    * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then

    * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic

    * (Render<T extends Entity) and this method has signature public void doRender(T entity, double d, double d1,

    * double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that.

    */

    public void doRender(EntityBlockChaosPrimed entity, double p_76986_2_, double p_76986_4_, double p_76986_6_, float p_76986_8_, float p_76986_9_)

    {

        BlockRendererDispatcher var10 = Minecraft.getMinecraft().getBlockRendererDispatcher();

        GlStateManager.pushMatrix();

        GlStateManager.translate((float)p_76986_2_, (float)p_76986_4_ + 0.5F, (float)p_76986_6_);

        float var11;

 

        if ((float)entity.fuse - p_76986_9_ + 1.0F < 10.0F)

        {

            var11 = 1.0F - ((float)entity.fuse - p_76986_9_ + 1.0F) / 10.0F;

            var11 = MathHelper.clamp_float(var11, 0.0F, 1.0F);

            var11 *= var11;

            var11 *= var11;

            float var12 = 1.0F + var11 * 0.3F;

            GlStateManager.scale(var12, var12, var12);

        }

 

        var11 = (1.0F - ((float)entity.fuse - p_76986_9_ + 1.0F) / 100.0F) * 0.8F;

        this.bindEntityTexture(entity);

        GlStateManager.translate(-0.5F, -0.5F, 0.5F);

        var10.renderBlockBrightness(Blocks.netherrack.getDefaultState(), entity.getBrightness(p_76986_9_));

        GlStateManager.translate(0.0F, 0.0F, 1.0F);

 

        if (entity.fuse / 5 % 2 == 0)

        {

            GlStateManager.disableTexture2D();

            GlStateManager.disableLighting();

            GlStateManager.enableBlend();

            GlStateManager.blendFunc(770, 772);

            GlStateManager.color(1.0F, 1.0F, 1.0F, var11);

            GlStateManager.doPolygonOffset(-3.0F, -3.0F);

            GlStateManager.enablePolygonOffset();

            var10.renderBlockBrightness(BlockChaos.getStateById(1), 1.0F);

            GlStateManager.doPolygonOffset(0.0F, 0.0F);

            GlStateManager.disablePolygonOffset();

            GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);

            GlStateManager.disableBlend();

            GlStateManager.enableLighting();

            GlStateManager.enableTexture2D();

        }

 

        GlStateManager.popMatrix();

        super.doRender(entity, p_76986_2_, p_76986_4_, p_76986_6_, p_76986_8_, p_76986_9_);

    }

   

    protected ResourceLocation setEntityTexture(EntityBlockChaosPrimed p_180563_1_)

    {

        return Texture;

    }

 

    /**

    * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture.

    */

    protected ResourceLocation getEntityTexture(Entity entity)

    {

        return setEntityTexture((EntityBlockChaosPrimed)entity);

    }

 

    /**

    * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then

    * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic

    * (Render<T extends Entity) and this method has signature public void doRender(T entity, double d, double d1,

    * double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that.

    */

    public void doRender(Entity p_76986_1_, double p_76986_2_, double p_76986_4_, double p_76986_6_, float p_76986_8_, float p_76986_9_)

    {

        this.doRender((EntityBlockChaosPrimed)p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_, p_76986_8_, p_76986_9_);

    }

}

 

 

The texture file is located in "assets/chaosblock/textures/entities/" and is named the same as in the render file.

 

Edit: Also, if anyone might be able to tell me how to give this block a custom explosion sound without modifying the regular explosion sound, I'd really appreciate it.

Posted

Yes, I mentioned that everything works fine except the texture so it shouldn't be that. As far as I know, entity textures can't be applied using that method anyway and have to be from a ResourceLocation in the render file.

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

    • When I first heard about Bitcoin back in 2018, I was skeptical. The idea of a decentralized, digital currency seemed too good to be true. But I was intrigued as I learned more about the technology behind it and its potential. I started small, investing just a few hundred dollars, dipping my toes into the cryptocurrency waters. At first, it was exhilarating to watch the value of my investment grow exponentially. I felt like I was part of the future, an early adopter of this revolutionary new asset. But that euphoria was short-lived. One day, I logged into my digital wallet only to find it empty - my Bitcoin had vanished without a trace. It turned out that the online exchange I had trusted had been hacked, and my funds were stolen. I was devastated, both financially and emotionally. All the potential I had seen in Bitcoin was tainted by the harsh reality that with decentralization came a lack of regulation and oversight. My hard-earned money was gone, lost to the ether of the digital world. This experience taught me a painful lesson about the price of trust in the uncharted territory of cryptocurrency. While the technology holds incredible promise, the risks can be catastrophic if you don't approach it with extreme caution. My Bitcoin investment gamble had failed, and I was left to pick up the pieces, wiser but poorer for having placed my faith in the wrong hands. My sincere appreciation goes to MUYERN TRUST HACKER. You are my hero in recovering my lost funds. Send a direct m a i l ( muyerntrusted ( @ ) mail-me ( . )c o m ) or message on whats app : + 1 ( 4-4-0 ) ( 3 -3 -5 ) ( 0-2-0-5 )
    • You could try posting a log (if there is no log at all, it may be the launcher you are using, the FAQ may have info on how to enable the log) as described in the FAQ, however this will probably need to be reported to/remedied by the mod author.
    • So me and a couple of friends are playing with a shitpost mod pack and one of the mods in the pack is corail tombstone and for some reason there is a problem with it, where on death to fire the player will get kicked out of the server and the tombstone will not spawn basically deleting an entire inventory, it doesn't matter what type of fire it is, whether it's from vanilla fire/lava, or from modded fire like ice&fire/lycanites and it's common enough to where everyone on the server has experienced at least once or twice and it doesn't give any crash log. a solution to this would be much appreciated thank you!
    • It is 1.12.2 - I have no idea if there is a 1.12 pack
  • Topics

×
×
  • Create New...

Important Information

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