Jump to content

[1.10.2] PotionEffect adding model to entity ?


MCRaichu

Recommended Posts

Hi everyone,

I want to add a model I have made to entities while they are under a potioneffect. Currently I don't know where to start . Has anyone tried this before? Any tips where to start? For better understanding, I want to create a crystallization disease that creates tiny crystals on the infected entity.

 

Thanks in advance,

McRaichu

It doesn't work, I don't know why.

It works, I don't know why.

Link to comment
Share on other sites

	@SubscribeEvent
	public void onEvent(RenderLivingEvent.Post<EntityLivingBase> event)
	{
		EntityLivingBase entity = event.getEntity();
		RenderLivingBase renderer = event.getRenderer();
		ModelBase model = renderer.getMainModel();
		if(entity instanceof EntityCreeper)
		{
			ModelCreeper mr = (ModelCreeper)model;
			ModelRenderer box = new ModelRenderer(model, 0, 16);
			box.addBox(0.0F, 0.0F, 0.0F, 10, 2, 10);
			mr.body.addChild(box);
		}
	}

 

I did a small test-code. I love the idea of adding to the model because the added parts move with the entity. But the problem is, I have no idea how to set a different texture for my added parts. is it even possible?

 

 

 

It doesn't work, I don't know why.

It works, I don't know why.

Link to comment
Share on other sites

47 minutes ago, diesieben07 said:

You have to bind your texture like you normally would.

I may have to ask you to get a bit more specific. My understanding was to simply change the model and assign new texture (straight forward).

EntityLivingBase entity = event.getEntity();
RenderLivingBase renderer = event.getRenderer();
ModelBase model = renderer.getMainModel();
if(entity instanceof EntityCreeper)
{
  ModelCreeper mr = (ModelCreeper)model;

  renderer.bindTexture(new ResourceLocation(Gunny.MODID+ ":textures/items/models/vss_item.png"));

  ModelRenderer box = new ModelRenderer(model, 0, 16);
  box.addBox(0.0F, -20.0F, 0.0F, 10, 2, 10);
  mr.body.addChild(box);
}

Maybe I don't get when the event is called and what the difference of Pre and Post are in this case.

 

Edit: Currently the original creeper-texture is still used.

Edited by MCRaichu

It doesn't work, I don't know why.

It works, I don't know why.

Link to comment
Share on other sites

No, the creeper (just a placeholder in my example) should render as normal but the addition, here the "box", should render with a texture of my choice. Currently the box renders with the creeper-texture.

It doesn't work, I don't know why.

It works, I don't know why.

Link to comment
Share on other sites

okay. to answer all you questions.

1.: the code i posted is in the onEvent(RenderLivingEvent.Post<EntityLivingBase> event) function as shown in Post 4

2.: As mentioned in the first post, I want to add something to any entity that is under a potioneffect. The code I posted, with creeper and the box I add, is just for testing.

3.: Using the model makes it easier to adjust the position of what i add, but with a global model that's not possible.

 

It doesn't work, I don't know why.

It works, I don't know why.

Link to comment
Share on other sites

 

6 minutes ago, diesieben07 said:

You must add it once at startup from your client proxy,

Wouldn't that require that I know all models when my mod is loaded? That would make it incompatible with other mods (their entities), right? In your experience, what would be your approach to achieve a kind of visual feedback to differentiate between affected entities and unaffected ones. Maybe I should consider a different idea. I just don't like the particle effects of the potions, I wanted something more solid/bigger.

It doesn't work, I don't know why.

It works, I don't know why.

Link to comment
Share on other sites

Looping over all Renderes in PostInit makes sence. I don't have time until sunday to give it a try. May have more question on monday meaning I may bother you again :D. Thanks again.

It doesn't work, I don't know why.

It works, I don't know why.

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.