Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.14.4] Making a Trident like item


MineModder2000
 Share

Recommended Posts

9 hours ago, MineModder2000 said:

can't pass an extended or copied version of that class. 

Create  your own. Start thinking like a programmer. You need to create your own ItemStackTileEntityRenderer which handles your Spear item. God why do you have to have everything put right in front of you on plain paper.

 

Step 1. Create Your own ItemStackTileEntityRenderer implementation and override renderItem(ItemStack)

Step 2. Duplicate what the Trident does, but with your own model.

Step 3. Set it in your Items Properties with the Item.Properties#setTEISR

 

Step 4. Create thrown entity by extending the TridentEntity

Step 5. Create renderer that renders the your spear model at the entities position/angle etc.

Step 6. Make sure everything works.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

13 hours ago, Animefan8888 said:

Create  your own. Start thinking like a programmer. You need to create your own ItemStackTileEntityRenderer which handles your Spear item. God why do you have to have everything put right in front of you on plain paper.

 

Step 1. Create Your own ItemStackTileEntityRenderer implementation and override renderItem(ItemStack)

Step 2. Duplicate what the Trident does, but with your own model.

Step 3. Set it in your Items Properties with the Item.Properties#setTEISR

 

Step 4. Create thrown entity by extending the TridentEntity

Step 5. Create renderer that renders the your spear model at the entities position/angle etc.

Step 6. Make sure everything works.

 

Excuse me no need to be rude, a better question is why you don't fully read / understand what I am typing to you. I already tried making my own "ItemStackTileEntityRenderer", hence "copied version of that class". There is no use as the method "Item.Properties#setTEISR" only accepts "import net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer", specifically. No other path is accepted, so there is nothing I can do here it seems. 

 

I have been looking at "TridentEntity" already, and have had my own renderer class for a while, mind you I have been programming Java for some time and have made other mods (non-forge), and even android applications, I am not foreign to these concepts. I can do steps 4 - 6 but it would be pointless since I can't set any other "ItemStackTileEntityRenderer" than the vanilla one. 

Link to comment
Share on other sites

42 minutes ago, MineModder2000 said:

I already tried making my own "ItemStackTileEntityRenderer"

Then you have done.

public class MyOwnItemStackTileEntityRenderer extends ItemStackTileEntityRenderer 

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

32 minutes ago, MineModder2000 said:

Yes indeed, as stated in previous post, the method does not accept extended classes of "ItemStackTileEntityRendererB".

Yes it does. You must have done something wrong.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

On 8/22/2019 at 9:22 PM, TheMikeste1 said:

I'm not very familiar with Renderers, so it's probably best to get someone else's input.

If you dig around in Minecraft's files (as it seems you've done a couple posts prior), you'll notice there's a model/trident.json and a model/trident_in_hand.json. I assume  "in_hand" is the one representing the item you hold. You'll notice the parent is builtin/entity, which means it is using a registered Entity as a model. This means you'll need to create and register an Entity to serve as the model of your Item, as well as hold other important information. If you want to see vanilla example of creating Entities, check Minecraft's EntityType (You want to do this. There a a couple things I'm leaving out, such as defining hitboxes).

With Forge you register an Entity (or rather, an EntityType) a little differently than vanilla. It's basically the same as other Objects in Forge, and nearly identical to TileEntityTypes. Since I couldn't find any specific documentation on registering them, here's an example:


    //Entities
    @ObjectHolder("wabbit")
    public static final EntityType<WabbitEntity> wabbit = null;

    @SubscribeEvent
    public static void registerEntities(final RegistryEvent.Register<EntityType<?>> event) {
        LOGGER.debug("Wabbits: Registering Entities...");
        event.getRegistry().registerAll(
                EntityType.Builder.create(WabbitEntity::new, EntityClassification.AMBIENT)
                .build("wabbit").setRegistryName(Constants.MOD_ID, "wabbit");
        );
    } //registerEntities()

