Jump to content

Stynxyxy

Members
  • Posts

    5
  • Joined

  • Last visited

Stynxyxy's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. thank you a lot!
  2. I Wanted to create a oxidation function for my own items. But i get Errors when I start minecraft. Here the code for the oxidation: package de.stynxyxy.armorplus.oxidationevents; import de.stynxyxy.armorplus.item.copperlightoxidated; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.item.Item; import net.minecraft.world.item.Items; import net.minecraft.world.item.enchantment.Enchantment; import de.stynxyxy.armorplus.item.kupferarmorItem; import net.minecraft.world.item.ItemStack; import net.minecraftforge.event.TickEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import de.stynxyxy.armorplus.init.moditems; import org.apache.commons.lang3.ObjectUtils; import java.util.HashMap; import java.util.Map; @Mod.EventBusSubscriber public class oxidation { private static final int TRANSFORM_DELAY = 100; // Number of ticks after which the item should transform private static final Map<ItemStack, Integer> transformCounts = new HashMap<>(); private static final Map<Item, Item> TRANSFORM_MAP = new HashMap<>(); static { //TRANSFORM_MAP.put(moditems.copper_boots.get(),moditems.exposed_copper_boots.get()); } @SubscribeEvent public static void onServerTick(TickEvent.ServerTickEvent event) { if (event.phase == TickEvent.Phase.END && event.side.isServer()) { for (ServerPlayer player : event.getServer().getPlayerList().getPlayers()) { Inventory inventory = player.getInventory(); for (int i = 0; i < inventory.getContainerSize(); i++) { ItemStack itemStack = inventory.getItem(i); if (shouldTransform(itemStack)) { int tickCount = transformCounts.getOrDefault(itemStack, 0); if (tickCount >= TRANSFORM_DELAY) { Item targetItem = TRANSFORM_MAP.get(itemStack.getItem()); if (targetItem != null) { ItemStack newItemStack = new ItemStack(targetItem, itemStack.getCount()); // Transfer enchantments to the new item Map<Enchantment, Integer> enchantments = itemStack.getAllEnchantments(); for (Map.Entry<Enchantment, Integer> entry : enchantments.entrySet()) { Enchantment enchantment = entry.getKey(); int level = entry.getValue(); newItemStack.enchant(enchantment, level); } // Set the name of the new item newItemStack.setHoverName(itemStack.getHoverName()); inventory.setItem(i, newItemStack); transformCounts.remove(itemStack); } } else { transformCounts.put(itemStack, tickCount + 1); } } } } } } private static boolean shouldTransform(ItemStack itemStack) { return TRANSFORM_MAP.containsKey(itemStack.getItem()); } } Thank you (;
  3. How do I get the arrow entity then?
  4. I want to create a particle Trail for an Arrow
  5. I want to detect an arrow every tick. Is there any event that can help me achieve this? I have tried using the LivingGetProjectileEvent, but it only updates a few times and then stops, even if the arrow is still in the air. Additionally, this event only provides information about the player who shot the arrow.
×
×
  • Create New...

Important Information

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