Jump to content

HELP WITH THROWABLE RENDERING


nickpops98

Recommended Posts

Hi everyone,

 

I was working on two new throwable entities in forge and I am trying to use the snowball and fireball rendering but I cannot see the two entities while they are in the air. However it has nothing to do with my entities as they perform as they are supposed to on impact. (Expolosion, potion effects...) Any help on how I could fix this so the entities actually render would be great.

 

Main Class

 

 

package nickpops98.modName;
// Imports required
@Mod( modid = Reference.MOD_ID, name = Reference.MOD_NAME, version = Reference.VERSION)
public class modName {
}
@EventHandler
public void Load(FMLInitializationEvent event) {                            
// [<] Entity Settings
EntityRegistry.registerGlobalEntityID(EntityLavaball.class, "Lavaball", 4);
EntityRegistry.registerGlobalEntityID(EntityBlindshot.class, "Blindshot", 5);
                                                            
RenderingRegistry.registerEntityRenderingHandler(EntityLavaball.class, new RenderFireball(1.0F));
RenderingRegistry.registerEntityRenderingHandler(EntityBlindshot.class, new RenderSnowball(Item.enderPearl));
// [>]
}

 

 

 

Entity Lavaball

 

 

package nickpops98.modName.entity.projectile;
// Imports required
public class EntityLavaball extends EntityThrowable
{
public EntityLavaball(World par1World)
{
     super(par1World);
     this.isImmuneToFire = true;
     this.setFire(1000);
}

public EntityLavaball(World par1World, EntityLivingBase par2EntityLivingBase)
{
     super(par1World, par2EntityLivingBase);
}
public EntityLavaball(World par1World, double par2, double par4, double par6)
{
     super(par1World, par2, par4, par6);
}
/**
     * Called when this EntityThrowable hits a block or entity.
     */
protected void onImpact(MovingObjectPosition par1MovingObjectPosition)
{
     this.worldObj.newExplosion((Entity)null, this.posX, this.posY, this.posZ, 0.8F, true, true);
     this.setDead();
}
}

 

 

 

Entity Blindshot

 

 

package nickpops98.modName.entity.projectile;
// Imports requiredpublic class EntityBlindshot extends EntityThrowable
{
public EntityBlindshot(World par1World)
{
     super(par1World);
     this.isImmuneToFire = true;
     this.setFire(1000);
}

public EntityBlindshot(World par1World, EntityLivingBase par2EntityLivingBase)
{
     super(par1World, par2EntityLivingBase);
}
public EntityBlindshot(World par1World, double par2, double par4, double par6)
{
     super(par1World, par2, par4, par6);
} /**
     * Called when this EntityThrowable hits a block or entity.
     */
protected void onImpact(MovingObjectPosition par1MovingObjectPosition)
{
     if(par1MovingObjectPosition.typeOfHit == EnumMovingObjectType.ENTITY)
     ((EntityLivingBase) par1MovingObjectPosition.entityHit).addPotionEffect(new PotionEffect(Potion.blindness.id, 300, 1));
}
}

 

 

 

Thanks in advance!

Link to comment
Share on other sites

Hi

 

I don't see an obvious problem but some thoughts...

 

I've been told it's better to use EntityRegistry.registerModEntity instead of registerGlobalEntityID.  (But I doubt this is causing your rendering problem)

 

