mirror of
https://github.com/TeamMidnightDust/VisualOverhaul.git
synced 2025-12-16 14:05:08 +01:00
feat: rework dynamic item colors
This commit is contained in:
@@ -4,6 +4,7 @@ import com.mojang.blaze3d.systems.RenderSystem;
|
|||||||
import eu.midnightdust.visualoverhaul.config.VOConfig;
|
import eu.midnightdust.visualoverhaul.config.VOConfig;
|
||||||
import eu.midnightdust.visualoverhaul.mixin.TextureManagerAccessor;
|
import eu.midnightdust.visualoverhaul.mixin.TextureManagerAccessor;
|
||||||
import eu.midnightdust.visualoverhaul.util.ModIconUtil;
|
import eu.midnightdust.visualoverhaul.util.ModIconUtil;
|
||||||
|
import eu.midnightdust.visualoverhaul.util.VOColorUtil;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.client.gui.DrawContext;
|
import net.minecraft.client.gui.DrawContext;
|
||||||
import net.minecraft.client.gui.widget.ClickableWidget;
|
import net.minecraft.client.gui.widget.ClickableWidget;
|
||||||
@@ -25,6 +26,8 @@ import java.util.Map;
|
|||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
import static eu.midnightdust.visualoverhaul.util.VOColorUtil.alphaAndBrightness;
|
||||||
|
|
||||||
public class IconicButtons {
|
public class IconicButtons {
|
||||||
MinecraftClient client = MinecraftClient.getInstance();
|
MinecraftClient client = MinecraftClient.getInstance();
|
||||||
TextureManager textureManager = client.getTextureManager();
|
TextureManager textureManager = client.getTextureManager();
|
||||||
@@ -77,7 +80,7 @@ public class IconicButtons {
|
|||||||
boolean showLeftWhenBoth = (VOConfig.buttonIconPosition.equals(VOConfig.IconPosition.BOTH) && !limitedSpace) || (VOConfig.buttonIconPosition.equals(VOConfig.IconPosition.BOTH) && widget.getX() < scaledWidth/2);
|
boolean showLeftWhenBoth = (VOConfig.buttonIconPosition.equals(VOConfig.IconPosition.BOTH) && !limitedSpace) || (VOConfig.buttonIconPosition.equals(VOConfig.IconPosition.BOTH) && widget.getX() < scaledWidth/2);
|
||||||
boolean showRightWhenBoth = (VOConfig.buttonIconPosition.equals(VOConfig.IconPosition.BOTH) && !limitedSpace) || (VOConfig.buttonIconPosition.equals(VOConfig.IconPosition.BOTH) && widget.getX() > scaledWidth/2);
|
boolean showRightWhenBoth = (VOConfig.buttonIconPosition.equals(VOConfig.IconPosition.BOTH) && !limitedSpace) || (VOConfig.buttonIconPosition.equals(VOConfig.IconPosition.BOTH) && widget.getX() > scaledWidth/2);
|
||||||
|
|
||||||
int color = widget.active ? fromArgb(alpha, 1.0F) : fromArgb(alpha, 0.3F);
|
int color = widget.active ? alphaAndBrightness(alpha, 1.0F) : alphaAndBrightness(alpha, 0.3F);
|
||||||
RenderSystem.enableBlend();
|
RenderSystem.enableBlend();
|
||||||
RenderSystem.enableDepthTest();
|
RenderSystem.enableDepthTest();
|
||||||
int inset = 2;
|
int inset = 2;
|
||||||
@@ -96,9 +99,6 @@ public class IconicButtons {
|
|||||||
RenderSystem.disableDepthTest();
|
RenderSystem.disableDepthTest();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int fromArgb(float alpha, float brightness) {
|
|
||||||
return ColorHelper.getArgb(MathHelper.floor(alpha*255), MathHelper.floor(brightness*255), MathHelper.floor(brightness*255), MathHelper.floor(brightness*255));
|
|
||||||
}
|
|
||||||
public static void reload(ResourceManager manager) {
|
public static void reload(ResourceManager manager) {
|
||||||
manager.findResources("textures", path -> path.getNamespace().equals("iconic") && path.getPath().contains(".properties")).forEach((id, resource) -> {
|
manager.findResources("textures", path -> path.getNamespace().equals("iconic") && path.getPath().contains(".properties")).forEach((id, resource) -> {
|
||||||
if (manager.getResource(id).isEmpty()) return;
|
if (manager.getResource(id).isEmpty()) return;
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package eu.midnightdust.visualoverhaul.mixin;
|
||||||
|
|
||||||
|
import eu.midnightdust.visualoverhaul.VisualOverhaulClient;
|
||||||
|
import eu.midnightdust.visualoverhaul.config.VOConfig;
|
||||||
|
import net.minecraft.client.render.item.tint.ConstantTintSource;
|
||||||
|
import net.minecraft.client.world.ClientWorld;
|
||||||
|
import net.minecraft.entity.LivingEntity;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Mixin(ConstantTintSource.class)
|
||||||
|
public abstract class MixinConstantTintSource {
|
||||||
|
@Inject(at = @At("RETURN"), method = "getTint", cancellable = true)
|
||||||
|
public void vo$modifyLeafTint(ItemStack stack, ClientWorld world, LivingEntity user, CallbackInfoReturnable<Integer> cir) {
|
||||||
|
// Dynamic Leaf Item colors
|
||||||
|
if (VOConfig.coloredItems && List.of(-12012264).contains(cir.getReturnValue())) {
|
||||||
|
cir.setReturnValue(VisualOverhaulClient.foliageColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package eu.midnightdust.visualoverhaul.mixin;
|
||||||
|
|
||||||
|
import eu.midnightdust.visualoverhaul.VisualOverhaulClient;
|
||||||
|
import eu.midnightdust.visualoverhaul.config.VOConfig;
|
||||||
|
import net.minecraft.client.render.item.tint.GrassTintSource;
|
||||||
|
import net.minecraft.client.world.ClientWorld;
|
||||||
|
import net.minecraft.entity.LivingEntity;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
|
@Mixin(GrassTintSource.class)
|
||||||
|
public abstract class MixinGrassTintSource {
|
||||||
|
@Inject(at = @At("RETURN"), method = "getTint", cancellable = true)
|
||||||
|
public void vo$modifyGrassTint(ItemStack stack, ClientWorld world, LivingEntity user, CallbackInfoReturnable<Integer> cir) {
|
||||||
|
// Dynamic Grass Item colors
|
||||||
|
if (VOConfig.coloredItems) {
|
||||||
|
cir.setReturnValue(VisualOverhaulClient.grassColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
package eu.midnightdust.visualoverhaul.mixin;
|
||||||
|
|
||||||
|
import eu.midnightdust.visualoverhaul.VisualOverhaulClient;
|
||||||
|
import eu.midnightdust.visualoverhaul.config.VOConfig;
|
||||||
|
import net.minecraft.client.render.item.tint.PotionTintSource;
|
||||||
|
import net.minecraft.client.world.ClientWorld;
|
||||||
|
import net.minecraft.component.DataComponentTypes;
|
||||||
|
import net.minecraft.entity.LivingEntity;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.potion.Potion;
|
||||||
|
import net.minecraft.potion.Potions;
|
||||||
|
import net.minecraft.registry.entry.RegistryEntry;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Unique;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Mixin(PotionTintSource.class)
|
||||||
|
public class MixinPotionTintSource {
|
||||||
|
@Unique private static final List<RegistryEntry<Potion>> WATER_POTIONS = List.of(Potions.WATER, Potions.MUNDANE, Potions.THICK, Potions.AWKWARD);
|
||||||
|
|
||||||
|
@Inject(at = @At("RETURN"), method = "getTint", cancellable = true)
|
||||||
|
public void vo$modifyWaterTint(ItemStack stack, ClientWorld world, LivingEntity user, CallbackInfoReturnable<Integer> cir) {
|
||||||
|
// Dynamic Potion Item colors
|
||||||
|
if (VOConfig.coloredItems) {
|
||||||
|
var contents = stack.getComponents().get(DataComponentTypes.POTION_CONTENTS);
|
||||||
|
if (contents != null && contents.potion().isPresent()) {
|
||||||
|
if (!WATER_POTIONS.contains(contents.potion().get()))
|
||||||
|
return; // Skip all potions with effects
|
||||||
|
}
|
||||||
|
cir.setReturnValue(VisualOverhaulClient.potionColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,12 +1,17 @@
|
|||||||
package eu.midnightdust.visualoverhaul.util;
|
package eu.midnightdust.visualoverhaul.util;
|
||||||
|
|
||||||
|
import net.minecraft.util.math.ColorHelper;
|
||||||
|
import net.minecraft.util.math.MathHelper;
|
||||||
|
|
||||||
public class VOColorUtil {
|
public class VOColorUtil {
|
||||||
public static int convertRgbToArgb(int rgb) {
|
public static int convertRgbToArgb(int rgb, int alpha) {
|
||||||
int red = 0xFF & (rgb >> 16);
|
int red = 0xFF & (rgb >> 16);
|
||||||
int green = 0xFF & (rgb >> 8);
|
int green = 0xFF & (rgb >> 8);
|
||||||
int blue = 0xFF & (rgb);
|
int blue = 0xFF & (rgb);
|
||||||
int alpha = 200; // Makes water bottles transparent, 255 would be opaque
|
|
||||||
|
|
||||||
return (alpha << 24) | (red << 16) | (green << 8) | blue;
|
return (alpha << 24) | (red << 16) | (green << 8) | blue;
|
||||||
}
|
}
|
||||||
|
public static int alphaAndBrightness(float alpha, float brightness) {
|
||||||
|
return ColorHelper.getArgb(MathHelper.floor(alpha*255), MathHelper.floor(brightness*255), MathHelper.floor(brightness*255), MathHelper.floor(brightness*255));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,9 @@
|
|||||||
"client": [
|
"client": [
|
||||||
"ItemRenderStateAccessor",
|
"ItemRenderStateAccessor",
|
||||||
"MixinBlastFurnaceBlock",
|
"MixinBlastFurnaceBlock",
|
||||||
|
"MixinConstantTintSource",
|
||||||
|
"MixinGrassTintSource",
|
||||||
|
"MixinPotionTintSource",
|
||||||
"MixinPressableWidget",
|
"MixinPressableWidget",
|
||||||
"MixinSliderWidget",
|
"MixinSliderWidget",
|
||||||
"MixinSmokerBlock",
|
"MixinSmokerBlock",
|
||||||
|
|||||||
@@ -74,12 +74,6 @@ public class VisualOverhaulClientFabric implements ClientModInitializer {
|
|||||||
// PhonosCompatInit.init();
|
// PhonosCompatInit.init();
|
||||||
//}
|
//}
|
||||||
|
|
||||||
// Registries.ITEM.forEach((item) -> {
|
|
||||||
// ModelPredicateProviderRegistry.register(item, Identifier.ofVanilla("round"), (stack, world, entity, seed) ->
|
|
||||||
// stack.getComponents().contains(DataComponentTypes.JUKEBOX_PLAYABLE) && stack.getComponents().contains(DataComponentTypes.CUSTOM_MODEL_DATA) &&
|
|
||||||
// stack.getComponents().get(DataComponentTypes.CUSTOM_MODEL_DATA).value() == 710 ? 1.0F : 0.0F);
|
|
||||||
// });
|
|
||||||
|
|
||||||
ClientPlayNetworking.registerGlobalReceiver(UpdateItemsPacket.PACKET_ID,
|
ClientPlayNetworking.registerGlobalReceiver(UpdateItemsPacket.PACKET_ID,
|
||||||
(payload, context) -> context.client().execute(() -> {
|
(payload, context) -> context.client().execute(() -> {
|
||||||
if (payload.blockTypeID().equals(UPDATE_TYPE_RECORD)) jukeboxItems.put(payload.pos(), payload.inv().getFirst());
|
if (payload.blockTypeID().equals(UPDATE_TYPE_RECORD)) jukeboxItems.put(payload.pos(), payload.inv().getFirst());
|
||||||
@@ -101,7 +95,6 @@ public class VisualOverhaulClientFabric implements ClientModInitializer {
|
|||||||
ResourceManagerHelper.registerBuiltinResourcePack(id("nobrewingbottles"), modContainer, ResourcePackActivationType.DEFAULT_ENABLED);
|
ResourceManagerHelper.registerBuiltinResourcePack(id("nobrewingbottles"), modContainer, ResourcePackActivationType.DEFAULT_ENABLED);
|
||||||
ResourceManagerHelper.registerBuiltinResourcePack(id("fancyfurnace"), modContainer, ResourcePackActivationType.DEFAULT_ENABLED);
|
ResourceManagerHelper.registerBuiltinResourcePack(id("fancyfurnace"), modContainer, ResourcePackActivationType.DEFAULT_ENABLED);
|
||||||
ResourceManagerHelper.registerBuiltinResourcePack(id("coloredwaterbucket"), modContainer, ResourcePackActivationType.DEFAULT_ENABLED);
|
ResourceManagerHelper.registerBuiltinResourcePack(id("coloredwaterbucket"), modContainer, ResourcePackActivationType.DEFAULT_ENABLED);
|
||||||
ResourceManagerHelper.registerBuiltinResourcePack(id("rounddiscs"), modContainer, ResourcePackActivationType.ALWAYS_ENABLED);
|
|
||||||
});
|
});
|
||||||
ClientPlayConnectionEvents.JOIN.register((handler, sender, client) -> {
|
ClientPlayConnectionEvents.JOIN.register((handler, sender, client) -> {
|
||||||
if (client.player != null) {
|
if (client.player != null) {
|
||||||
@@ -116,7 +109,7 @@ public class VisualOverhaulClientFabric implements ClientModInitializer {
|
|||||||
waterColor = BiomeColors.getWaterColor(client.world, client.player.getBlockPos());
|
waterColor = BiomeColors.getWaterColor(client.world, client.player.getBlockPos());
|
||||||
foliageColor = BiomeColors.getFoliageColor(client.world, client.player.getBlockPos());
|
foliageColor = BiomeColors.getFoliageColor(client.world, client.player.getBlockPos());
|
||||||
grassColor = BiomeColors.getGrassColor(client.world, client.player.getBlockPos());
|
grassColor = BiomeColors.getGrassColor(client.world, client.player.getBlockPos());
|
||||||
potionColor = VOColorUtil.convertRgbToArgb(waterColor);
|
potionColor = VOColorUtil.convertRgbToArgb(waterColor, 200);
|
||||||
} else {
|
} else {
|
||||||
waterColor = 4159204;
|
waterColor = 4159204;
|
||||||
foliageColor = -8934609;
|
foliageColor = -8934609;
|
||||||
@@ -124,21 +117,6 @@ public class VisualOverhaulClientFabric implements ClientModInitializer {
|
|||||||
potionColor = -13083194;
|
potionColor = -13083194;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// ColorProviderRegistry.ITEM.register((stack, tintIndex) -> tintIndex == 0 ? -1 : waterColor, Items.WATER_BUCKET, Items.AXOLOTL_BUCKET, Items.COD_BUCKET, Items.PUFFERFISH_BUCKET, Items.TROPICAL_FISH_BUCKET, Items.SALMON_BUCKET);
|
|
||||||
// ColorProviderRegistry.ITEM.register((stack, tintIndex) -> grassColor, Items.GRASS_BLOCK, Items.SHORT_GRASS, Items.TALL_GRASS, Items.FERN, Items.LARGE_FERN);
|
|
||||||
// ColorProviderRegistry.ITEM.register((stack, tintIndex) -> foliageColor, Items.OAK_LEAVES, Items.DARK_OAK_LEAVES, Items.JUNGLE_LEAVES, Items.ACACIA_LEAVES, Items.VINE, Items.SUGAR_CANE);
|
|
||||||
// if (VOConfig.coloredLilypad) ColorProviderRegistry.ITEM.register((stack, tintIndex) -> foliageColor, Items.LILY_PAD);
|
|
||||||
//
|
|
||||||
// ColorProviderRegistry.ITEM.register((stack, tintIndex) -> {
|
|
||||||
// var contents = stack.getComponents().get(DataComponentTypes.POTION_CONTENTS);
|
|
||||||
// if (contents == null || contents.potion().isEmpty()) return tintIndex > 0 ? -1 : potionColor;
|
|
||||||
// var potion = contents.potion().get();
|
|
||||||
// if ((potion == Potions.WATER || potion == Potions.MUNDANE || potion == Potions.THICK || potion == Potions.AWKWARD) && tintIndex == 0) {
|
|
||||||
// return potionColor;
|
|
||||||
// }
|
|
||||||
// return tintIndex > 0 ? -1 : contents.getColor();
|
|
||||||
// }, Items.POTION, Items.SPLASH_POTION, Items.LINGERING_POTION);
|
|
||||||
}
|
}
|
||||||
if (VOConfig.coloredLilypad) {
|
if (VOConfig.coloredLilypad) {
|
||||||
ColorProviderRegistry.BLOCK.register((state, world, pos, tintIndex) -> world != null ? world.getColor(pos, BiomeColors.FOLIAGE_COLOR) : 0, Blocks.LILY_PAD);
|
ColorProviderRegistry.BLOCK.register((state, world, pos, tintIndex) -> world != null ? world.getColor(pos, BiomeColors.FOLIAGE_COLOR) : 0, Blocks.LILY_PAD);
|
||||||
|
|||||||
@@ -8,13 +8,10 @@ import net.minecraft.block.Block;
|
|||||||
import net.minecraft.block.Blocks;
|
import net.minecraft.block.Blocks;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.client.color.world.BiomeColors;
|
import net.minecraft.client.color.world.BiomeColors;
|
||||||
import net.minecraft.client.item.ModelPredicateProviderRegistry;
|
|
||||||
import net.minecraft.client.render.RenderLayer;
|
import net.minecraft.client.render.RenderLayer;
|
||||||
import net.minecraft.client.render.RenderLayers;
|
import net.minecraft.client.render.RenderLayers;
|
||||||
import net.minecraft.component.DataComponentTypes;
|
|
||||||
import net.minecraft.registry.Registries;
|
import net.minecraft.registry.Registries;
|
||||||
import net.minecraft.resource.ResourcePackProfile;
|
import net.minecraft.resource.ResourcePackProfile;
|
||||||
import net.minecraft.util.Identifier;
|
|
||||||
import net.neoforged.fml.ModLoadingContext;
|
import net.neoforged.fml.ModLoadingContext;
|
||||||
import net.neoforged.neoforge.client.event.ClientTickEvent;
|
import net.neoforged.neoforge.client.event.ClientTickEvent;
|
||||||
import net.neoforged.neoforge.common.NeoForge;
|
import net.neoforged.neoforge.common.NeoForge;
|
||||||
@@ -43,12 +40,6 @@ public class VisualOverhaulClientForge {
|
|||||||
});
|
});
|
||||||
NeoForge.EVENT_BUS.addListener(VisualOverhaulClientForge::doClientTick);
|
NeoForge.EVENT_BUS.addListener(VisualOverhaulClientForge::doClientTick);
|
||||||
|
|
||||||
Registries.ITEM.forEach((item) -> {
|
|
||||||
ModelPredicateProviderRegistry.register(item, Identifier.ofVanilla("round"), (stack, world, entity, seed) ->
|
|
||||||
stack.getComponents().contains(DataComponentTypes.JUKEBOX_PLAYABLE) && stack.getComponents().contains(DataComponentTypes.CUSTOM_MODEL_DATA) &&
|
|
||||||
stack.getComponents().get(DataComponentTypes.CUSTOM_MODEL_DATA).value() == 710 ? 1.0F : 0.0F);
|
|
||||||
});
|
|
||||||
|
|
||||||
RenderLayers.setRenderLayer(Blocks.JUKEBOX, RenderLayer.getCutout());
|
RenderLayers.setRenderLayer(Blocks.JUKEBOX, RenderLayer.getCutout());
|
||||||
RenderLayers.setRenderLayer(Blocks.FURNACE, RenderLayer.getCutout());
|
RenderLayers.setRenderLayer(Blocks.FURNACE, RenderLayer.getCutout());
|
||||||
RenderLayers.setRenderLayer(Blocks.SMOKER, RenderLayer.getCutout());
|
RenderLayers.setRenderLayer(Blocks.SMOKER, RenderLayer.getCutout());
|
||||||
@@ -61,7 +52,7 @@ public class VisualOverhaulClientForge {
|
|||||||
waterColor = BiomeColors.getWaterColor(client.world, client.player.getBlockPos());
|
waterColor = BiomeColors.getWaterColor(client.world, client.player.getBlockPos());
|
||||||
foliageColor = BiomeColors.getFoliageColor(client.world, client.player.getBlockPos());
|
foliageColor = BiomeColors.getFoliageColor(client.world, client.player.getBlockPos());
|
||||||
grassColor = BiomeColors.getGrassColor(client.world, client.player.getBlockPos());
|
grassColor = BiomeColors.getGrassColor(client.world, client.player.getBlockPos());
|
||||||
potionColor = VOColorUtil.convertRgbToArgb(waterColor);
|
potionColor = VOColorUtil.convertRgbToArgb(waterColor, 200);
|
||||||
} else {
|
} else {
|
||||||
waterColor = 4159204;
|
waterColor = 4159204;
|
||||||
foliageColor = -8934609;
|
foliageColor = -8934609;
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import static eu.midnightdust.visualoverhaul.VisualOverhaulCommon.*;
|
|||||||
|
|
||||||
@Mod(MOD_ID)
|
@Mod(MOD_ID)
|
||||||
public class VisualOverhaulForge {
|
public class VisualOverhaulForge {
|
||||||
|
|
||||||
public VisualOverhaulForge() {
|
public VisualOverhaulForge() {
|
||||||
if (FMLEnvironment.dist == Dist.CLIENT) VisualOverhaulClientForge.initClient();
|
if (FMLEnvironment.dist == Dist.CLIENT) VisualOverhaulClientForge.initClient();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import net.minecraft.block.entity.LockableContainerBlockEntity;
|
|||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
import net.minecraft.server.world.ServerChunkManager;
|
import net.minecraft.server.world.ServerChunkManager;
|
||||||
|
import net.minecraft.server.world.ServerWorld;
|
||||||
import net.minecraft.util.collection.DefaultedList;
|
import net.minecraft.util.collection.DefaultedList;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.ChunkPos;
|
import net.minecraft.util.math.ChunkPos;
|
||||||
@@ -36,7 +37,7 @@ public abstract class MixinAbstractFurnaceBlockEntity extends LockableContainerB
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Inject(at = @At("TAIL"), method = "tick")
|
@Inject(at = @At("TAIL"), method = "tick")
|
||||||
private static void tick(World world, BlockPos pos, BlockState state, AbstractFurnaceBlockEntity blockEntity, CallbackInfo ci) {
|
private static void tick(ServerWorld world, BlockPos pos, BlockState state, AbstractFurnaceBlockEntity blockEntity, CallbackInfo ci) {
|
||||||
if (world.getBlockState(pos).hasBlockEntity()) {
|
if (world.getBlockState(pos).hasBlockEntity()) {
|
||||||
if (!world.isClient && (visualoverhaul$invUpdate || world.getPlayers().size() == visualoverhaul$playerUpdate)) {
|
if (!world.isClient && (visualoverhaul$invUpdate || world.getPlayers().size() == visualoverhaul$playerUpdate)) {
|
||||||
Stream<ServerPlayerEntity> watchingPlayers = ((ServerChunkManager)world.getChunkManager()).chunkLoadingManager.getPlayersWatchingChunk(new ChunkPos(pos), false).stream();
|
Stream<ServerPlayerEntity> watchingPlayers = ((ServerChunkManager)world.getChunkManager()).chunkLoadingManager.getPlayersWatchingChunk(new ChunkPos(pos), false).stream();
|
||||||
|
|||||||
@@ -1,39 +0,0 @@
|
|||||||
package eu.midnightdust.visualoverhaul.neoforge.mixin;
|
|
||||||
|
|
||||||
import eu.midnightdust.visualoverhaul.config.VOConfig;
|
|
||||||
import net.minecraft.client.color.block.BlockColors;
|
|
||||||
import net.minecraft.client.color.item.ItemColors;
|
|
||||||
import net.minecraft.component.DataComponentTypes;
|
|
||||||
import net.minecraft.item.Items;
|
|
||||||
import net.minecraft.potion.Potions;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
|
||||||
|
|
||||||
import static eu.midnightdust.visualoverhaul.VisualOverhaulClient.*;
|
|
||||||
import static eu.midnightdust.visualoverhaul.VisualOverhaulClient.potionColor;
|
|
||||||
|
|
||||||
@Mixin(ItemColors.class)
|
|
||||||
public abstract class MixinItemColors {
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
@Inject(method = "create", at = @At("RETURN"))
|
|
||||||
private static void create(BlockColors blockMap, CallbackInfoReturnable<ItemColors> info) {
|
|
||||||
if (VOConfig.coloredItems) {
|
|
||||||
ItemColors itemColors = info.getReturnValue();
|
|
||||||
itemColors.register((stack, tintIndex) -> tintIndex == 0 ? -1 : waterColor, Items.WATER_BUCKET, Items.AXOLOTL_BUCKET, Items.COD_BUCKET, Items.PUFFERFISH_BUCKET, Items.TROPICAL_FISH_BUCKET, Items.SALMON_BUCKET);
|
|
||||||
itemColors.register((stack, tintIndex) -> grassColor, Items.GRASS_BLOCK, Items.SHORT_GRASS, Items.TALL_GRASS, Items.FERN, Items.LARGE_FERN);
|
|
||||||
itemColors.register((stack, tintIndex) -> foliageColor, Items.OAK_LEAVES, Items.JUNGLE_LEAVES, Items.DARK_OAK_LEAVES, Items.ACACIA_LEAVES, Items.VINE, Items.SUGAR_CANE);
|
|
||||||
if (VOConfig.coloredLilypad) itemColors.register((stack, tintIndex) -> foliageColor, Items.LILY_PAD);
|
|
||||||
itemColors.register((stack, tintIndex) -> {
|
|
||||||
var contents = stack.getComponents().get(DataComponentTypes.POTION_CONTENTS);
|
|
||||||
if (contents == null || contents.potion().isEmpty()) return tintIndex > 0 ? -1 : potionColor;
|
|
||||||
var potion = contents.potion().get();
|
|
||||||
if ((potion == Potions.WATER || potion == Potions.MUNDANE || potion == Potions.THICK || potion == Potions.AWKWARD) && tintIndex == 0) {
|
|
||||||
return potionColor;
|
|
||||||
}
|
|
||||||
return tintIndex > 0 ? -1 : contents.getColor();
|
|
||||||
}, Items.POTION, Items.SPLASH_POTION, Items.LINGERING_POTION);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user