Jump to content

Recommended Posts

Posted

I was inspired by the game Farcry Primal to create a Minecraft mod similar to it, mainly only implementing the Stone Age survival concept. However, to do this, some mobs things must be removed because they don't fit in. For example, zombies, creepers, endermen, skeletons, spiders, cave spiders, silverfish, iron weapons, pickaxes, and basically everything else in Minecraft. In other words, I'm attempting to turn Minecraft into another game by adding a mod. 

I'm pretty sure that I have to call EntityJoinWorldEvent to replace entities (from what I've read from modder forums), but I'm not sure how to use it to REMOVE entities. 

Furthermore, I need a way to remove/replace ITEMS in Minecraft, because the stone age didn't have iron weapons (or swords, pickaxes, etc.).

And finally, I need a way to remove villages and structures, although this one I can just suggest that the player turns it off. 

I feel like this is a lot, but I know that other mods have done stuff like this, so therefore it's possible. 

Posted (edited)

How would I go about canceling the EntityJoinWorldEvent? Can you give an example of how to format it? 

I was looking here for examples so I could get a basic idea of how to use it and formulate a complete "Event Handler" as I understand it's called (https://www.programcreek.com/java-api-examples/?class=net.minecraftforge.event.entity.EntityJoinWorldEvent&method=setCanceled), but I figure if I can see one designed specifically for my problem, I may have a much better time solving it. 

 

This is what I have so far... 

public class RemoveStuff {

//Removes all entities upon spawning// 
     @SubscribeEvent(priority = EventPriority.HIGHEST)
     public void OnEntitySpawn(EntityJoinWorldEvent event) {
          
          if (event.getEntity() instanceof /*/WHATEVER ENTITY/*/) {
          
          }
                event.setCanceled(boolean true);

     }

Am I close? 

 

Furthermore, how do I call on the item to set it's creative tab to null? Is that what the hashtag is for? To let you know where to specify what said Item/Event is? 

Edited by perigrine3
Posted (edited)
1 hour ago, perigrine3 said:

Thank you a lot, but I have another question; what are the # hashtags for? I've seen them a lot in other forums and modding assistance, but I have no clue what they mean? 

It means that the field or method isn't static

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

Double colons (e.g. SomeClass::SomeMethod) has a similar meaning, but I'll be honest that I haven't seen the distinction clarified for me. Just pointing out that you might see that sometimes too.

  • 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
4 hours ago, perigrine3 said:

This is what I have so far... 


public class RemoveStuff {

//Removes all entities upon spawning// 
     @SubscribeEvent(priority = EventPriority.HIGHEST)
     public void OnEntitySpawn(EntityJoinWorldEvent event) {
          
          if (event.getEntity() instanceof /*/WHATEVER ENTITY/*/) {
          
          }
                event.setCanceled(boolean true);

     }

Am I close? 

 

Your class isn’t annotated with @EventBusSubscriber and your method isn’t static so everything should work, but here’s this just in case.41725BB5-4DE4-43D5-8631-B167988B66E8.jpeg.ff334db72bec7b270c5d27f4f710e32f.jpeg

 

You want the method Event#setCancelled(boolean) which translates to the code event.setCancelled(true/false);

 

Your method should also begin with a lowercase (onEntitySpawn rather than OnEntitySpawn) and probably should be called onEntityJoinWorld because it’s not the same as spawning.

 

 

  • Thanks 1

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Posted

Alright, that makes sense, and I'm glad that this is working out so well so far. 

Now to move on to disabling the items: 

 
 
 
 
 
 
On 4/21/2019 at 8:22 AM, diesieben07 said:

Hide it from the creative menu (Item#setCreativeTab(null)).

So I assume that the code for this looks like item.setCreativeTab(null), but what I am wondering is how do I get specific items to hide? How do I reference them in a get statement? My first guess would be to use an "if" statement, like the one in my "onEntityJoin" event. Here's what I'm thinking: 

     public void hideCreativeItems(String item) {
          if (item.getItem() instanceof /*/WHATEVER ITEM/*/) {
          }
                item.setCreativeTab(null);
     }

I'm probably wrong about the string part because I'm still unsure as to how to use those. 

Please fix my code as necessary. 

Posted (edited)

I'm probably wrong again, but what the heck. Are either of these correct? 

1) 

     @SubscribeEvent
     public void setCreativeTab(IForgeRegistry item) {
          ForgeRegistries.ITEMS.setCreativeTab(null); 
     }

2) 

     @SubscribeEvent
     public Item setCreativeTab(CreativeTabs tab) {
          ForgeRegistries.ITEMS.setCreativeTab(null); 
     }

 

If not, please tell me why not, and if so, please tell me why. 

Also, what are the constants of Items.class? Could you give a link?

Edited by perigrine3
Posted (edited)

Neither, because neither method takes a parameter of type Event

Neither, because neither is a startup even method (preInit, Init, postInit)

Neither, because neither method correctly uses the Items registry (which item are you changing?)

The second one also declares a return type that is both unneeded and never returned. 

 

Quote

Also, what are the constants of Items.class?

Items.BREAD, Items.REDSTONE_DUST, Items.CAKE

etc

Edited by Draco18s

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

Look net.minecraft.item.Items or net.minecraft.forge.ForgeRegistries. Your mod should have something like the first one. The event in the argument is needed to call the method when the event fires. For example, a game wants to spawn a mob, an event fires and calls your method. If you do not have an event in the method, it will not be called. It seems something like that, but I could be wrong.

If I helped you, don't forget like. I'm using a translator, sorry.

Posted
46 minutes ago, perigrine3 said:

Then how would I use the items registry correctly?

Items.BREAD.setCreativeTab(null)

Is the same as

ForgeRegistries.ITEMS.get(new ResourceLocation("minecraft","bread"))

46 minutes ago, perigrine3 said:

Also, I figured it needed to be an event method. So like the event handler I made for repressing entities from spawning?

Yes. Well, probably. You need the right event type. 

49 minutes ago, Torq said:

The event in the argument is needed to call the method when the event fires. For example, a game wants to spawn a mob, an event fires and calls your method. If you do not have an event in the method, it will not be called. It seems something like that, but I could be wrong.

Sort of. The method signature needs to match in order for it to be called. If you don't have an Event type as the only parameter, then no event call will ever invoke your method because the signature would never match. 

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

I found an event that should work I think. It would have to activate as soon as the game loads, without crashing it, so I chose "FMLPostInitializationEvent". Now what I'm doing is listing out all of the item's I need to remove. 

However, I also have some blocks to remove. Would I call on them by say "Blocks" instead of "Items"?

Edited by perigrine3
Posted
4 hours ago, perigrine3 said:

However, I also have some blocks to remove. Would I call on them by say "Blocks" instead of "Items"?

Yes

