January 31, 20205 yr Author 22 hours ago, diesieben07 said: Pass null to the constuctor and overide getType to use a supplier instead of the typeIn field. I missed this one, but thanks. New in Modding? == Still learning!
February 1, 20205 yr 23 hours ago, DragonITA said: Does the first parameter, the entity parameter, have to be or all three parameters? You should pass in null as the entity type as you’re going to override the getType method to return your one 23 hours ago, DragonITA said: I still have not understood how to override the function. Just override “getType” like any other method. You can use an anonymous subclass if you want. The only issue that I’ve found with this is that the spawn egg textures don’t get generated for your egg. I’m looking into this. Edited February 1, 20205 yr by Cadiboo About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.github.io/tutorials Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support. When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible. Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)
March 6, 20205 yr If you still have problems with your SparnEgg, try this: public class SupplierSpawnEggItem extends SpawnEggItem { private RegistryObject<?> supplier; public SupplierSpawnEggItem(EntityType<?> typeIn, RegistryObject<?> supplierIn, int primaryColorIn, int secondaryColorIn, Properties builder) { super(typeIn, primaryColorIn, secondaryColorIn, builder); supplier = supplierIn; } @Override public EntityType<?> getType(CompoundNBT p_208076_1_) { return (EntityType<?>) supplier.get(); } } This custom SpawnEgg-class works fine for me. Textures and colors work too. Edited March 6, 20205 yr by Drachenbauer
March 6, 20205 yr On 2/1/2020 at 12:15 PM, Cadiboo said: You should pass in null as the entity type as you’re going to override the getType method to return your one
March 6, 20205 yr Author @DrachenbauerYes, i tried, then compared it with Cadiboo Spawnegg and now it work fine. For these that need to make a Spawnegg with DeferredRegister just see Cadiboo github New in Modding? == Still learning!
March 6, 20205 yr Author @Drachenbauer https://github.com/Cadiboo/Example-Mod/blob/1.15.2/src/main/java/io/github/cadiboo/examplemod/item/ModdedSpawnEggItem.java. I say it just see Cadiboo Github. New in Modding? == Still learning!
March 6, 20205 yr Author And not forgot to see the ModEventSubscriber New in Modding? == Still learning!
March 6, 20205 yr i´m not sure, what the additional code in yous does... What more than placing eitities by hand in creative should it do?
March 6, 20205 yr Author @DrachenbauerOk, for placing a entity you need a spawnegg. Cadiboo has make a method to create, register and use Spawnegggs but that are registered with the deferredregister. But the Problem with the DeferredRegister is that when you are trying to place the entity then the game crash and it say you that the RegistryObject was not found (RegistryObject = Your entity). This was caused because the egg was registered before the entity, so when you use the egg you spawn null and it cause a crash. Now the other part of the code is to make that when you use the Spawnegg, that you are sure that the entity was before registered, so that when you spawn it it not cause a game crash. Edited March 6, 20205 yr by DragonITA New in Modding? == Still learning!
March 6, 20205 yr My much slimmer code, that i posted above, can do that too. Ad cadiboo´s version: is there something about using spawneggs in a redstone-dispenser? I just wonder, about this part: public static void initUnaddedEggs() { final Map<EntityType<?>, SpawnEggItem> EGGS = ObfuscationReflectionHelper.getPrivateValue(SpawnEggItem.class, null, "field_195987_b"); DefaultDispenseItemBehavior defaultDispenseItemBehavior = new DefaultDispenseItemBehavior() { public ItemStack dispenseStack(IBlockSource source, ItemStack stack) { Direction direction = source.getBlockState().get(DispenserBlock.FACING); EntityType<?> entitytype = ((SpawnEggItem) stack.getItem()).getType(stack.getTag()); entitytype.spawn(source.getWorld(), stack, null, source.getBlockPos().offset(direction), SpawnReason.DISPENSER, direction != Direction.UP, false); stack.shrink(1); return stack; } }; for (final SpawnEggItem egg : UNADDED_EGGS) { EGGS.put(egg.getType(null), egg); DispenserBlock.registerDispenseBehavior(egg, defaultDispenseItemBehavior); // ItemColors for each spawn egg don't need to be registered because this method is called before ItemColors is created } UNADDED_EGGS.clear(); } I tested to put my egg into the dispenser, but only the egg came out. But this happens with all my mod-ones, also the ones, that still are registered the old way, too... Edit: Now i got the new one to work in a dispenser. Now i know, this method makes it able to spawn the entity out of the disbenser. And for the two constructors: When do you get an Entity type in a NonNullSupplier? With DeferredRegister, you put them always into a RegistryObject. And instead of using this thing called "Lazy", you also can put them into separate fields and use a boolean to choose one in the getType method. The boolean is set to true in one constructor and false in the other. Another question: Why do the creators of minecraft never change the order of register entity and item? Edit: Now i modifyed the constructors a bit: I removed the EntityType parameters from the constructor-headers and pass directly "null" to the superconstructor. So i could remove the "null" from my registry lines for the eggs. Edited March 7, 20205 yr by Drachenbauer
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.