Jump to content

[1.15.2] Entity model renders as Pig


Tessa

Recommended Posts

After updating my mod to version 1.15 and fixing almost everything, the one thing that isn't working for me are all the models of my entities.

There are 11 different models for 26 new entities. I don't NEED to switch to the deferred registry method, right?  

 

I've taken out the registry for the rest of the entities for the sake of clarity.

public class EntityList {
	
	public static EntityType<?> STUMP_ENTITY = 
	registerEntityType(StumpEntity::new, EntityClassification.CREATURE, 1f, 1.5f, "stump_entity");
	public static EntityType<?> OCTOPUS_ENTITY = 
	registerEntityType(OctopusEntity::new, EntityClassification.CREATURE, 1f, 2.5f, "octopus_entity");

   	public static <T extends Entity> EntityType<?> registerEntityType(EntityType.IFactory<T> factoryIn, EntityClassification classification, float width, float height, String name) {
		return EntityType.Builder.create(factoryIn, EntityClassification.CREATURE).size(width, height).build(TheBigBang.MODID + name).setRegistryName(TheBigBang.MODID, name);
	}
}

 

@Mod.EventBusSubscriber(modid = TheBigBang.MODID, bus = Mod.EventBusSubscriber.Bus.MOD)
@ObjectHolder(TheBigBang.MODID)
public class EntityInit {
	
	@SubscribeEvent
	public static void registerEntities(final RegistryEvent.Register<EntityType<?>> event) {
		event.getRegistry().registerAll (
			EntityList.STUMP_ENTITY,
			EntityList.OCTOPUS_ENTITY
		);
		
		registerEntityWorldSpawn(EntityList.STUMP_ENTITY, 2, 4, Biomes.FOREST);
		registerEntityWorldSpawn(EntityList.OCTOPUS_ENTITY, 2, 8, Biomes.GRAVELLY_MOUNTAINS, Biomes.STONE_SHORE);
	}
	
	@SuppressWarnings("unchecked")
	public static void registerEntityRenders() {
		RenderingRegistry.registerEntityRenderingHandler((EntityType<StumpEntity>)EntityList.STUMP_ENTITY, new StumpRenderer.RenderFactory());
		RenderingRegistry.registerEntityRenderingHandler((EntityType<OctopusEntity>)EntityList.OCTOPUS_ENTITY, new OctopusRenderer.RenderFactory());
	}
	
	@SubscribeEvent
	public static void registerEntityItems(final RegistryEvent.Register<Item> event) {
		event.getRegistry().registerAll (
			ItemList.STUMP_SPAWN_EGG = registerEntitySpawnEgg(EntityList.STUMP_ENTITY, 0x886633, 0x3e2e17, "stump_spawn_egg"),
			ItemList.OCTOPUS_SPAWN_EGG = registerEntitySpawnEgg(EntityList.OCTOPUS_ENTITY, 0x6356B5, 0xBD4E86, "octopus_spawn_egg")
		);
	}
	
	public static Item registerEntitySpawnEgg(EntityType<?> type, int color1, int color2, String name) {
		SpawnEggItem item = new SpawnEggItem(type, color1, color2, new Item.Properties().group(ItemGroup.MISC));
		item.setRegistryName(TheBigBang.MODID, name);
		return item;
	}
	
	public static void registerEntityWorldSpawn(EntityType<?> entity, int minGroupCount, int maxGroupCount, Biome... biomes) {
		for(Biome biome : biomes) {
			if(biome != null) {
				biome.getSpawns(entity.getClassification()).add(new SpawnListEntry(entity, 10, minGroupCount, maxGroupCount));
			}
		}
	}	
}

 

Link to comment
Share on other sites

9 minutes ago, diesieben07 said:

Why are you doing this instead of declaring your EntityType fields with the proper type?

Well, this way I can use the function i made called "registerEntityType", which significantly reduces the amount of typing and copy pasting I need to do.

 

9 minutes ago, diesieben07 said:

Where is this called?

In my main class

@Mod(TheBigBang.MODID)
public final class TheBigBang {
	
	public static final String MODID = "thebigbang";
	public static final Logger LOGGER = LogManager.getLogger(MODID);
	public static IProxy proxy = DistExecutor.runForDist(() -> () -> new ClientProxy(), () -> () -> new ServerProxy());
	
	public TheBigBang() 
	{
		FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
		FMLJavaModLoadingContext.get().getModEventBus().addListener(this::clientRegistries);
	}
	
	private void setup(final FMLCommonSetupEvent event)
	{
		proxy.Init();
		BigBangPacketHandler.packetHandlerInit();
	}
	
	private void clientRegistries(final FMLClientSetupEvent event)
	{
		EntityInit.registerEntityRenders();
	}
}

 

9 minutes ago, diesieben07 said:

Also show your entity classes.

Here's one of the entities

public class StumpEntity extends AnimalEntity
{
	private static final Ingredient TEMPTATION_ITEMS = Ingredient.fromItems(Items.BONE_MEAL, Items.POISONOUS_POTATO, Items.ROTTEN_FLESH);
	