There are other files you'll likely want to create, such as a SpearModel (since it looks like you're making a spear). The best thing to do is just search "Trident" in you IDE and look at all the .java and .json files. Piece together what each thing does, and do your best to throw a spear together. You'll learn more as you go along and be able to come back to improve your spear.

EDIT: Also, note that when you make your Renderer, you'll also need to register it. you do that like this:


RenderingRegistry.registerEntityRenderingHandler(WabbitEntity.class, RenderWabbitFactory.INSTANCE);

The second value is a factory. Take a look at this for more info. (https://stackoverflow.com/questions/37126170/irenderfactory-help-in-minecraft-forge)

i apologize, I totally missed this reply of yours. I have indeed seen those files, there are three actually, another is trident_throwing.json. Anyways i have done the following : 

 

@Mod.EventBusSubscriber(bus=Mod.EventBusSubscriber.Bus.MOD)
    public static class RegistryEvents {
    	
    @SubscribeEvent
    public static void registerEntities(final RegistryEvent.Register<EntityType<?>> event) {

    LOGGER.debug("Hello from Register Entities");

    event.getRegistry().registerAll(

    	EntityType.Builder.create(Spear_Entity::new, EntityClassification.AMBIENT).build("spear").setRegistryName("mymod", "spear")
    );

    RenderingRegistry.registerEntityRenderingHandler(Spear_Entity.class, Spear_Factory.INSTANCE);
  }
}

 

Something is still amiss, how is my actual "SpearRender" class linked to my "SpearEntity" class? So I made this "Spear_Factory" class great, where does the important stuff hook in? Thanks btw. 

Edited by MineModder2000
Link to comment
Share on other sites

17 hours ago, Animefan8888 said:

Yes it does. You must have done something wrong.

Yes I did, I got it now, i had to implement some thing in the "Spear" class, and then pass it in to the method. The Renderer piece is still missing though, see the above post. 

Edited by MineModder2000
Link to comment
Share on other sites

9 hours ago, MineModder2000 said:

Something is still amiss, how is my actual "SpearRender" class linked to my "SpearEntity" class?

Do RenderingRegistry.registerEntityRenderingHandler() in your ClientSetupEvent

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

1 hour ago, Animefan8888 said:

Do RenderingRegistry.registerEntityRenderingHandler() in your ClientSetupEvent

 

I moved the line there but still, my renderer is not being used. The parameters for that call are as follows : 

 

RenderingRegistry.registerEntityRenderingHandler(Spear_Entity.class, Spear_Factory.INSTANCE);

 

So the question remains, where does Spear_Renderer fit in? I am guessing it has to be linked to the Spear_Factory, as of right now that class does nothing other than "implement IRenderFactory<Spear_Entity>" :

 

package mymod;

import net.minecraft.client.renderer.entity.EntityRenderer;
import net.minecraft.client.renderer.entity.EntityRendererManager;
import net.minecraftforge.fml.client.registry.IRenderFactory;

public class Spear_Factory implements IRenderFactory<Spear_Entity> {
	
	public static final Spear_Factory INSTANCE = new Spear_Factory();

	@Override
	public EntityRenderer<? super Spear_Entity> createRenderFor(EntityRendererManager manager) {
		
		return null;
	}
}

 

There has to be more.

Link to comment
Share on other sites

3 minutes ago, MineModder2000 said:

@Override public EntityRenderer<? super Spear_Entity> createRenderFor(EntityRendererManager manager) { return null; }

Why are you returning null here. It needs to return your renderer.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

9 minutes ago, Animefan8888 said:

Why are you returning null here. It needs to return your renderer.

 

Oh right, my bad, new to making entities and rendering...

package mymod;

import net.minecraft.client.renderer.entity.EntityRenderer;
import net.minecraft.client.renderer.entity.EntityRendererManager;
import net.minecraftforge.fml.client.registry.IRenderFactory;

public class Spear_Factory implements IRenderFactory<Spear_Entity> {
	
	public static final Spear_Factory INSTANCE = new Spear_Factory();
	private Spear_Renderer spear_Renderer = new Spear_Renderer(null);

	@Override
	public EntityRenderer<? super Spear_Entity> createRenderFor(EntityRendererManager manager) {
		
		spear_Renderer = new Spear_Renderer(manager);
		
		return spear_Renderer;
	}
}

 

Still chucking tridents....

Link to comment
Share on other sites

3 minutes ago, MineModder2000 said:

Still chucking tridents....

Oh...then your Item is still spawning Tridents...you need to override onStoppedUsing or whatever it is called.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

40 minutes ago, Animefan8888 said:

Oh...then your Item is still spawning Tridents...you need to override onStoppedUsing or whatever it is called.

Oh right it had trident entities in that method, I changed all of that which required me to update my "Spear_Entity" class and include another super constructor :

 

package mymod;

import net.minecraft.entity.EntityType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.projectile.TridentEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;

public class Spear_Entity extends TridentEntity {

	public Spear_Entity(EntityType<? extends TridentEntity> p_i50148_1_, World p_i50148_2_) {
		
		super(p_i50148_1_, p_i50148_2_);
	}

	public Spear_Entity(World worldIn, PlayerEntity playerentity, ItemStack stack) {

		super(worldIn, playerentity, stack);
	}
}

 

However this causes a problem inside of a line of code that previously worked fine :

 

   @SubscribeEvent
        public static void registerEntities(final RegistryEvent.Register<EntityType<?>> event) {
        	
            LOGGER.debug("Hello from Register Entities");
            
            event.getRegistry().registerAll(
            		
            	EntityType.Builder.create(Spear_Entity::new, EntityClassification.AMBIENT).build("spear").setRegistryName("mymod", "spear")
            );
            
        	RenderingRegistry.registerEntityRenderingHandler(Spear_Entity.class, Spear_Factory.INSTANCE);
        }

 

The "EntityType.Builder.create(Spear_Entity::new, EntityClassification.AMBIENT)" part is underlined in red in Eclipse with the following message : "Cannot infer type argument(s) for <T> create(EntityType.IFactory<T>, EntityClassification)". But this only happens when I have that second constructor in the entity class.

Link to comment
Share on other sites

35 minutes ago, MineModder2000 said:

Bump

Learn Java

 

On 8/25/2019 at 9:06 AM, MineModder2000 said:

The "EntityType.Builder.create(Spear_Entity::new, EntityClassification.AMBIENT)" part is underlined in red in Eclipse with the following message : "Cannot infer type argument(s) for <T> create(EntityType.IFactory<T>, EntityClassification)"

This is a Java error you could probably look this statement up in a generic way and find an answer.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

Well I learned the basics of generics and got the jist of it. This is my Spear_Entity class now : 

 

package mymod.spear;

import net.minecraft.entity.EntityType;
import net.minecraft.entity.EntityType.IFactory;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.projectile.TridentEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;

public class Spear_Entity extends TridentEntity implements IFactory<Spear_Entity> {

    public Spear_Entity(EntityType<? extends TridentEntity> p_i50148_1_, World p_i50148_2_) {
        
        super(p_i50148_1_, p_i50148_2_);
    }

    public Spear_Entity(World worldIn, PlayerEntity playerentity, ItemStack stack) {

        super(worldIn, playerentity, stack);
    }

    @Override
    public Spear_Entity create(EntityType<Spear_Entity> p_create_1_, World p_create_2_) {

        return null;
    }
}

 

But now I don't know which parameters to pass to the first constructor that is invoked here (the second one is called from my Spear extends Item class)  

 

   @SubscribeEvent
        public static void registerEntities(final RegistryEvent.Register<EntityType<?>> event) {
        	
            LOGGER.debug("Hello from Register Entities");
            
            event.getRegistry().registerAll(
            		
            	EntityType.Builder.create(new Spear_Entity(null, null), EntityClassification.MISC).build("spear").setRegistryName("mymod", "spear")
            	//EntityType.Builder.create(EntityClassification.MISC).build("spear").setRegistryName("mymod", "spear")
            );
            
        	RenderingRegistry.registerEntityRenderingHandler(Spear_Entity.class, Spear_Factory.INSTANCE);
        }


 

Link to comment
Share on other sites

14 minutes ago, MineModder2000 said:

But now I don't know which parameters to pass to the first constructor that is invoked here (the second one is called from my Spear extends Item class)  

By "first constructor," I assume you mean "new Spear_Entity(null , null)" inside of Builder#create. Instead of giving it an Entity, give it an IFactory, like so:

Spear_Entity::new

 

 

Edited by TheMikeste1
Typo
Link to comment
Share on other sites

I created my own throwable entity by copying (not extending) the EggItem and EggEntity classes. All works great, however the item breaks when hitting grass (as eggs do) when I want it to go through (like arrows and tridents do). Anyone have any idea how to make this happen? It just needs to ignore grasses...

Edited by MineModder2000
Link to comment
Share on other sites

22 minutes ago, MineModder2000 said:

Anyone have any idea how to make this happen?

In the onImpact method you have to check to see if the block is passable or not.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

1 hour ago, Animefan8888 said:

In the onImpact method you have to check to see if the block is passable or not.

Yes I am familiar with this method and have already explored this, but could not figure out any way to check for such. 

 

RayTraceResult.Type.BLOCK

 

The block variable here is not the same as the Block class, so it doesn't have "is passable" and related methods, and cannot be compared to grass blocks and such. Sorry I should've mentioned all this in the OP. 

Link to comment
Share on other sites

4 minutes ago, MineModder2000 said:

The block variable here is not the same as the Block class, so it doesn't have "is passable" and related methods,

True, but if you had looked into other instances of ThrowableEntity you would have found that if the Type is BLOCK then you could cast the RayTraceResult to BlockRayTraceResult and then get the Block's position in the world and get it from the World.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

2 hours ago, Animefan8888 said:

True, but if you had looked into other instances of ThrowableEntity you would have found that if the Type is BLOCK then you could cast the RayTraceResult to BlockRayTraceResult and then get the Block's position in the world and get it from the World.

Ah I see. Well I am trying this just as a test but getting console error :

 

     if (result.getType() == RayTraceResult.Type.BLOCK && this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.GRASS) {
            
            ((EntityRayTraceResult)result).getEntity().attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), damage);
            this.world.setEntityState(this, (byte)3);
            this.remove();
        }

 

