Jump to content

Recommended Posts

Posted

Hello,

So I have a nuke block that's works as intended. However when i light it, the block will turn white for a quick second then disappear. Here is my code:

 

Registry in @Init method:

EntityRegistry.registerModEntity(EntityNukePrimed.class, "NukePrimed", 3, this, 350, 5, false);
	RenderingRegistry.registerEntityRenderingHandler(EntityNukePrimed.class, new RenderNukePrimed());

 

EntityNukePrimed:

package crzyguitardude.extracraft.extraores.entity;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;

public class EntityNukePrimed extends Entity
{
    /** How long the fuse is */
    public int fuse;
    private EntityLiving tntPlacedBy;
    private String texture;

    public EntityNukePrimed(World par1World)
    {
        super(par1World);
        this.fuse = 0;
        this.preventEntitySpawning = true;
        this.setSize(0.98F, 0.98F);
        this.yOffset = this.height / 2.0F;
    }

    public EntityNukePrimed(World par1World, double par2, double par4, double par6, EntityLiving par8EntityLiving)
    {
        this(par1World);
        this.setPosition(par2, par4, par6);
        float f = (float)(Math.random() * Math.PI * 2.0D);
        this.motionX = (double)(-((float)Math.sin((double)f)) * 0.02F);
        this.motionY = 0.20000000298023224D;
        this.motionZ = (double)(-((float)Math.cos((double)f)) * 0.02F);
        this.fuse = 120;
        this.prevPosX = par2;
        this.prevPosY = par4;
        this.prevPosZ = par6;
        this.tntPlacedBy = par8EntityLiving;
    }

    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();

            if (!this.worldObj.isRemote)
            {
                this.explode();
            }
        }
        else
        {
            this.worldObj.spawnParticle("smoke", this.posX, this.posY + 0.5D, this.posZ, 0.0D, 0.0D, 0.0D);
        }
    }

    private void explode()
    {
        float f = 4.0F * 4;
        this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, f, true);
    }

    /**
     * (abstract) Protected helper method to write subclass entity data to NBT.
     */
    protected void writeEntityToNBT(NBTTagCompound par1NBTTagCompound)
    {
        par1NBTTagCompound.setByte("Fuse", (byte)this.fuse);
    }

    /**
     * (abstract) Protected helper method to read subclass entity data from NBT.
     */
    protected void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)
    {
        this.fuse = par1NBTTagCompound.getByte("Fuse");
    }

    @SideOnly(Side.CLIENT)
    public float getShadowSize()
    {
        return 0.0F;
    }

    public EntityLiving func_94083_c()
    {
        return this.tntPlacedBy;
    }
    

    public String getTexture()
    {
        return "/mods/extraores/textures/blocks/block_NukeSide.png";
    }

    
}

 

RenderNukePrimed:

package crzyguitardude.extracraft.extraores.entity;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import crzyguitardude.extracraft.extraores.ExtraOres;
import crzyguitardude.extracraft.extraores.block.BlockNuke;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityTNTPrimed;
import org.lwjgl.opengl.GL11;

@SideOnly(Side.CLIENT)
public class RenderNukePrimed extends Render
{
    private RenderBlocks blockRenderer = new RenderBlocks();

    public RenderNukePrimed()
    {
        this.shadowSize = 0.5F;
    }

    public void renderPrimedTNT(EntityNukePrimed par1EntityTNTPrimed, double par2, double par4, double par6, float par8, float par9)
    {
        GL11.glPushMatrix();
        GL11.glTranslatef((float)par2, (float)par4, (float)par6);
        float f2;

        if ((float)par1EntityTNTPrimed.fuse - par9 + 1.0F < 10.0F)
        {
            f2 = 1.0F - ((float)par1EntityTNTPrimed.fuse - par9 + 1.0F) / 10.0F;

            if (f2 < 0.0F)
            {
                f2 = 0.0F;
            }

            if (f2 > 1.0F)
            {
                f2 = 1.0F;
            }

            f2 *= f2;
            f2 *= f2;
            float f3 = 1.0F + f2 * 0.3F;
            GL11.glScalef(f3, f3, f3);
        }

        f2 = (1.0F - ((float)par1EntityTNTPrimed.fuse - par9 + 1.0F) / 100.0F) * 0.8F;
        this.loadTexture("/mods/extraores/textures/blocks/block_NukeSide.png");
        this.blockRenderer.renderBlockAsItem(ExtraOres.nuke, 0, par1EntityTNTPrimed.getBrightness(par9));

        if (par1EntityTNTPrimed.fuse / 5 % 2 == 0)
        {
            GL11.glDisable(GL11.GL_TEXTURE_2D);
            GL11.glDisable(GL11.GL_LIGHTING);
            GL11.glEnable(GL11.GL_BLEND);
            GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_DST_ALPHA);
            GL11.glColor4f(1.0F, 1.0F, 1.0F, f2);
            this.blockRenderer.renderBlockAsItem(ExtraOres.nuke, 0, 1.0F);
            GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
            GL11.glDisable(GL11.GL_BLEND);
            GL11.glEnable(GL11.GL_LIGHTING);
            GL11.glEnable(GL11.GL_TEXTURE_2D);
        }

