Jump to content

Recommended Posts

Posted
  On 8/24/2019 at 12:45 AM, MineModder2000 said:

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

Expand  

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.

Posted
  On 8/24/2019 at 10:47 AM, 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.

Expand  

 

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. 

Posted
  On 8/25/2019 at 12:05 AM, MineModder2000 said:

I already tried making my own "ItemStackTileEntityRenderer"

Expand  

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.

Posted
  On 8/25/2019 at 12:55 AM, MineModder2000 said:

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

Expand  

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.

Posted (edited)
  On 8/23/2019 at 4:22 AM, 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)

Expand  

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
Posted (edited)
  On 8/25/2019 at 1:27 AM, Animefan8888 said:

Yes it does. You must have done something wrong.

Expand  

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
Posted
  On 8/25/2019 at 4:08 AM, MineModder2000 said:

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

Expand  

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.

Posted
  On 8/25/2019 at 1:54 PM, Animefan8888 said:

Do RenderingRegistry.registerEntityRenderingHandler() in your ClientSetupEvent

Expand  

 

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.

Posted
  On 8/25/2019 at 3:00 PM, MineModder2000 said:

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

Expand  

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.

Posted
  On 8/25/2019 at 3:03 PM, Animefan8888 said:

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

Expand  

 

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....

Posted
  On 8/25/2019 at 3:18 PM, MineModder2000 said:

Still chucking tridents....

Expand  

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.

Posted
  On 8/25/2019 at 3:21 PM, Animefan8888 said:

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

Expand  

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.

Posted
  On 8/27/2019 at 12:29 AM, MineModder2000 said:

Bump

Expand  

Learn Java

 

  On 8/25/2019 at 4:06 PM, 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)"

Expand  

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.

Posted

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);
        }


 

Posted (edited)
  On 8/29/2019 at 4:33 AM, 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)  

Expand  

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
Posted (edited)

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
Posted
  On 9/2/2019 at 12:44 AM, MineModder2000 said:

Anyone have any idea how to make this happen?

Expand  

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.

Posted
  On 9/2/2019 at 1:07 AM, Animefan8888 said:

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

Expand  

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. 

Posted
  On 9/2/2019 at 2:46 AM, MineModder2000 said:

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

Expand  

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.

Posted
  On 9/2/2019 at 2:55 AM, 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.

Expand  

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. 

 

Posted
  On 9/2/2019 at 5:28 AM, MineModder2000 said:

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

Expand  

Well lets just look at why.

  On 9/2/2019 at 5:28 AM, MineModder2000 said:

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

Expand  

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

  On 9/2/2019 at 5:28 AM, MineModder2000 said:

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

Expand  

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.

Posted (edited)
  On 9/2/2019 at 5:32 AM, 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?

Expand  

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

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.

Announcements




  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • You are using Create 6 - some addons are not compatible with it Remove all addons and add these one by one littlecontraptions is mentioned - keep this one removed
    • Different problem now. https://paste.ee/p/iDo8lS35
    • I would like to have a BoP sapling drop from my block if it is also installed. I think I have done everything and I cannot pinpoint the problem, which is the error in the logs that appears when joining a world:   [Worker-Main-11/ERROR] [ne.mi.co.ForgeHooks/]: Couldn't parse element loot_tables:grasses:blocks/leaves_block com.google.gson.JsonSyntaxException: Expected name to be an item, was unknown string 'biomesoplenty:magic_sapling' My code:   LootItemConditions.CONDITIONS.register(modEventBus); public class LootItemConditions { public static final DeferredRegister<LootItemConditionType> CONDITIONS = DeferredRegister.create(Registries.LOOT_CONDITION_TYPE, Grasses.MOD_ID); public static final RegistryObject<LootItemConditionType> IS_MOD_LOADED = CONDITIONS.register("is_mod_loaded", () -> new LootItemConditionType(new IsModLoaded.ConditionSerializer())); } public class IsModLoaded implements LootItemCondition { private final boolean exists; private final String modID; public IsModLoaded(String modID) { this.exists = ModList.get().isLoaded(modID); this.modID = modID; } @Override public LootItemConditionType getType() { return LootItemConditions.IS_MOD_LOADED.get(); } @Override public boolean test(LootContext context) { return this.exists; } public static LootItemCondition.Builder builder(String modid) { return () -> new IsModLoaded(modid); } public static class ConditionSerializer implements Serializer<IsModLoaded> { @Override public void serialize(JsonObject json, IsModLoaded instance, JsonSerializationContext ctx) { json.addProperty("modid", instance.modID); } @Override public IsModLoaded deserialize(JsonObject json, JsonDeserializationContext ctx) { return new IsModLoaded(GsonHelper.getAsString(json, "modid")); } } } protected LootTable.Builder createLeavesDropsWithModIDCheck(Block selfBlock, Item sapling, Property<?>[] properties, String modIDToCheck, float... chances) { CopyBlockState.Builder blockStateCopyBuilder = CopyBlockState.copyState(selfBlock); for(Property<?> property : properties) { blockStateCopyBuilder.copy(property); } return LootTable.lootTable() .withPool(LootPool.lootPool().setRolls(ConstantValue.exactly(1.0F)) .add(LootItem.lootTableItem(selfBlock) .when(HAS_SHEARS_OR_SILK_TOUCH) .apply(blockStateCopyBuilder))) .withPool(LootPool.lootPool().setRolls(ConstantValue.exactly(1.0F)) .add(this.applyExplosionCondition(selfBlock, LootItem.lootTableItem(sapling)) .when(IsModLoaded.builder(modIDToCheck))) .when(BonusLevelTableCondition.bonusLevelFlatChance(Enchantments.BLOCK_FORTUNE, chances)) .when(HAS_NO_SHEARS_OR_SILK_TOUCH)) .withPool(LootPool.lootPool().name("sticks").setRolls(ConstantValue.exactly(1.0F)) .add(this.applyExplosionDecay(selfBlock, LootItem.lootTableItem(Items.STICK). apply(SetItemCountFunction.setCount(UniformGenerator.between(1.0F, 2.0F)))) .when(BonusLevelTableCondition.bonusLevelFlatChance(Enchantments.BLOCK_FORTUNE, NORMAL_LEAVES_STICK_CHANCES)) .when(HAS_NO_SHEARS_OR_SILK_TOUCH))); } I don't know. Am I making a mistake somewhere? Am I forgetting something? Should there be something else?
  • Topics

×
×
  • Create New...

Important Information

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