It's too much to even post. 

 

Link to comment
Share on other sites

Just now, MineModder2000 said:

Well I am trying this just as a test but getting console error :

Well lets just look at why.

1 minute ago, MineModder2000 said:

 if (result.getType() == RayTraceResult.Type.BLOCK && this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.GRASS) {

Ok all is fine here you check if its type is BLOCK and then check if the block is grass. Good good.

1 minute ago, MineModder2000 said:

((EntityRayTraceResult)result).getEntity().attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), damage);

Then you immediately cast it to an EntityRayTraceResult even though the type is not ENTITY...
WHY? JUST WHY?

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

17 hours ago, Animefan8888 said:

Well lets just look at why.

Ok all is fine here you check if its type is BLOCK and then check if the block is grass. Good good.

Then you immediately cast it to an EntityRayTraceResult even though the type is not ENTITY...
WHY? JUST WHY?

Oh boy, this is a face palm for me ?. I had it written differently last night, and it wasn't working so I tried to test that line alone to see what would happen, forgetting the different types / casting. Chalk it up to late night brain fog. I have this now :

 


    	if (result.getType() == RayTraceResult.Type.BLOCK && this.world.getBlockState(((BlockRayTraceResult)result).getPos()).getBlock() == Blocks.GRASS) {
    		
    		System.out.println("no");
    	}
    	
    	else if (result.getType() == RayTraceResult.Type.ENTITY) {
        	
        	((EntityRayTraceResult)result).getEntity().attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), damage);
        	this.world.setEntityState(this, (byte)3);
        	this.remove();
        }

 

But it's going through all blocks, not just grass. 

Edited by MineModder2000
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
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.

 Share




×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.