Fix Watering Can animation and tooltip
This commit is contained in:
parent
7e2204b7bb
commit
fab7353e78
|
|
@ -40,9 +40,11 @@ import thedarkcolour.exdeorum.client.screen.MechanicalSieveScreen;
|
||||||
import thedarkcolour.exdeorum.client.ter.*;
|
import thedarkcolour.exdeorum.client.ter.*;
|
||||||
import thedarkcolour.exdeorum.config.EConfig;
|
import thedarkcolour.exdeorum.config.EConfig;
|
||||||
import thedarkcolour.exdeorum.fluid.WitchWaterFluid;
|
import thedarkcolour.exdeorum.fluid.WitchWaterFluid;
|
||||||
|
import thedarkcolour.exdeorum.item.WateringCanItem;
|
||||||
import thedarkcolour.exdeorum.recipe.RecipeUtil;
|
import thedarkcolour.exdeorum.recipe.RecipeUtil;
|
||||||
import thedarkcolour.exdeorum.registry.EBlockEntities;
|
import thedarkcolour.exdeorum.registry.EBlockEntities;
|
||||||
import thedarkcolour.exdeorum.registry.EFluids;
|
import thedarkcolour.exdeorum.registry.EFluids;
|
||||||
|
import thedarkcolour.exdeorum.registry.EItems;
|
||||||
import thedarkcolour.exdeorum.registry.EMenus;
|
import thedarkcolour.exdeorum.registry.EMenus;
|
||||||
|
|
||||||
public class ClientHandler {
|
public class ClientHandler {
|
||||||
|
|
@ -66,7 +68,15 @@ public class ClientHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void registerClientExtensions(RegisterClientExtensionsEvent event) {
|
private static void registerClientExtensions(RegisterClientExtensionsEvent event) {
|
||||||
event.registerFluidType(WitchWaterFluid.createClientExtensions(), EFluids.WITCH_WATER_TYPE.get());
|
event.registerFluidType(new WitchWaterFluid.ClientExtensions(), EFluids.WITCH_WATER_TYPE.get());
|
||||||
|
event.registerItem(new WateringCanItem.ClientExtensions(),
|
||||||
|
EItems.WOODEN_WATERING_CAN.get(),
|
||||||
|
EItems.STONE_WATERING_CAN.get(),
|
||||||
|
EItems.IRON_WATERING_CAN.get(),
|
||||||
|
EItems.GOLDEN_WATERING_CAN.get(),
|
||||||
|
EItems.DIAMOND_WATERING_CAN.get(),
|
||||||
|
EItems.NETHERITE_WATERING_CAN.get()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void registerFluidModels(RegisterFluidModelsEvent event) {
|
private static void registerFluidModels(RegisterFluidModelsEvent event) {
|
||||||
|
|
|
||||||
|
|
@ -52,12 +52,10 @@ public class WitchWaterFluid extends FluidType {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IClientFluidTypeExtensions createClientExtensions() {
|
public static class ClientExtensions implements IClientFluidTypeExtensions {
|
||||||
return new IClientFluidTypeExtensions() {
|
@Override
|
||||||
@Override
|
public void modifyFogColor(Camera camera, float partialTick, ClientLevel level, int renderDistance, float darkenWorldAmount, Vector4f fluidFogColor) {
|
||||||
public void modifyFogColor(Camera camera, float partialTick, ClientLevel level, int renderDistance, float darkenWorldAmount, Vector4f fluidFogColor) {
|
fluidFogColor.set(32f / 255f, 12f / 255f, 64f / 255f, fluidFogColor.w);
|
||||||
fluidFogColor.set(32f / 255f, 12f / 255f, 64f / 255f, fluidFogColor.w);
|
}
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@ import net.minecraft.world.item.Item;
|
||||||
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.ItemUseAnimation;
|
import net.minecraft.world.item.ItemUseAnimation;
|
||||||
|
import net.minecraft.world.item.component.TooltipDisplay;
|
||||||
import net.minecraft.world.level.ClipContext;
|
import net.minecraft.world.level.ClipContext;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
|
|
@ -137,11 +138,12 @@ public class WateringCanItem extends Item {
|
||||||
return ItemUseAnimation.NONE;
|
return ItemUseAnimation.NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void appendHoverText(ItemStack stack, TooltipContext context, List<Component> tooltip, TooltipFlag pIsAdvanced) {
|
@Override
|
||||||
|
public void appendHoverText(ItemStack stack, TooltipContext context, TooltipDisplay display, Consumer<Component> tooltip, TooltipFlag tooltipFlag) {
|
||||||
var fluidHandler = getFluidHandler(stack);
|
var fluidHandler = getFluidHandler(stack);
|
||||||
if (fluidHandler != null) {
|
if (fluidHandler != null) {
|
||||||
// use the block name which is guaranteed to have a vanilla translation
|
// use the block name which is guaranteed to have a vanilla translation
|
||||||
tooltip.add(Component.translatable("block.minecraft.water").append(Component.translatable(TranslationKeys.FRACTION_DISPLAY, fluidHandler.getFluidInTank(0).getAmount(), this.capacity)).withStyle(ChatFormatting.GRAY));
|
tooltip.accept(Component.translatable("block.minecraft.water").append(Component.translatable(TranslationKeys.FRACTION_DISPLAY, fluidHandler.getFluidInTank(0).getAmount(), this.capacity)).withStyle(ChatFormatting.GRAY));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -307,8 +309,18 @@ public class WateringCanItem extends Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initializeClient(Consumer<IClientItemExtensions> consumer) {
|
private static IFluidHandler getFluidHandler(ItemAccess itemAccess) {
|
||||||
consumer.accept(ClientExtensions.INSTANCE);
|
var handler = itemAccess.getCapability(Capabilities.Fluid.ITEM);
|
||||||
|
return handler == null ? null : IFluidHandler.of(handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static IFluidHandler getFluidHandler(ItemStack stack) {
|
||||||
|
if (stack.isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
var itemAccess = ItemAccess.forStack(stack);
|
||||||
|
return getFluidHandler(itemAccess);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class FluidHandler extends FluidHandlerItemStack {
|
public static class FluidHandler extends FluidHandlerItemStack {
|
||||||
|
|
@ -351,9 +363,7 @@ public class WateringCanItem extends Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private enum ClientExtensions implements IClientItemExtensions {
|
public static class ClientExtensions implements IClientItemExtensions {
|
||||||
INSTANCE;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean applyForgeHandTransform(PoseStack poseStack, LocalPlayer player, HumanoidArm arm, ItemStack itemInHand, float partialTick, float equipProcess, float swingProcess) {
|
public boolean applyForgeHandTransform(PoseStack poseStack, LocalPlayer player, HumanoidArm arm, ItemStack itemInHand, float partialTick, float equipProcess, float swingProcess) {
|
||||||
if (player.isUsingItem()) {
|
if (player.isUsingItem()) {
|
||||||
|
|
@ -388,18 +398,4 @@ public class WateringCanItem extends Item {
|
||||||
return 1 - opposite * opposite * opposite;
|
return 1 - opposite * opposite * opposite;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IFluidHandler getFluidHandler(ItemAccess itemAccess) {
|
|
||||||
var handler = itemAccess.getCapability(Capabilities.Fluid.ITEM);
|
|
||||||
return handler == null ? null : IFluidHandler.of(handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static IFluidHandler getFluidHandler(ItemStack stack) {
|
|
||||||
if (stack.isEmpty()) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
var itemAccess = ItemAccess.forStack(stack);
|
|
||||||
return getFluidHandler(itemAccess);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user