I'd suggest that you put a breakpoint into RenderManager.renderEntityWithPosYaw

 

            render = this.getEntityRenderObject(par1Entity);  // breakpoint here

            if (render != null && this.renderEngine != null)
            {

or alternatively

 

  if (par1Entity instanceof EntityLavaball) {
     System.out.println("rendering EntityLavaball"); // breakpoint here
  }
            render = this.getEntityRenderObject(par1Entity);

            if (render != null && this.renderEngine != null)
            {

 

then trace into it to see why your desired renderer isn't being retrieved.  Or alternatively, if it's being retrieved, why the render code isn't working.

 

-TGG

Link to comment
Share on other sites

Hi

 

I did as you said and I can now see that for some reason my entities are not being passed through to RenderManager.

 

I'm not sure what you mean by that.

 

do you mean that when you got to the line

            render = this.getEntityRenderObject(par1Entity);

your par1Entity is the EntityLavaball, render was set to null?

 

or do you mean that renderEntityWithPosYaw was never called for your EntityLavaball at all?

 

-TGG

 

 

 

 

 

Link to comment
Share on other sites

Hi

 

Hmmm ok

 

In RenderGlobal.renderEntities, add the following line

 

            this.theWorld.theProfiler.endStartSection("entities");

            for (i = 0; i < list.size(); ++i)
            {
                entity = (Entity)list.get(i);
                if (entity instanceof EntityLavaball) {
     System.out.println("rendering EntityLavaball"); // breakpoint here
  }

when it breaks, see if you can trace through and see why it isn't getting to

                    RenderManager.instance.renderEntity(entity, par3);

 

-TGG

 

Link to comment
Share on other sites

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

    • Hello everyone, I'm making this post to seek help for my modded block, It's a special block called FrozenBlock supposed to take the place of an old block, then after a set amount of ticks, it's supposed to revert its Block State, Entity, data... to the old block like this :  The problem I have is that the system breaks when handling multi blocks (I tried some fix but none of them worked) :  The bug I have identified is that the function "setOldBlockFields" in the item's "setFrozenBlock" function gets called once for the 1st block of multiblock getting frozen (as it should), but gets called a second time BEFORE creating the first FrozenBlock with the data of the 1st block, hence giving the same data to the two FrozenBlock :   Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=head] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@73681674 BlockEntityData : id:"minecraft:bed",x:3,y:-60,z:-6} Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=3, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=2, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} here is the code inside my custom "freeze" item :    @Override     public @NotNull InteractionResult useOn(@NotNull UseOnContext pContext) {         if (!pContext.getLevel().isClientSide() && pContext.getHand() == InteractionHand.MAIN_HAND) {             BlockPos blockPos = pContext.getClickedPos();             BlockPos secondBlockPos = getMultiblockPos(blockPos, pContext.getLevel().getBlockState(blockPos));             if (secondBlockPos != null) {                 createFrozenBlock(pContext, secondBlockPos);             }             createFrozenBlock(pContext, blockPos);             return InteractionResult.SUCCESS;         }         return super.useOn(pContext);     }     public static void createFrozenBlock(UseOnContext pContext, BlockPos blockPos) {         BlockState oldState = pContext.getLevel().getBlockState(blockPos);         BlockEntity oldBlockEntity = oldState.hasBlockEntity() ? pContext.getLevel().getBlockEntity(blockPos) : null;         CompoundTag oldBlockEntityData = oldState.hasBlockEntity() ? oldBlockEntity.serializeNBT() : null;         if (oldBlockEntity != null) {             pContext.getLevel().removeBlockEntity(blockPos);         }         BlockState FrozenBlock = setFrozenBlock(oldState, oldBlockEntity, oldBlockEntityData);         pContext.getLevel().setBlockAndUpdate(blockPos, FrozenBlock);     }     public static BlockState setFrozenBlock(BlockState blockState, @Nullable BlockEntity blockEntity, @Nullable CompoundTag blockEntityData) {         BlockState FrozenBlock = BlockRegister.FROZEN_BLOCK.get().defaultBlockState();         ((FrozenBlock) FrozenBlock.getBlock()).setOldBlockFields(blockState, blockEntity, blockEntityData);         return FrozenBlock;     }  
    • It is an issue with quark - update it to this build: https://www.curseforge.com/minecraft/mc-mods/quark/files/3642325
    • Remove Instant Massive Structures Mod from your server     Add new crash-reports with sites like https://paste.ee/  
    • Update your drivers: https://www.amd.com/en/support/graphics/amd-radeon-r9-series/amd-radeon-r9-200-series/amd-radeon-r9-280x
  • Topics

×
×
  • Create New...

Important Information

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