Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.15.2] Entity model renders as Pig


Tessa
 Share

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

6 minutes ago, Tessa said:

I don't NEED to switch to the deferred registry method, right?  

You do not need to, no. But you cannot  create registry entries in static initializers. Either use DeferredRegister or create your entries in the proper registry events.

 

4 minutes ago, Tessa said:

@SuppressWarnings("unchecked")

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

 

5 minutes ago, Tessa said:

registerEntityWorldSpawn

You are calling this method in the completely wrong place. The correct way would be FMLCommonSetupEvent and using DeferredWorkQueue.

 

7 minutes ago, Tessa said:

registerEntityRenders

Where is this called?

 

Also show your entity classes.

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

2 hours ago, Tessa said:

But if I make the initializers non static I have to make the functions using them non static which means I cannot call stuff like the registerEntityRenderers function, right?

The registry entries must be created in the appropriate registry event.

Ideally you'd use DeferredRegister.

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

I cloned your repository.

First of all the current code crashes, because you are trying to register spawning for null entity types. You are trying to use @ObjectHolder fields before they are initialized.

 

So I commented all that out. Your spawn eggs do not work, because you create all of them with a null entity type (item registry event fires before entity type registry event).

Using /summon worked fine though and your entity renders:

image.png.cee206c3bc79a1cf888504284eb74c36.png

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.

Guest
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.

 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.