        GL11.glPopMatrix();
    }

    /**
     * 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 par1Entity, double par2, double par4, double par6, float par8, float par9)
    {
        this.renderPrimedTNT((EntityNukePrimed)par1Entity, par2, par4, par6, par8, par9);
    }
    
    protected void loadTexture(String par1Str)
    {
        this.renderManager.renderEngine.bindTexture(par1Str);
    }
}

 

Any help is appreciated.

Posted

I messed around with tweaking TNT at one point and had the same issue (using the TNT entity).  Never did figure out what was up with it, but I couldn't get my block to do what I wanted it to either, so I abandoned that project.

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
  On 4/26/2013 at 11:07 PM, Senitiel said:

Try adding this:

 

EntityRegistry.registerGlobalEntityID(EntityNukePrimed.class, "NukePrimed", ModLoader.getUniqueEntityId());

 

in clientProxy register Renders method - before calling

RenderingRegistry.registerEntityRenderingHandler(EntityNukePrimed.class, new RenderNukePrimed());

 

Helps?

 

No, thanks for help but it didn't work.

Posted

From little things: do You call

             proxy.registerRenderers();

in Your mod Load method?

 

If it's not it, i would suggest placing lots of System.out.println() in Your render methods,

to figure out what code is or isn't called, or if something, which is supposed to be non-zero and non-null is what it's supposed to be.

 

Also: You may try spawning PrimedNukes with a RightClick item, to see if Your issue is related to entity spawning,

or to Entity itself.

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

    • 39056As a committed high school teacher, I have devoted my career to imparting knowledge about business studies and entrepreneurship to my students. Over the past few years, my professional journey took an unexpected turn, leading me to embark on a thrilling yet challenging adventure. This is the story of how I established my own consulting firm, ventured into the dynamic world of cryptocurrency trading, and faced a nerve-wracking situation that nearly cost me my digital fortune.After years of teaching fundamental business principles, I felt compelled to apply my knowledge in a practical setting. This desire culminated in the launch of US Consulting, a firm aimed at providing affordable and pragmatic business advice to small and medium sized enterprises. Leveraging the skills and extensive network I had cultivated over the years, I quickly built a robust client base. To my astonishment, the firm took off faster than I had anticipated, generating significant revenue and allowing me to realize my entrepreneurial dreams.With the profits from my consulting business, I recognised a burgeoning opportunity in the rapidly evolving field of cryptocurrency. I decided to invest $100,000 in Bitcoin and $70,000 in Ethereum, driven by the potential I saw in these digital assets. I immersed myself in studying market trends and the underlying technology, and my diligence paid off. Within six months, my initial investment had more than doubled, soaring to over $200,000. The exhilaration of witnessing such rapid returns reinforced my belief in the transformative power of cryptocurrencies. This took a dramatic turn one fateful day. During a particularly lively class, a group of students decided to play a prank on me. I had left my phone in my desk drawer, but when I returned to retrieve it, I discovered it was missing. At first, I thought I had misplaced it, but soon the reality of the prank set in. Panic surged through me as I realized that my phone was my primary access point to my cryptocurrency wallets.The sense of helplessness was overwhelming. Without my phone, I could not access my digital assets, and the thought of losing control over my investments was distressing. My frustration morphed into fear as I contemplated the potential financial loss. In this moment of crisis, I remembered the recommendation of Salvage Asset Recovery, a tool that my colleague had mentioned earlier. He assured me that  Salvage Asset Recovery could help recover my digital assets, which brought me a glimmer of hope, especially since I hadn’t set up my security measures properly. Salvage Asset Recovery successfully managed to recover all my cryptocurrency, allowing me to regain control over my investments. This situation not only taught me valuable insights about security but also reinforced my commitment to guiding my students through the complexities of the business world. With the support of Salvage Asset Recovery, I emerged from this ordeal with a renewed sense of purpose, eager to share my recovery ordeal and to raise awareness for  Salvage Asset Recovery good work.   Get in touch with Salvage Asset Recovery via below CONTACT DETAILS TELEGRAM—@Salvageasset  
    • i have removed  phosphor and phosphorcrashfix and it is still crashing https://pastebin.com/ZdA1J25p
    • I have removed stevekunglib and it is still crashing again https://pastebin.com/9vE8pji0
  • Topics

×
×
  • Create New...

Important Information

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