Posted February 17, 20196 yr Hello can anyone tell me how to put my Costom entity-class into the first "null" here: public static final Item RED_EGG = new ItemSpawnEgg(null, 14614528, 14663583, null); the two numbers are the egg-colors. Every thing i tryed to put in my entity, caused red underscores with errors.
February 17, 20196 yr The first parameter is the EntityType of the entity to spawn. As I've told you in your other thread construct it in this event using the builder, I've even shown you how to do so with an example line. The last parameter is the parameters of the item(max stack size, it's ItemGroup, container item, etc). Look at how other items are registered in the Item class.
February 17, 20196 yr Author can you give me an example for that builder-line in a method? i think, in this case, i can find a way to connect it with my entity-lines in my EnityInit-class Anf for the paremeters, i have no other items there to look at Edited February 17, 20196 yr by Drachenbauer
February 17, 20196 yr public static EntityType<EntityItem> storedItemType; @SubscribeEvent public static void onItemRegistry(RegistryEvent.Register<Item> event) { // Here for example I am creating a type for the EntityItem, you would need your own entity here with your own parameters. storedItemType = EntityType.Builder.create(EntityItem.class, EntityItem::new).tracker(32, 1, true).build("v0idstestmod.test_entity"); event.getRegistry().register(new ItemSpawnEgg(storedItemType, 0xffffff, 0x00ff00, new Item.Properties().group(ItemGroup.MISC))); // Your other registration code ... }
February 17, 20196 yr Well, you can create a helper method but in general yes, you will need an EntityType for each entity.
February 17, 20196 yr Author Thet´s ( helper method ) what i need a sample for Oh and i don´t know, what "sendvelocity" in your entity-register-line is for Edited February 17, 20196 yr by Drachenbauer
February 17, 20196 yr 6 minutes ago, Drachenbauer said: Oh and i don´t know, what "sendvelocity" in your entity-register-line is for Whether the server should send the velocity data to the client. 7 minutes ago, Drachenbauer said: Thet´s ( helper method ) what i need a sample for public static <T extends Entity>EntityType<T> registerEntityAndEgg(IForgeRegistry<Item> itemRegistry, Class<T> entityClass, Function<? super World, T> factory, int eggPrimaryColor, int eggSecondaryColor, int trackingRange, int updateFrequency, boolean sendVelocityUpdates, String name) { EntityType<T> type = EntityType.Builder.create(entityClass, factory).tracker(trackingRange, updateFrequency, sendVelocityUpdates).build(TestMod.MODID + '.' + name); itemRegistry.register(new ItemSpawnEgg(type, eggPrimaryColor, eggSecondaryColor, new Item.Properties().group(ItemGroup.MISC)).setRegistryName(name)); return type; } Or something along those lines, I am not writing code for you, this is just an example that you will need to adjust to your needs.
February 17, 20196 yr Author @SubscribeEvent public static void registerEntities(final RegistryEvent.Register<EntityType> event) { event.getRegistry().register(EntityType.Builder.create(EntityRed.class, EntityRed::new).tracker(32, 1, true).build("AngryBirdsMod.EntityRed")); LOGGER.info("Entities registered."); } What must in the place, where i have EntityType in the top line, to get a working event to register entitys Edited February 17, 20196 yr by Drachenbauer
February 17, 20196 yr 8 minutes ago, Drachenbauer said: What must in the place, where i have EntityType in blue, to get a working event to register entitys EntityType is a valid registry entry, you don't need to change it to anything. Of course it has a generic parameter you must provide, this is basic java. Since this is a forge event a wildcard type will do.
February 17, 20196 yr Author do you mean empty braces behind it? I don´t know, what exactly you mean with "provide parameter" what exactly must i add there Edited February 17, 20196 yr by Drachenbauer
February 17, 20196 yr https://en.wikipedia.org/wiki/Generics_in_Java. A type parameter is declared within the <>. Say a List<T> is a generic class where T is the type parameter. When you create a new list you specify said type parameter, like new List<String>. Now String is the type parameter, meaning that List now only accepts strings. If you want said List to accept anything you declare a wildcard as it's type parameter(new List<?>).
February 17, 20196 yr Author do you mean, i have to place a <?> behind EntityType? ok, now the red underscore is gone. Edited February 17, 20196 yr by Drachenbauer
February 17, 20196 yr Author in the item registration, where i have the thing with the eggs, it says "EntityItem" and in the entity registration i have the names of my entitys there. how do i connect my entitys with the eggs?
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.