Posted February 21, 20232 yr Hello, I am unable to register a custom TNT block I made. I am getting two errors, one in the constructor in my Primed_Dynamite class. I am unsure of what type to cast, here is the code for it: public Primed_Dynamite(Level p_32079_, double p_32080_, double p_32081_, double p_32082_, @Nullable LivingEntity p_32083_) { //this(CustomEntityType.DYNAMITE, p_32079_); this((EntityType<Primed_Dynamite>)CustomEntityType.PRIMED_DYNAMITE, p_32079_); this.setPos(p_32080_, p_32081_, p_32082_); double d0 = p_32079_.random.nextDouble() * (double)((float)Math.PI * 2F); this.setDeltaMovement(-Math.sin(d0) * 0.02D, (double)0.2F, -Math.cos(d0) * 0.02D); this.setFuse(80); this.xo = p_32080_; this.yo = p_32081_; this.zo = p_32082_; this.owner = p_32083_; } I am also clueless as to how to make a registryObject for the primed dynamite entity, with my current code I get the errors: "The method register(String, Supplier<? extends I>) in the type DeferredRegister<EntityType<?>> is not applicable for the arguments (String, () -> {})" and "The method build(null) is undefined for the type Block" public static final RegistryObject<EntityType<Primed_Dynamite>> PRIMED_DYNAMITE = ENTITY_TYPES.register("dynamite", () -> EntityType.Builder.of(Primed_Dynamite::new, ModBlocks.DYNAMITE.get().build(null))); Here is my github repositry and the specific files in question: https://github.com/John-Tsiglieris/Mod https://github.com/John-Tsiglieris/Mod/blob/main/src/main/java/block/custom/Dynamite.java https://github.com/John-Tsiglieris/Mod/blob/main/src/main/java/block/custom/Primed_Dynamite.java https://github.com/John-Tsiglieris/Mod/blob/main/src/main/java/entity/custom/CustomEntityType.java
February 21, 20232 yr 10 hours ago, Johnnycakes said: this((EntityType<Primed_Dynamite>)CustomEntityType.PRIMED_DYNAMITE, p_32079_); You shouldn't need to cast anything. Take a look at what type its asking for and what you are supplying it. 10 hours ago, Johnnycakes said: I am also clueless as to how to make a registryObject for the primed dynamite entity, with my current code I get the errors: "The method register(String, Supplier<? extends I>) in the type DeferredRegister<EntityType<?>> is not applicable for the arguments (String, () -> {})" and "The method build(null) is undefined for the type Block" Makes sense, EntityType$Builder is not a valid object to supply. Additionally `Block#build` doesn't exist. I suggest looking once again at what is available since you seem to have performed an incorrect copy.
February 21, 20232 yr Author Okay so I fixed the constructor, but I only solved half of my problems. What is the proper way to register an entity if EntityType$Builder objects are not valid to supply? Because after reading the forge docs it seems like entities can only be created using their $Builder classes.
February 22, 20232 yr 18 hours ago, Johnnycakes said: What is the proper way to register an entity if EntityType$Builder objects are not valid to supply? Because after reading the forge docs it seems like entities can only be created using their $Builder classes. They are. It's just that, as mentioned, EntityType$Builder is not a valid type to supply for EntityType. You can get an EntityType from an EntityType$Builder via #build. Block#build is not a valid method. I believe you can figure out the rest if you read your code.
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.