Jump to content

[1.19.3] Help with custom TNT?


Johnnycakes

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

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.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.