#ive checked everything abt this code and its still broken

12 messages · Page 1 of 1 (latest)

patent tusk
#
var EntityType = Java.type('net.minecraft.world.entity.EntityType');
var SpawnEggItem = Java.type('net.minecraft.world.item.SpawnEggItem');
var Registry = Java.type('net.minecraft.core.Registry');
var RegistryKey = Java.type('net.minecraft.core.RegistryKey');

// Register an event listener for when a new player joins the server
events.listen('player.logged_in', function(event) {
  // Get the player's world
  var player = event.getPlayer();
  var world = player.getCommandSenderWorld();
  
  // Remove all vanilla hostile mob spawn eggs
  var hostileEggIds = [EntityType.ZOMBIE, EntityType.SKELETON, EntityType.SPIDER, EntityType.CREEPER, EntityType.ENDERMAN];
  hostileEggIds.forEach(function(id) {
    var eggItem = Registry.ITEM.get(new RegistryKey('minecraft', 'spawn_egg_' + EntityType.getKey(id).getPath()));
    if (eggItem instanceof SpawnEggItem) {
      world.getRecipeManager().removeRecipe(eggItem.getRegistryName());
    }
  });
});```


Ive ran it through syntax errors bing ai chat gpt all saying its fine im trying to get rid of all vanilla mob spawn eggs oh yea and it says in game java is not defined ive tried everything to fix it
kindred talonBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

fresh axle
#

what exactly are you trying to achieve hmmm

patent tusk
#

there mean

quaint vigil
#

why are you trying to remove items

#

thats not possible with kubejs

#

spawn eggs are also not obtainable in survival

#

so why are you trying to remove them

#

also why do you have both 1.18 and 1.16

#

??xy

little blazeBOT
# quaint vigil ??xy

The XY problem is when you really want to do X, and you think that Y can achieve X. However, you can't get Y to work, and so ask for help exclusively about Y.

This can lead to a lot of confusion from the people trying to help you, as Y can seem like a very random thing to want to do, and a lot of the time isn't the best way to achieve X anyway.

Its fine to ask about Y, just always include some context about X so you can be put on the right track if Y won't do X well, or there is an easier way to do X.