Posted October 12, 20214 yr Whenever I installed my very first 1.17 mod. The spawning of the entity as well as it's spawn egg didn't show up. Here's the code to explain why: package com.gohkenytp.coyote.common.items; import java.util.*; import net.minecraft.world.level.block.DispenserBlock; import net.minecraft.core.dispenser.DefaultDispenseItemBehavior; import net.minecraft.core.BlockSource; import net.minecraft.world.entity.MobSpawnType; import net.minecraft.nbt.CompoundTag; import net.minecraft.core.Direction; import net.minecraftforge.common.util.Lazy; import net.minecraftforge.common.util.NonNullSupplier; import net.minecraft.world.entity.EntityType; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.SpawnEggItem; import net.minecraftforge.fml.util.ObfuscationReflectionHelper; import net.minecraftforge.fmllegacy.RegistryObject; public class CoyoteEgg extends SpawnEggItem { protected static final List<CoyoteEgg> UNADDED_EGGS = new ArrayList<CoyoteEgg>(); private final Lazy<? extends EntityType<?>> entityTypeSupplier; public CoyoteEgg(final NonNullSupplier<? extends EntityType<?>> entityTypeSupplier, final int primaryColour, final int secondaryColour, final Item.Properties properties) { super(null, primaryColour, secondaryColour, properties); this.entityTypeSupplier = Lazy.of(entityTypeSupplier::get); UNADDED_EGGS.add(this); } public CoyoteEgg(final RegistryObject<? extends EntityType<?>> entityTypeSupplier, final int primaryColour, final int secondaryColour, final Item.Properties properties) { super(null, primaryColour, secondaryColour, properties); this.entityTypeSupplier = Lazy.of(entityTypeSupplier::get); UNADDED_EGGS.add(this); } public static void regSpawnEggs() { final Map<EntityType<?>, SpawnEggItem> EGGS = ObfuscationReflectionHelper.getPrivateValue(SpawnEggItem.class, null, "field_195987_b"); DefaultDispenseItemBehavior dispenseBehaviour = new DefaultDispenseItemBehavior() { @Override protected ItemStack execute(BlockSource source, ItemStack stack) { Direction direction = source.getBlockState().getValue(DispenserBlock.FACING); EntityType<?> type = ((SpawnEggItem) stack.getItem()).getType(stack.getTag()); type.spawn(source.getLevel(), stack, null, source.getPos().relative(direction), MobSpawnType.DISPENSER, direction != Direction.UP, false); stack.shrink(1); return stack; } }; for (final SpawnEggItem spawnEgg : UNADDED_EGGS) { EGGS.put(spawnEgg.getType(null), spawnEgg); DispenserBlock.registerBehavior(spawnEgg, dispenseBehaviour); } UNADDED_EGGS.clear(); } @Override public EntityType<?> getType(CompoundTag nbt) { return this.entityTypeSupplier.get(); } }
October 12, 20214 yr Author I got the SpawnEgg set already and I figured it out. Until I came across this: Type parameter 'com.gohkenytp.coyote.common.entities.CoyoteEntity' is not within its bound; should extend 'net.minecraft.world.entity.animal.Wolf' I need help with this immediately!
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.