  • Thanks 1

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Posted
//Removes items from Creative Tabs// 
     @SubscribeEvent
     public void setCreativeTab(IForgeRegistry item) {
          ForgeRegistries.ITEMS.setCreativeTab(null); 

          Item.registerItems(FMLPostInitializationEvent event) {
          
/*/Swords/*/ {
          Items.IRON_SWORD.setCreativeTab(null); 
          Items.WOODEN_SWORD.setCreativeTab(null); 
          Items.STONE_SWORD.setCreativeTab(null); 
          Items.DIAMOND_SWORD.setCreativeTab(null); 
          Items.GOLDEN_SWORD.setCreativeTab(null); 
          }

I'm unsure as to how to correctly format this. Can somebody please show me what I'm doing wrong? 

Posted (edited)

I don't think I understand it any better than I did before. 

//Removes items from Creative Tabs// 
     @SubscribeEvent
     public void hideFromCreative(FMLPostInitializationEvent event) {
          
/*/Swords/*/ {
          Item.IRON_SWORD.setCreativeTab(null); 
          Item.WOODEN_SWORD.setCreativeTab(null); 
          Item.STONE_SWORD.setCreativeTab(null); 
          Item.DIAMOND_SWORD.setCreativeTab(null); 
          Item.GOLDEN_SWORD.setCreativeTab(null); 
          }

If this is wrong, can someone PLEASE explain in Layman's terms how to fix it and why it is wrong? And can someone please give me an alternate solution? A different way to remove items and blocks from all creative tabs? Even just a way to repress the creative tabs would be fantastic. 

Edited by perigrine3
Posted
6 hours ago, perigrine3 said:

     public void setCreativeTab(IForgeRegistry item) {
          ForgeRegistries.ITEMS.setCreativeTab(null); 

          Item.registerItems(FMLPostInitializationEvent event) {

Why do you have a method inside a method?

 

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 did but I got rid of that. 

//Removes items from Creative Tabs// 
     @SubscribeEvent
     public void hideFromCreative(FMLPostInitializationEvent event) {
          
/*/Swords/*/ {
          Item.IRON_SWORD.setCreativeTab(null); 
          Item.WOODEN_SWORD.setCreativeTab(null); 
          Item.STONE_SWORD.setCreativeTab(null); 
          Item.DIAMOND_SWORD.setCreativeTab(null); 
          Item.GOLDEN_SWORD.setCreativeTab(null); 
          }

This is what I have now. 

Edited by perigrine3
Posted (edited)
1 hour ago, perigrine3 said:

I did but I got rid of that. 


//Removes items from Creative Tabs// 
     @SubscribeEvent
     public void hideFromCreative(FMLPostInitializationEvent event) {
          
/*/Swords/*/ {
          Item.IRON_SWORD.setCreativeTab(null); 
          Item.WOODEN_SWORD.setCreativeTab(null); 
          Item.STONE_SWORD.setCreativeTab(null); 
          Item.DIAMOND_SWORD.setCreativeTab(null); 
          Item.GOLDEN_SWORD.setCreativeTab(null); 
          }

This is what I have now. 

Please post your entire code; that extract of your code won't even compile.

Make sure you have valid event subscribers.

 

Correct me if I'm wrong, but I'm pretty sure FMLPostInitializationEvent is part of the FML lifecycle event thingy, thus it should be annotated with @EventHandler instead.

Edited by DavidM

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

Posted

It's a lot of code, but here it is: 

public class removeStuff {

//Removes entities upon spawning// 
     //Dragon 
     @SubscribeEvent
     public void onEntityJoin(EntityJoinWorldEvent event) {
          if (event.getEntity() instanceof EntityDragon) {
          }
                event.setCanceled(true);
     }

     //Wither
     @SubscribeEvent
     public void onEntityJoin(EntityJoinWorldEvent event) {
          if (event.getEntity() instanceof EntityWither) {
          }
                event.setCanceled(true);
     }

     //Mooshroom
     @SubscribeEvent
     public void onEntityJoin(EntityJoinWorldEvent event) {
          if (event.getEntity() instanceof EntityMooshroom) {
          }
                event.setCanceled(true);
     }

     //Donkey
     @SubscribeEvent
     public void onEntityJoin(EntityJoinWorldEvent event) {
          if (event.getEntity() instanceof EntityDonkey) {
          }
                event.setCanceled(true);
     }

     //Pig
     @SubscribeEvent
     public void onEntityJoin(EntityJoinWorldEvent event) {
          if (event.getEntity() instanceof EntityPig) {
          }
                event.setCanceled(true);
     }

     //Mule
     @SubscribeEvent
     public void onEntityJoin(EntityJoinWorldEvent event) {
          if (event.getEntity() instanceof EntityMule) {
          }
                event.setCanceled(true);
     }

     //Sheep
     @SubscribeEvent
     public void onEntityJoin(EntityJoinWorldEvent event) {
          if (event.getEntity() instanceof EntitySheep) {
          }
                event.setCanceled(true);
     }

     //ZombieHorse
     @SubscribeEvent
     public void onEntityJoin(EntityJoinWorldEvent event) {
          if (event.getEntity() instanceof EntityZombieHorse) {
          }
                event.setCanceled(true);
     }

     //Chicken
     @SubscribeEvent
     public void onEntityJoin(EntityJoinWorldEvent event) {
          if (event.getEntity() instanceof EntityChicken) {
          }
                event.setCanceled(true);
     }

     //Bat
     @SubscribeEvent
     public void onEntityJoin(EntityJoinWorldEvent event) {
          if (event.getEntity() instanceof EntityBat) {
          }
                event.setCanceled(true);
     }

     //Squid
     @SubscribeEvent
     public void onEntityJoin(EntityJoinWorldEvent event) {
          if (event.getEntity() instanceof EntitySquid) {
          }
                event.setCanceled(true);
     }

     //Cow
     @SubscribeEvent
     public void onEntityJoin(EntityJoinWorldEvent event) {
          if (event.getEntity() instanceof EntityCow) {
          }
                event.setCanceled(true);
     }

     //Villager
     @SubscribeEvent
     public void onEntityJoin(EntityJoinWorldEvent event) {
          if (event.getEntity() instanceof EntityVillager) {
          }
                event.setCanceled(true);
     }

     //Horse
     @SubscribeEvent
     public void onEntityJoin(EntityJoinWorldEvent event) {
          if (event.getEntity() instanceof EntityHorse) {
          }
                event.setCanceled(true);
     }

     //Llama
     @SubscribeEvent
     public void onEntityJoin(EntityJoinWorldEvent event) {
          if (event.getEntity() instanceof EntityLlama) {
          }
                event.setCanceled(true);
     }

     //SkeletonHorse
     public void onEntityJoin(EntityJoinWorldEvent event) {
          if (event.getEntity() instanceof EntitySkeletonHorse) {
          }
                event.setCanceled(true);
     }

     //Parrot
     @SubscribeEvent
     public void onEntityJoin(EntityJoinWorldEvent event) {
          if (event.getEntity() instanceof EntityParrot) {
          }
                event.setCanceled(true);
     }

     //Wolf
     @SubscribeEvent
     public void onEntityJoin(EntityJoinWorldEvent event) {
          if (event.getEntity() instanceof EntityWolf) {
          }
                event.setCanceled(true);
     }

     //Rabbit
     @SubscribeEvent
     public void onEntityJoin(EntityJoinWorldEvent event) {
          if (event.getEntity() instanceof EntityRabbit) {
          }
                event.setCanceled(true);
     }

     //Ocelot
     @SubscribeEvent
     public void onEntityJoin(EntityJoinWorldEvent event) {
          if (event.getEntity() instanceof EntityOcelot) {
          }
                event.setCanceled(true);
     }

     //Enderman
     @SubscribeEvent
     public void onEntityJoin(EntityJoinWorldEvent event) {
          if (event.getEntity() instanceof EntityEnderman) {
          }
                event.setCanceled(true);
     }

     //IronGolem
     @SubscribeEvent
     public void onEntityJoin(EntityJoinWorldEvent event) {
          if (event.getEntity() instanceof EntityIronGolem) {
          }
                event.setCanceled(true);
     }

     //Evoker
     @SubscribeEvent
     public void onEntityJoin(EntityJoinWorldEvent event) {
          if (event.getEntity() instanceof EntityEvoker) {
          }
                event.setCanceled(true);
     }

     //Skeleton
     @SubscribeEvent
     public void onEntityJoin(EntityJoinWorldEvent event) {
          if (event.getEntity() instanceof EntitySkeleton) {
          }
                event.setCanceled(true);
     }

     //Golem
     @SubscribeEvent
     public void onEntityJoin(EntityJoinWorldEvent event) {
          if (event.getEntity() instanceof EntityGolem) {
          }
                event.setCanceled(true);
     }

     //Husk
     @SubscribeEvent
     public void onEntityJoin(EntityJoinWorldEvent event) {
          if (event.getEntity() instanceof EntityHusk) {
          }
                event.setCanceled(true);
     }

     //Shulker
     @SubscribeEvent
     public void onEntityJoin(EntityJoinWorldEvent event) {
          if (event.getEntity() instanceof EntityShulker) {
          }
                event.setCanceled(true);
     }

     //Zombie
     @SubscribeEvent
     public void onEntityJoin(EntityJoinWorldEvent event) {
          if (event.getEntity() instanceof EntityZombie) {
          }
                event.setCanceled(true);
     }

     //Spider
     @SubscribeEvent
     public void onEntityJoin(EntityJoinWorldEvent event) {
          if (event.getEntity() instanceof EntitySpider) {
          }
                event.setCanceled(true);
     }

     //Silverfish
     @SubscribeEvent
     public void onEntityJoin(EntityJoinWorldEvent event) {
          if (event.getEntity() instanceof EntitySilverfish) {
          }
                event.setCanceled(true);
     }

     //IllusionIllager
     @SubscribeEvent
     public void onEntityJoin(EntityJoinWorldEvent event) {
          if (event.getEntity() instanceof EntityIllusionIllager) {
          }
                event.setCanceled(true);
     }

     //PigZombie
     @SubscribeEvent
     public void onEntityJoin(EntityJoinWorldEvent event) {
          if (event.getEntity() instanceof EntityPigZombie) {
          }
                event.setCanceled(true);
     }

     //WitherSkeleton
     @SubscribeEvent
     public void onEntityJoin(EntityJoinWorldEvent event) {
          if (event.getEntity() instanceof EntityWitherSkeleton) {
          }
                event.setCanceled(true);
     }

     //Ghast
     @SubscribeEvent
     public void onEntityJoin(EntityJoinWorldEvent event) {
          if (event.getEntity() instanceof EntityGhast) {
          }
                event.setCanceled(true);
     }

     //Vindicator
     @SubscribeEvent
     public void onEntityJoin(EntityJoinWorldEvent event) {
          if (event.getEntity() instanceof EntityVindicator) {
          }
                event.setCanceled(true);
     }

     //ZombieVillager
     @SubscribeEvent
     public void onEntityJoin(EntityJoinWorldEvent event) {
          if (event.getEntity() instanceof EntityZombieVillager) {
          }
                event.setCanceled(true);
     }

     //Snowman
     @SubscribeEvent
     public void onEntityJoin(EntityJoinWorldEvent event) {
          if (event.getEntity() instanceof EntitySnowman) {
          }
                event.setCanceled(true);
     }

     //Witch
     @SubscribeEvent
     public void onEntityJoin(EntityJoinWorldEvent event) {
          if (event.getEntity() instanceof EntityWitch) {
          }
                event.setCanceled(true);
     }

     //MagmaCube
     @SubscribeEvent
     public void onEntityJoin(EntityJoinWorldEvent event) {
          if (event.getEntity() instanceof EntityMagmaCube) {
          }
                event.setCanceled(true);
     }

     //SpellcasterIllager
     @SubscribeEvent
     public void onEntityJoin(EntityJoinWorldEvent event) {
          if (event.getEntity() instanceof EntitySpellcasterIllager) {
          }
                event.setCanceled(true);
     }

     //PolarBear
     @SubscribeEvent
     public void onEntityJoin(EntityJoinWorldEvent event) {
          if (event.getEntity() instanceof EntityPolarBear) {
          }
                event.setCanceled(true);
     }

     //Guardian
     @SubscribeEvent
     public void onEntityJoin(EntityJoinWorldEvent event) {
          if (event.getEntity() instanceof EntityGuardian) {
          }
                event.setCanceled(true);
     }

     //Vex
     @SubscribeEvent
     public void onEntityJoin(EntityJoinWorldEvent event) {
          if (event.getEntity() instanceof EntityVex) {
          }
                event.setCanceled(true);
     }

     //Slime
     @SubscribeEvent
     public void onEntityJoin(EntityJoinWorldEvent event) {
          if (event.getEntity() instanceof EntitySlime) {
          }
                event.setCanceled(true);
     }

     //Blaze
     @SubscribeEvent
     public void onEntityJoin(EntityJoinWorldEvent event) {
          if (event.getEntity() instanceof EntityBlaze) {
          }
                event.setCanceled(true);
     }

     //Creeper
     @SubscribeEvent
     public void onEntityJoin(EntityJoinWorldEvent event) {
          if (event.getEntity() instanceof EntityCreeper) {
          }
                event.setCanceled(true);
     }

     //ElderGuardian
     @SubscribeEvent
     public void onEntityJoin(EntityJoinWorldEvent event) {
          if (event.getEntity() instanceof EntityElderGuardian) {
          }
                event.setCanceled(true);
     }

     //CaveSpider
     @SubscribeEvent
     public void onEntityJoin(EntityJoinWorldEvent event) {
          if (event.getEntity() instanceof EntityCaveSpider) {
          }
                event.setCanceled(true);
     }

     //Endermite
     @SubscribeEvent
     public void onEntityJoin(EntityJoinWorldEvent event) {
          if (event.getEntity() instanceof EntityEndermite) {
          }
                event.setCanceled(true);
     }

     //Stray
     @SubscribeEvent
     public void onEntityJoin(EntityJoinWorldEvent event) {
          if (event.getEntity() instanceof EntityStray) {
          }
               event.setCanceled(true);
     }

//Removes items from Creative Tabs// 
     @EventHandler
     public void hideFromCreative(FMLPostInitializationEvent event) {
          
/*/Swords/*/ {
          Item.IRON_SWORD.setCreativeTab(null); 
          Item.WOODEN_SWORD.setCreativeTab(null); 
          Item.STONE_SWORD.setCreativeTab(null); 
          Item.DIAMOND_SWORD.setCreativeTab(null); 
          Item.GOLDEN_SWORD.setCreativeTab(null); 
          }
/*/Axes/*/ {
          Item.IRON_AXE.setCreativeTab(null); 
          Item.WOODEN_AXE.setCreativeTab(null); 
          Item.STONE_AXE.setCreativeTab(null); 
          Item.DIAMOND_AXE.setCreativeTab(null); 
          Item.GOLDEN_AXE.setCreativeTab(null); 
          }
/*/Pickaxes/*/ {
          Item.IRON_PICKAXE.setCreativeTab(null); 
          Item.WOODEN_PICKAXE.setCreativeTab(null); 
          Item.STONE_PICKAXE.setCreativeTab(null); 
          Item.DIAMOND_PICKAXE.setCreativeTab(null); 
          Item.GOLDEN_PICKAXE.setCreativeTab(null); 
          }
/*/Hoes/*/ {
          Item.IRON_HOE.setCreativeTab(null); 
          Item.WOODEN_HOE.setCreativeTab(null); 
          Item.STONE_HOE.setCreativeTab(null); 
          Item.DIAMOND_HOE.setCreativeTab(null); 
          Item.GOLDEN_HOE.setCreativeTab(null); 
          }
/*/Shovels/*/ {
          Item.IRON_SHOVEL.setCreativeTab(null); 
          Item.WOODEN_SHOVEL.setCreativeTab(null); 
          Item.STONE_SHOVEL.setCreativeTab(null); 
          Item.DIAMOND_SHOVEL.setCreativeTab(null); 
          Item.GOLDEN_SHOVEL.setCreativeTab(null); 
          }

/*/Ores and Stuff/*/ {
          Item.IRON_INGOT.setCreativeTab(null); 
          Item.GOLD_INGOT.setCreativeTab(null); 
          Item.EMERALD.setCreativeTab(null); 
          Item.DIAMOND.setCreativeTab(null); 
          Item.COAL.setCreativeTab(null); 
          Item.QUARTZ.setCreativeTab(null); 
          
          }

/*/Items/*/ {
          Item.GOLDEN_RAIL.setCreativeTab(null); 
          Item.DETECTOR_RAIL.setCreativeTab(null); 
          Item.RAIL.setCreativeTab(null); 
          Item.TORCH.setCreativeTab(null); 
          Item.CAKE.setCreativeTab(null); 
          Block.CAKE.setCreativeTab(null); 
          Item.ACTIVATOR_RAIL.setCreativeTab(null); 
          Item.LEVER.setCreativeTab(null); 
          Item.STONE_PRESSURE_PLATE.setCreativeTab(null); 
          Item.WOODEN_PRESSURE_PLATE.setCreativeTab(null); 
          Item.REDSTONE_TORCH.setCreativeTab(null); 
          Item.STONE_BUTTON.setCreativeTab(null); 
          Item.REPEATER.setCreativeTab(null); 
          Item.TRAPDOOR.setCreativeTab(null); 
          Item.IRON_BARS.setCreativeTab(null); 
          Item.GLASS_PANE.setCreativeTab(null); 
          Item.NETHER_WART.setCreativeTab(null); 
          Block.REDSTONE_LAMP.setCreativeTab(null); 
          Item.TRIPWIRE_HOOK.setCreativeTab(null); 
          Item.WOODEN_BUTTON.setCreativeTab(null); 
          Item.LIGHT_WEIGHTED_PRESSURE_PLATE.setCreativeTab(null); 
          Item.HEAVY_WEIGHTED_PRESSURE_PLATE.setCreativeTab(null); 
          Item.COMPARATOR.setCreativeTab(null); 
          Block.DAYLIGHT_DETECTOR.setCreativeTab(null); 
          Item.HOPPER.setCreativeTab(null); 
          Item.STAINED_GLASS_PANE.setCreativeTab(null); 
          Item.IRON_TRAPDOOR.setCreativeTab(null); 
          Item.CARPET.setCreativeTab(null); 
          Item.BANNER.setCreativeTab(null); 
          Item.SPRUCE_DOOR.setCreativeTab(null); 
          Item.BIRCH_DOOR.setCreativeTab(null); 
          Item.JUNGLE_DOOR.setCreativeTab(null); 
          Item.ACACIA_DOOR.setCreativeTab(null); 
          Item.DARK_OAK_DOOR.setCreativeTab(null); 
          Item.WOODEN_DOOR.setCreativeTab(null); 
          Block.END_ROD.setCreativeTab(null); 
          Block.GLASS.setCreativeTab(null); 
          Block.LAPIS_BLOCK.setCreativeTab(null); 
          Block.DISPENSER.setCreativeTab(null); 
          Block.NOTEBLOCK.setCreativeTab(null); 
          Item.BED.setCreativeTab(null); 
          Block.BED.setCreativeTab(null);
          Block.STICKY_PISTON.setCreativeTab(null); 
          Block.PISTON.setCreativeTab(null); 
          Block.WOOL.setCreativeTab(null); 
          Block.GOLD_BLOCK.setCreativeTab(null); 
          Block.IRON_BLOCK.setCreativeTab(null); 
          Block.STONE_SLAB.setCreativeTab(null); 
          Block.DOUBLE_STONE_SLAB.setCreativeTab(null); 
          Block.BRICK_BLOCK.setCreativeTab(null); 
          Block.TNT.setCreativeTab(null); 
          Block.BOOKSHELF.setCreativeTab(null); 
          Block.MOB_SPAWNER.setCreativeTab(null); 
          Block.CHEST.setCreativeTab(null); 
          Block.DIAMOND_BLOCK.setCreativeTab(null); 
          Block.CRAFTING_TABLE.setCreativeTab(null); 
          Block.FURNACE.setCreativeTab(null); 
          Block.STANDING_SIGN.setCreativeTab(null); 
          Item.LADDER.setCreativeTab(null); 
          Block.JUKEBOX.setCreativeTab(null); 
          Item.FENCE.setCreativeTab(null); 
          Block.PUMPKIN.setCreativeTab(null); 
          Block.NETHERRACK.setCreativeTab(null); 
          Block.SOUL_SAND.setCreativeTab(null); 
          Block.GLOWSTONE.setCreativeTab(null); 
          Block.PORTAL.setCreativeTab(null); 
          Block.LIT_PUMPKIN.setCreativeTab(null); 
          Block.STAINED_GLASS.setCreativeTab(null); 
          Block.MONSTER_EGG.setCreativeTab(null); 
          Block.STONEBRICK.setCreativeTab(null); 
          Item.FENCE_GATE.setCreativeTab(null); 
          Block.BRICK_STAIRS.setCreativeTab(null); 
          Block.STONE_BRICK_STAIRS.setCreativeTab(null); 
          Block.NETHER_BRICK.setCreativeTab(null); 
          Block.NETHER_BRICK_STAIRS.setCreativeTab(null); 
          Item.NETHER_BRICK_FENCE.setCreativeTab(null); 
          Block.ENCHANTING_TABLE.setCreativeTab(null); 
          Block.BREWING_STAND.setCreativeTab(null); 
          Block.CAULDRON.setCreativeTab(null); 
          Item.END_PORTAL.setCreativeTab(null); 
          Block.END_PORTAL_FRAME.setCreativeTab(null); 
          Block.END_STONE.setCreativeTab(null); 
          Item.DRAGON_EGG.setCreativeTab(null); 
          Block.REDSTONE_LAMP.setCreativeTab(null); 
          Block.ENDER_CHEST.setCreativeTab(null); 
          Block.EMERALD_BLOCK.setCreativeTab(null); 
          Block.BEACON.setCreativeTab(null); 
          Item.FLOWER_POT.setCreativeTab(null); 
          Item.SKULL.setCreativeTab(null); 
          Block.ANVIL.setCreativeTab(null); 
          Block.TRAPPED_CHEST.setCreativeTab(null); 
          Block.QUARTZ_BLOCK.setCreativeTab(null); 
          Block.QUARTZ_STAIRS.setCreativeTab(null); 
          Block.DROPPER.setCreativeTab(null); 
          Block.STAINED_HARDENED_CLAY.setCreativeTab(null); 
          Block.SLIME.setCreativeTab(null); 
          Block.PRISMARINE.setCreativeTab(null); 
          Block.SEA_LANTERN.setCreativeTab(null); 
          Block.HAY_BLOCK.setCreativeTab(null); 
          Block.HARDENED_CLAY.setCreativeTab(null); 
          Block.COAL_BLOCK.setCreativeTab(null); 
          Item.SPRUCE_FENCE_GATE.setCreativeTab(null); 
          Item.BIRCH_FENCE_GATE.setCreativeTab(null); 
          Item.JUNGLE_FENCE_GATE.setCreativeTab(null); 
          Item.DARK_OAK_FENCE_GATE.setCreativeTab(null); 
          Item.ACACIA_FENCE_GATE.setCreativeTab(null); 
          Item.SPRUCE_FENCE.setCreativeTab(null); 
          Item.BIRCH_FENCE.setCreativeTab(null); 
          Item.JUNGLE_FENCE.setCreativeTab(null); 
          Item.DARK_OAK_FENCE.setCreativeTab(null); 
          Item.ACACIA_FENCE_GATE.setCreativeTab(null); 
          Item.CHORUS_PLANT.setCreativeTab(null); 
          Item.CHORUS_FLOWER.setCreativeTab(null); 
          Block.PURPUR_BLOCK.setCreativeTab(null); 
          Block.PURPUR_PILLAR.setCreativeTab(null); 
          Block.PURPUR_STAIRS.setCreativeTab(null); 
          Block.PURPUR_SLAB.setCreativeTab(null); 
          Block.END_BRICKS.setCreativeTab(null); 
          Block.END_GATEWAY.setCreativeTab(null); 
          Block.OBSERVER.setCreativeTab(null); 
          Block.NETHER_WART_BLOCK.setCreativeTab(null); 
          Block.RED_NETHER_BRICK.setCreativeTab(null); 
          Block.BONE_BLOCK.setCreativeTab(null); 
          Block.WHITE_SHULKER_BOX.setCreativeTab(null); 
          Block.ORANGE_SHULKER_BOX.setCreativeTab(null); 
          Block.MAGENTA_SHULKER_BOX.setCreativeTab(null); 
          Block.LIGHT_BLUE_SHULKER_BOX.setCreativeTab(null); 
          Block.YELLOW_SHULKER_BOX.setCreativeTab(null); 
          Block.LIME_SHULKER_BOX.setCreativeTab(null); 
          Block.PINK_SHULKER_BOX.setCreativeTab(null); 
          Block.GRAY_SHULKER_BOX.setCreativeTab(null); 
          Block.SILVER_SHULKER_BOX.setCreativeTab(null); 
          Block.CYAN_SHULKER_BOX.setCreativeTab(null); 
          Block.PURPLE_SHULKER_BOX.setCreativeTab(null); 
          Block.BLUE_SHULKER_BOX.setCreativeTab(null); 
          Block.BROWN_SHULKER_BOX.setCreativeTab(null); 
          Block.GREEN_SHULKER_BOX.setCreativeTab(null); 
          Block.RED_SHULKER_BOX.setCreativeTab(null); 
          Block.BLACK_SHULKER_BOX.setCreativeTab(null); 
          Block.WHITE_GLAZED_TERRACOTTA.setCreativeTab(null); 
          Block.ORANGE_GLAZED_TERRACOTTA.setCreativeTab(null); 
          Block.MAGENTA_GLAZED_TERRACOTTA.setCreativeTab(null); 
          Block.LIGHT_BLUE_GLAZED_TERRACOTTA.setCreativeTab(null); 
          Block.YELLOW_GLAZED_TERRACOTTA.setCreativeTab(null); 
          Block.LIME_GLAZED_TERRACOTTA.setCreativeTab(null); 
          Block.PINK_GLAZED_TERRACOTTA.setCreativeTab(null); 
          Block.GRAY_GLAZED_TERRACOTTA.setCreativeTab(null); 
          Block.LIGHT_GRAY_GLAZED_TERRACOTTA.setCreativeTab(null); 
          Block.CYAN_GLAZED_TERRACOTTA.setCreativeTab(null); 
          Block.PURPLE_GLAZED_TERRACOTTA.setCreativeTab(null); 
          Block.BLUE_GLAZED_TERRACOTTA.setCreativeTab(null); 
          Block.BROWN_GLAZED_TERRACOTTA.setCreativeTab(null); 
          Block.GREEN_GLAZED_TERRACOTTA.setCreativeTab(null); 
          Block.RED_GLAZED_TERRACOTTA.setCreativeTab(null); 
          Block.BLACK_GLAZED_TERRACOTTA.setCreativeTab(null); 
          Block.CONCRETE.setCreativeTab(null); 
          Block.CONCRETE_POWDER.setCreativeTab(null); 
          Item.FLINT_AND_STEEL.setCreativeTab(null); 
          Item.BOWL.setCreativeTab(null); 
          Item.MUSHROOM_STEW.setCreativeTab(null); 
          Item.GUNPOWDER.setCreativeTab(null); 
          Item.BREAD.setCreativeTab(null); 
          Item.LEATHER_HELMET.setCreativeTab(null); 
          Item.LEATHER_CHESTPLATE.setCreativeTab(null); 
          Item.LEATHER_LEGGINGS.setCreativeTab(null); 
          Item.LEATHER_BOOTS.setCreativeTab(null); 
          Item.IRON_HELMET.setCreativeTab(null); 
          Item.IRON_CHESTPLATE.setCreativeTab(null); 
          Item.IRON_LEGGINGS.setCreativeTab(null); 
          Item.IRON_BOOTS.setCreativeTab(null); 
          Item.GOLD_HELMET.setCreativeTab(null); 
          Item.GOLD_CHESTPLATE.setCreativeTab(null); 
          Item.GOLD_LEGGINGS.setCreativeTab(null); 
          Item.GOLD_BOOTS.setCreativeTab(null); 
          Item.DIAMOND_HELMET.setCreativeTab(null); 
          Item.DIAMOND_CHESTPLATE.setCreativeTab(null); 
          Item.DIAMOND_LEGGINGS.setCreativeTab(null); 
          Item.DIAMOND_BOOTS.setCreativeTab(null); 
          Item.CHAINMAIL_HELMET.setCreativeTab(null); 
          Item.CHAINMAIL_CHESTPLATE.setCreativeTab(null); 
          Item.CHAINMAIL_LEGGINGS.setCreativeTab(null); 
          Item.CHAINMAIL_BOOTS.setCreativeTab(null); 
          Item.FLINT.setCreativeTab(null); 
          Item.RAW_PORKCHOP.setCreativeTab(null); 
          Item.COOKED_PORKCHOP.setCreativeTab(null); 
          Item.PAINTING.setCreativeTab(null); 
          Item.GOLDEN_APPLE.setCreativeTab(null); 
          Item.SIGN.setCreativeTab(null); 
          Item.WOODEN_DOOR.setCreativeTab(null); 
          Item.BUCKET.setCreativeTab(null); 
          Item.WATER_BUCKET.setCreativeTab(null); 
          Item.LAVA_BUCKET.setCreativeTab(null); 
          Item.MINECART.setCreativeTab(null); 
          Item.SADDLE.setCreativeTab(null); 
          Item.IRON_DOOR.setCreativeTab(null); 
          Item.REDSTONE.setCreativeTab(null); 
          Item.BOAT.setCreativeTab(null); 
          Item.LEATHER.setCreativeTab(null); 
          Item.MILK_BUCKET.setCreativeTab(null); 
          Item.BRICK.setCreativeTab(null); 
          Item.CLAY_BALL.setCreativeTab(null); 
          Item.PAPER.setCreativeTab(null); 
          Item.BOOK.setCreativeTab(null); 
          Item.SLIME_BALL.setCreativeTab(null); 
          Item.CHEST_MINECART.setCreativeTab(null); 
          Item.FURNACE_MINECART.setCreativeTab(null); 
          Item.EGG.setCreativeTab(null); 
          Item.COMPASS.setCreativeTab(null); 
          Item.FISHING_ROD.setCreativeTab(null); 
          Item.CLOCK.setCreativeTab(null); 
          Item.GLOWSTONE_DUST.setCreativeTab(null); 
          Item.DYE.setCreativeTab(null); 
          Item.SUGAR.setCreativeTab(null); 
          Item.COOKIE.setCreativeTab(null); 
          Item.MAP.setCreativeTab(null); 
          Item.SHEARS.setCreativeTab(null); 
          Item.PUMPKIN_SEEDS.setCreativeTab(null); 
          Item.BEEF.setCreativeTab(null); 
          Item.COOKED_BEEF.setCreativeTab(null); 
          Item.CHICKEN.setCreativeTab(null); 
          Item.COOKED_CHICKEN.setCreativeTab(null); 
          Item.ROTTEN_FLESH.setCreativeTab(null); 
          Item.ENDER_PEARL.setCreativeTab(null); 
          Item.BLAZE_ROD.setCreativeTab(null); 
          Item.GHAST_TEAR.setCreativeTab(null); 
          Item.GOLD_NUGGET.setCreativeTab(null); 
          Item.POTION.setCreativeTab(null); 
          Item.GLASS_BOTTLE.setCreativeTab(null); 
          Item.SPIDER_EYE.setCreativeTab(null); 
          Item.FERMENTED_SPIDER_EYE.setCreativeTab(null); 
          Item.BLAZE_POWDER.setCreativeTab(null); 
          Item.MAGMA_CREAM.setCreativeTab(null); 
          Item.ENDER_EYE.setCreativeTab(null); 
          Item.SPECKLED_MELON.setCreativeTab(null); 
          Item.SPAWN_EGG.setCreativeTab(null); 
          Item.EXPERIENCE_BOTTLE.setCreativeTab(null); 
          Item.FIRE_CHARGE.setCreativeTab(null); 
          Item.WRITABLE_BOOK.setCreativeTab(null); 
          Item.WRITTEN_BOOK.setCreativeTab(null); 
          Item.ITEM_FRAME.setCreativeTab(null); 
          Item.BAKED_POTATOE.setCreativeTab(null); 
          Item.POISONOUS_POTATOE.setCreativeTab(null); 
          Item.FILLED_MAP.setCreativeTab(null); 
          Item.GOLDEN_CARROT.setCreativeTab(null); 
          Item.CARROT_ON_A_STICK.setCreativeTab(null); 
          Item.NETHER_STAR.setCreativeTab(null); 
          Item.PUMPKIN_PIE.setCreativeTab(null); 
          Item.FIREWORKS.setCreativeTab(null); 
          Item.FIREWORK_CHARGE.setCreativeTab(null); 
          Item.ENCHANTED_BOOK.setCreativeTab(null); 
          Item.NETHERBRICK.setCreativeTab(null); 
          Item.PRISMARINE_SHARD.setCreativeTab(null); 
          Item.TNT_MINECART.setCreativeTab(null); 
          Item.HOPPER_MINECART.setCreativeTab(null); 
          Item.PRISMARINE_CRYSTALS.setCreativeTab(null); 
          Item.RABBIT.setCreativeTab(null); 
          Item.COOKED_RABBIT.setCreativeTab(null); 
          Item.RABBIT_STEW.setCreativeTab(null); 
          Item.RABBIT_FOOT.setCreativeTab(null); 
          Item.RABBIT_HIDE_.setCreativeTab(null); 
          Item.ARMOR_STAND.setCreativeTab(null); 
          Item.IRON_HORSE_ARMOR.setCreativeTab(null); 
          Item.GOLDEN_HORSE_ARMOR.setCreativeTab(null); 
          Item.DIAMOND_HORSE_ARMOR.setCreativeTab(null); 
          Item.NAME_TAG.setCreativeTab(null); 
          Item.COMMAND_BLOCK_MINECART.setCreativeTab(null); 
          Item.MUTTON.setCreativeTab(null); 
          Item.RAW_MUTTON.setCreativeTab(null); 
          Item.POPPED_CHORUS_FRUIT.setCreativeTab(null); 
          Item.BEETROOT.setCreativeTab(null); 
          Item.BEETROOT_SEEDS.setCreativeTab(null); 
          Item.BEETROOT_SUIT.setCreativeTab(null); 
          Item.DRAGON_BREATH.setCreativeTab(null); 
          Item.SPLASH_POTION.setCreativeTab(null); 
          Item.SPECTRAL_ARROW.setCreativeTab(null); 
          Item.TIPPED_ARROW.setCreativeTab(null); 
          Item.LINGERING_POTION.setCreativeTab(null); 
          Item.SHIELD.setCreativeTab(null); 
          Item.ELYTRA.setCreativeTab(null); 
          Item.SPRUCE_BOAT.setCreativeTab(null); 
          Item.BIRCH_BOAT.setCreativeTab(null); 
          Item.JUNGLE_BOAT.setCreativeTab(null); 
          Item.ACACIA_BOAT.setCreativeTab(null); 
          Item.DARK_OAK_BOAT.setCreativeTab(null); 
          Item.TOTEM_OF_UNDYING.setCreativeTab(null); 
          Item.SHULKER_SHELL.setCreativeTab(null); 
          Item.IRON_NUGGET.setCreativeTab(null); 
          Item.KNOWLEDGE_BOOK.setCreativeTab(null); 
          Item.RECORD_13.setCreativeTab(null); 
          Item.RECORD_CAT.setCreativeTab(null); 
          Item.RECORD_BLOCKS.setCreativeTab(null); 
          Item.RECORD_CHIRP.setCreativeTab(null); 
          Item.RECORD_FAR.setCreativeTab(null); 
          Item.RECORD_MALL.setCreativeTab(null); 
          Item.RECORD_MELLOHI.setCreativeTab(null); 
          Item.RECORD_STAL.setCreativeTab(null); 
          Item.RECORD_STRAD.setCreativeTab(null); 
          Item.RECORD_WARD.setCreativeTab(null); 
          Item.RECORD_11.setCreativeTab(null); 
          Item.WAIT.setCreativeTab(null); 
          }

     }

     public void blockStructures(InitMapGenEvent event) {
     // Cancels any structure generation
               event.setCanceled(true);
          }

} 

 

Posted

Damn. Okay. The onEntityJoin methods are all supposed to remove one mob, and I thought the if statement would do just that, so idk what you mean by 

5 minutes ago, diesieben07 said:

they all unconditionally cancel the event

 

I need a way to remove most of the items. Where can I find a list of all of the constants of the Items.class? 

Posted
56 minutes ago, perigrine3 said:

     @SubscribeEvent
     public void onEntityJoin(EntityJoinWorldEvent event) {
          if (event.getEntity() instanceof EntityDragon) {
              //this runs if the if statement is true
          }
          //now we're done with the if statement.

          event.setCanceled(true);
     }

See comments. Now go learn Java.

  • 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

You can just hide every item doing:

for(Item i : ForgeRegistries.ITEMS) {
	if(i.getCreatorModId(new ItemStack(i)).equals("minecraft")) {
				i.setCreativeTab(null);
	}
}

That means for every item in forge, if the item has the modid "minecraft" it will set the item's creative tab to null.

  • Thanks 1

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

    • Version 1.19 - Forge 41.0.63 I want to create a wolf entity that I can ride, so far it seems to be working, but the problem is that when I get on the wolf, I can’t control it. I then discovered that the issue is that the server doesn’t detect that I’m riding the wolf, so I’m struggling with synchronization. However, it seems to not be working properly. As I understand it, the server receives the packet but doesn’t register it correctly. I’m a bit new to Java, and I’ll try to provide all the relevant code and prints *The comments and prints are translated by chatgpt since they were originally in Spanish* Thank you very much in advance No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. MountableWolfEntity package com.vals.valscraft.entity; import com.vals.valscraft.network.MountSyncPacket; import com.vals.valscraft.network.NetworkHandler; import net.minecraft.client.Minecraft; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.animal.Wolf; import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.Entity; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.level.Level; import net.minecraft.world.phys.Vec3; import net.minecraftforge.event.TickEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.network.PacketDistributor; public class MountableWolfEntity extends Wolf { private boolean hasSaddle; private static final EntityDataAccessor<Byte> DATA_ID_FLAGS = SynchedEntityData.defineId(MountableWolfEntity.class, EntityDataSerializers.BYTE); public MountableWolfEntity(EntityType<? extends Wolf> type, Level level) { super(type, level); this.hasSaddle = false; } @Override protected void defineSynchedData() { super.defineSynchedData(); this.entityData.define(DATA_ID_FLAGS, (byte)0); } public static AttributeSupplier.Builder createAttributes() { return Wolf.createAttributes() .add(Attributes.MAX_HEALTH, 20.0) .add(Attributes.MOVEMENT_SPEED, 0.3); } @Override public InteractionResult mobInteract(Player player, InteractionHand hand) { ItemStack itemstack = player.getItemInHand(hand); if (itemstack.getItem() == Items.SADDLE && !this.hasSaddle()) { if (!player.isCreative()) { itemstack.shrink(1); } this.setSaddle(true); return InteractionResult.SUCCESS; } else if (!level.isClientSide && this.hasSaddle()) { player.startRiding(this); MountSyncPacket packet = new MountSyncPacket(true); // 'true' means the player is mounted NetworkHandler.CHANNEL.sendToServer(packet); // Ensure the server handles the packet return InteractionResult.SUCCESS; } return InteractionResult.PASS; } @Override public void travel(Vec3 travelVector) { if (this.isVehicle() && this.getControllingPassenger() instanceof Player) { System.out.println("The wolf has a passenger."); System.out.println("The passenger is a player."); Player player = (Player) this.getControllingPassenger(); // Ensure the player is the controller this.setYRot(player.getYRot()); this.yRotO = this.getYRot(); this.setXRot(player.getXRot() * 0.5F); this.setRot(this.getYRot(), this.getXRot()); this.yBodyRot = this.getYRot(); this.yHeadRot = this.yBodyRot; float forward = player.zza; float strafe = player.xxa; if (forward <= 0.0F) { forward *= 0.25F; } this.flyingSpeed = this.getSpeed() * 0.1F; this.setSpeed((float) this.getAttributeValue(Attributes.MOVEMENT_SPEED) * 1.5F); this.setDeltaMovement(new Vec3(strafe, travelVector.y, forward).scale(this.getSpeed())); this.calculateEntityAnimation(this, false); } else { // The wolf does not have a passenger or the passenger is not a player System.out.println("No player is mounted, or the passenger is not a player."); super.travel(travelVector); } } public boolean hasSaddle() { return this.hasSaddle; } public void setSaddle(boolean hasSaddle) { this.hasSaddle = hasSaddle; } @Override protected void dropEquipment() { super.dropEquipment(); if (this.hasSaddle()) { this.spawnAtLocation(Items.SADDLE); this.setSaddle(false); } } @SubscribeEvent public static void onServerTick(TickEvent.ServerTickEvent event) { if (event.phase == TickEvent.Phase.START) { MinecraftServer server = net.minecraftforge.server.ServerLifecycleHooks.getCurrentServer(); if (server != null) { for (ServerPlayer player : server.getPlayerList().getPlayers()) { if (player.isPassenger() && player.getVehicle() instanceof MountableWolfEntity) { MountableWolfEntity wolf = (MountableWolfEntity) player.getVehicle(); System.out.println("Tick: " + player.getName().getString() + " is correctly mounted on " + wolf); } } } } } private boolean lastMountedState = false; @Override public void tick() { super.tick(); if (!this.level.isClientSide) { // Only on the server boolean isMounted = this.isVehicle() && this.getControllingPassenger() instanceof Player; // Only print if the state changed if (isMounted != lastMountedState) { if (isMounted) { Player player = (Player) this.getControllingPassenger(); // Verify the passenger is a player System.out.println("Server: Player " + player.getName().getString() + " is now mounted."); } else { System.out.println("Server: The wolf no longer has a passenger."); } lastMountedState = isMounted; } } } @Override public void addPassenger(Entity passenger) { super.addPassenger(passenger); if (passenger instanceof Player) { Player player = (Player) passenger; if (!this.level.isClientSide && player instanceof ServerPlayer) { // Send the packet to the server to indicate the player is mounted NetworkHandler.CHANNEL.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) player), new MountSyncPacket(true)); } } } @Override public void removePassenger(Entity passenger) { super.removePassenger(passenger); if (passenger instanceof Player) { Player player = (Player) passenger; if (!this.level.isClientSide && player instanceof ServerPlayer) { // Send the packet to the server to indicate the player is no longer mounted NetworkHandler.CHANNEL.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) player), new MountSyncPacket(false)); } } } @Override public boolean isControlledByLocalInstance() { Entity entity = this.getControllingPassenger(); return entity instanceof Player; } @Override public void positionRider(Entity passenger) { if (this.hasPassenger(passenger)) { double xOffset = Math.cos(Math.toRadians(this.getYRot() + 90)) * 0.4; double zOffset = Math.sin(Math.toRadians(this.getYRot() + 90)) * 0.4; passenger.setPos(this.getX() + xOffset, this.getY() + this.getPassengersRidingOffset() + passenger.getMyRidingOffset(), this.getZ() + zOffset); } } } MountSyncPacket package com.vals.valscraft.network; import com.vals.valscraft.entity.MountableWolfEntity; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.player.Player; import net.minecraftforge.network.NetworkEvent; import java.util.function.Supplier; public class MountSyncPacket { private final boolean isMounted; public MountSyncPacket(boolean isMounted) { this.isMounted = isMounted; } public void encode(FriendlyByteBuf buffer) { buffer.writeBoolean(isMounted); } public static MountSyncPacket decode(FriendlyByteBuf buffer) { return new MountSyncPacket(buffer.readBoolean()); } public void handle(NetworkEvent.Context context) { context.enqueueWork(() -> { ServerPlayer player = context.getSender(); // Get the player from the context if (player != null) { // Verifies if the player has dismounted if (!isMounted) { Entity vehicle = player.getVehicle(); if (vehicle instanceof MountableWolfEntity wolf) { // Logic to remove the player as a passenger wolf.removePassenger(player); System.out.println("Server: Player " + player.getName().getString() + " is no longer mounted."); } } } }); context.setPacketHandled(true); // Marks the packet as handled } } networkHandler package com.vals.valscraft.network; import com.vals.valscraft.valscraft; import net.minecraft.resources.ResourceLocation; import net.minecraftforge.network.NetworkRegistry; import net.minecraftforge.network.simple.SimpleChannel; import net.minecraftforge.network.NetworkEvent; import java.util.function.Supplier; public class NetworkHandler { private static final String PROTOCOL_VERSION = "1"; public static final SimpleChannel CHANNEL = NetworkRegistry.newSimpleChannel( new ResourceLocation(valscraft.MODID, "main"), () -> PROTOCOL_VERSION, PROTOCOL_VERSION::equals, PROTOCOL_VERSION::equals ); public static void init() { int packetId = 0; // Register the mount synchronization packet CHANNEL.registerMessage( packetId++, MountSyncPacket.class, MountSyncPacket::encode, MountSyncPacket::decode, (msg, context) -> msg.handle(context.get()) // Get the context with context.get() ); } }  
    • Do you use features of inventory profiles next (ipnext) or is there a change without it?
    • Remove rubidium - you are already using embeddium, which is a fork of rubidium
  • Topics

×
×
  • Create New...

Important Information

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