修改item color位置

This commit is contained in:
17146 2025-02-23 03:44:35 +08:00
parent f09f597d86
commit af6e2b3c1e
2 changed files with 11 additions and 6 deletions

View file

@ -14,7 +14,6 @@ import net.minecraft.world.item.Items;
import net.minecraft.world.item.alchemy.PotionUtils; import net.minecraft.world.item.alchemy.PotionUtils;
import net.minecraft.world.item.alchemy.Potions; import net.minecraft.world.item.alchemy.Potions;
import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.item.crafting.Ingredient;
import net.minecraftforge.client.event.RegisterColorHandlersEvent;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.brewing.BrewingRecipeRegistry; import net.minecraftforge.common.brewing.BrewingRecipeRegistry;
import net.minecraftforge.event.TickEvent; import net.minecraftforge.event.TickEvent;
@ -70,7 +69,6 @@ public class ModUtils {
bus.addListener(this::onCommonSetup); bus.addListener(this::onCommonSetup);
bus.addListener(this::onClientSetup); bus.addListener(this::onClientSetup);
bus.addListener(this::onRegisterColorHandlers);
MinecraftForge.EVENT_BUS.register(this); MinecraftForge.EVENT_BUS.register(this);
} }
@ -189,8 +187,4 @@ public class ModUtils {
public void onClientSetup(final FMLClientSetupEvent event) { public void onClientSetup(final FMLClientSetupEvent event) {
MouseMovementHandler.init(); MouseMovementHandler.init();
} }
public void onRegisterColorHandlers(final RegisterColorHandlersEvent.Item event) {
event.register((stack, layer) -> layer == 1 ? PotionUtils.getColor(stack) : -1, ModItems.POTION_MORTAR_SHELL.get());
}
} }

View file

@ -1,15 +1,21 @@
package com.atsuishio.superbwarfare.item.common.ammo; package com.atsuishio.superbwarfare.item.common.ammo;
import com.atsuishio.superbwarfare.init.ModItems;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.TooltipFlag; import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.item.alchemy.PotionUtils; import net.minecraft.world.item.alchemy.PotionUtils;
import net.minecraft.world.item.alchemy.Potions; import net.minecraft.world.item.alchemy.Potions;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.event.RegisterColorHandlersEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.List; import java.util.List;
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
public class PotionMortarShell extends MortarShell { public class PotionMortarShell extends MortarShell {
public PotionMortarShell() { public PotionMortarShell() {
@ -25,4 +31,9 @@ public class PotionMortarShell extends MortarShell {
public void appendHoverText(ItemStack pStack, @Nullable Level pLevel, List<Component> pTooltip, TooltipFlag pFlag) { public void appendHoverText(ItemStack pStack, @Nullable Level pLevel, List<Component> pTooltip, TooltipFlag pFlag) {
PotionUtils.addPotionTooltip(pStack, pTooltip, 0.125F); PotionUtils.addPotionTooltip(pStack, pTooltip, 0.125F);
} }
@SubscribeEvent
public static void onRegisterColorHandlers(final RegisterColorHandlersEvent.Item event) {
event.register((stack, layer) -> layer == 1 ? PotionUtils.getColor(stack) : -1, ModItems.POTION_MORTAR_SHELL.get());
}
} }