	@SuppressWarnings("unchecked")
	public StumpEntity(EntityType<? extends AnimalEntity> type, World worldIn)
	{
		super((EntityType<? extends AnimalEntity>) EntityList.STUMP_ENTITY, worldIn);
	}
	
	@Override
	protected void registerGoals()
	{
	      this.goalSelector.addGoal(0, new SwimGoal(this));
	      this.goalSelector.addGoal(1, new PanicGoal(this, 0.5D));
	      this.goalSelector.addGoal(3, new BreedGoal(this, 0.4D));
	      this.goalSelector.addGoal(4, new TemptGoal(this, 0.4D, false, TEMPTATION_ITEMS));
	      this.goalSelector.addGoal(5, new FollowParentGoal(this, 0.3D));
	      this.goalSelector.addGoal(6, new WaterAvoidingRandomWalkingGoal(this, 0.3D));
	      this.goalSelector.addGoal(7, new LookAtGoal(this, PlayerEntity.class, 0.3F));
	      this.goalSelector.addGoal(8, new LookRandomlyGoal(this));
	}
	
	@Override
	protected void registerAttributes() 
	{
		super.registerAttributes();
		this.getAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(10.0d);
		this.getAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.3d);
	}

	@Override
	protected SoundEvent getHurtSound(DamageSource damageSourceIn) 
	{
		return SoundInit.STUMP_DAMAGE;
	}

	@Override
	protected SoundEvent getDeathSound() 
	{
		return SoundInit.STUMP_DIE;
	}
	
	@Override
	public StumpEntity createChild(AgeableEntity ageable) 
	{
		return (StumpEntity) EntityList.STUMP_ENTITY.create(this.world);
	}
	
	public boolean isBreedingItem(ItemStack stack) 
	{
		return TEMPTATION_ITEMS.test(stack);
	}
	
}

 

Edited by Tessa
Link to comment
Share on other sites

Sorry for the late reply, I've been trying to make it work, but neither using the proper EntityType nor creating my registries in the registry events fixes it. 
Could something be wrong with the models themselves? What causes the game to render the entity using the pig model instead of the designated one?

Link to comment
Share on other sites

Well, when I was still working in 1.14 everything worked perfectly and in that version even had some issues where entities spawned on the Client which I fixed. But if you insist, what do thing would be the best way to 100% verify they're spawned on server?

Link to comment
Share on other sites

Waaait, okay sorry for misunderstanding you. So you're saying because the entity is only spawned on the server the client doesn't know what model to use, right? Okay so yeah, the breakpoint was only reached once which was on the server, so I guess that means you were right and it isn't spawned on the client. For some reason I thought it didn't need to be spawned on clientside.

Link to comment
Share on other sites

Okay, so I think I have the initialization set up correctly now. But now when the game starts it gives me a this error for each entity type
[24Apr2020 11:14:22.209] [Render thread/WARN] [net.minecraft.entity.EntityType/]: No data fixer registered for entity thebigbangstump_entity

Link to comment
Share on other sites

Right, that wasn't what was crashing the game, there was a nullpointerexception because, like you said, the register entity spawns was being done in the wrong place.
For now i commented them out, but the entities still use pig models.

Link to comment
Share on other sites

“My entity renders as a pig” means that the outcome of the entire render is a pig. In this case something is terribly wrong (incorrect entity data, possibly caused by not sending the entity creation packet to the client properly).

Meanwhile, “my entity’s model looks like a pig” means there’s something wrong with the model. These two problems are drastically different.

 

I would recommend to elaborate on the problem in the future to prevent misunderstanding. In this case, the misunderstanding caused diesieben07 to spend a lot of time tracking down a problem that didn’t exist, which would be frustrating to anyone.

Edited by DavidM

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

Link to comment
Share on other sites

On 4/21/2020 at 11:38 AM, Tessa said:

the one thing that isn't working for me are all the models of my entities.

 

On 4/23/2020 at 11:40 AM, Tessa said:

Could something be wrong with the models themselves?

 

On 4/23/2020 at 11:40 AM, Tessa said:

What causes the game to render the entity using the pig model

 

On 4/23/2020 at 11:49 AM, Tessa said:

All of which result in them using the pig model.

 

3 hours ago, Tessa said:

For now i commented them out, but the entities still use pig models.

At this point I assumed we were on the same page, but yes, I was talking about the models. Regardless I really appreciate your help and I'm sorry for the misunderstanding.  
I guess I should've mentioned they were using the right textures...

Edited by Tessa
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

    • They were already updated, and just to double check I even did a cleanup and fresh update from that same page. I'm quite sure drivers are not the problem here. 
    • i tried downloading the drivers but it says no AMD graphics hardware has been detected    
    • Update your AMD/ATI drivers - get the drivers from their website - do not update via system  
    • As the title says i keep on crashing on forge 1.20.1 even without any mods downloaded, i have the latest drivers (nvidia) and vanilla minecraft works perfectly fine for me logs: https://pastebin.com/5UR01yG9
    • 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;     }  
  • Topics

×
×
  • Create New...

Important Information

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