Jump to content

Recommended Posts

Posted (edited)
2 hours ago, MineModder2000 said:

Well anyways this didn't work as iron golems still drop iron ingots :

That's because the ResourceLocation given by getName has a folder in the path IE entities/iron_golem. Also the namespace is the file name not the item it drops. You'll have to look at the LootTable/LootPool(s).

Edited by Animefan8888
  • Thanks 1

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
52 minutes ago, Animefan8888 said:

That's because the ResourceLocation given by getName has a folder in the namespace IE entities/iron_golem. Also the namespace is the file name not the item it drops. You'll have to look at the LootTable/LootPool(s).

 

The below code isn't cancelling the loot. 

 

 	if (event.getName().getNamespace().equals("entities/iron_golem")) {
    			
    		event.setCanceled(true);
    	}

 

Posted
8 minutes ago, MineModder2000 said:

.getNamespace()

This returns the modid(both of our mistakes). You need to use getPath. Also just canceling the event will cause all of the drops for the iron_golem to not drop. So maybe try to remove the pool for the iron ingots instead.

  • Thanks 1

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
1 hour ago, Animefan8888 said:

This returns the modid(both of our mistakes). You need to use getPath. Also just canceling the event will cause all of the drops for the iron_golem to not drop. So maybe try to remove the pool for the iron ingots instead.

 

I tried this, with and without the "item" before "leather", to no avail. 
    

 @SubscribeEvent
    public void lootTableLoadEvent(LootTableLoadEvent event) {
    	
    	if (event.getName().getPath().equals("entities/horse")) {
    			
    		event.getTable().removePool("item/leather");
    	}
    }
    
Posted (edited)
16 minutes ago, MineModder2000 said:

event.getTable().removePool("item/leather");

There is only one pool in entity loot tables it's called "main" and you need to remove an entry in that pool. Not the pool itself.

Edited by Animefan8888
  • Thanks 1

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
7 minutes ago, Animefan8888 said:

There is only one pool in entity loot tables it's called "main" and you need to remove an entry in that pool. Not the pool itself.

 

Not seeing any methods beyond this that allow for specific entry removal.....

 

event.getTable().getPool("main")
Posted (edited)

If you want to remove an item from a pool knowing only the item:

 

https://github.com/Draco18s/ReasonableRealism/blob/1.14.4/src/main/java/com/draco18s/hardlib/util/LootUtils.java#L34

 

You need reflection.

(Note: that removes it from all pools, you may wish to only remove from the main pool, from a pool by name, or...)

Edited by Draco18s
  • Thanks 1

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted
5 minutes ago, MineModder2000 said:

Not seeing any methods beyond this that allow for specific entry removal.....

That's because they haven't been implemented in 1.14 forge , yet(I assume). They are currently commented out in the source code under the forge section. You'll have to use Reflection like Draco18s has so helpfully provided an example for.

  • Thanks 1

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
9 minutes ago, Draco18s said:

If you want to remove an item from a pool knowing only the item:

 

https://github.com/Draco18s/ReasonableRealism/blob/1.14.4/src/main/java/com/draco18s/hardlib/util/LootUtils.java#L34

 

You need reflection.

(Note: that removes it from all pools, you may wish to only remove from the main pool, from a pool by name, or...)

 

7 minutes ago, Animefan8888 said:

That's because they haven't been implemented in 1.14 forge , yet(I assume). They are currently commented out in the source code under the forge section. You'll have to use Reflection like Draco18s has so helpfully provided an example for.

 

Thanks guys, I will consider if this is what I want to do, else I will do the json overriding technique instead. 

Posted

Probably. Have you tried looking at the code that handles it?

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Literally knowing fuckall about where to look, let me see...

 

oh hey, there's a net.minecraft.entity.merchant package. I wonder what's in here.

 

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted (edited)
2 hours ago, Draco18s said:

Literally knowing fuckall about where to look, let me see...

 

oh hey, there's a net.minecraft.entity.merchant package. I wonder what's in here.

 

My dreams of becoming a ballerina? I see the public field that I can change in VillagerTrades, I'll take a crack at it. 

Edited by MineModder2000
Posted
9 hours ago, MineModder2000 said:

My dreams of becoming a ballerina?

?

  • Haha 1

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted (edited)

I'm stoked that I got this to work, my test of farmers offering diamond axes was successful. I just realized that whatever trades the villagers load with, that's it, you can't change it retroactively, important note for testing. 

 

 

 

Edited by MineModder2000
Posted
58 minutes ago, MineModder2000 said:

HOW

Several ways. Why not take a look at the net.minecraftforge.event package and sub-packages? There is definitely an event for what you want.

  • Thanks 1

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)
10 minutes ago, Animefan8888 said:

Several ways. Why not take a look at the net.minecraftforge.event package and sub-packages? There is definitely an event for what you want.

Ah, I did this before asking but I missed it. It has the literal name : RightClickBlock, doh! 

Edited by MineModder2000
Posted

Hmm, i tried both of the following, no cigar : 

 

    @SubscribeEvent
    public void rightClickBlock(RightClickBlock event) {

    		event.setCanceled(true); 
    }
    
    @SubscribeEvent
    public void entityInteract(EntityInteract event) {

    		event.setCanceled(true); 
    }

 

PlayerInteractEvent is where these are located. 

Posted
9 hours ago, diesieben07 said:

Are you using the latest version of Forge for 1.14.4? I recall the interaction events were not fully working in the earlier versions.

Also, did you try using the debugger to see if your event handlers are called at all?

 

I am using 28.0.27. I can't run from Eclipse, I get errors. Updating may solve the problem. 

 

3 hours ago, Animefan8888 said:

Read the javadoc above the class.

 

I did, it just goes over how it fires and what not. 

 

    /**
     * This event is fired on both sides whenever the player right clicks while targeting a block.
     * This event controls which of {@link net.minecraft.block.Block#onBlockActivated} and/or {@link net.minecraft.item.Item#onItemUse}
     * will be called after {@link net.minecraft.item.Item#onItemUseFirst} is called.
     * Canceling the event will cause none of the above three to be called
     *
     * Let result be a return value of the above three methods, or {@link #cancellationResult} if the event is cancelled.
     * If we are on the client and result is not {@link EnumActionResult#SUCCESS}, the client will then try {@link RightClickItem}.
     *
     * There are various results to this event, see the getters below.
     * Note that handling things differently on the client vs server may cause desynchronizations!
     */

 

Canceling the event will cause none of the above three to be called, so it should work.

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




×
×
  • Create New...

Important Information

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