mirror of
https://github.com/TeamMidnightDust/VisualOverhaul.git
synced 2025-12-18 14:35:09 +01:00
VisualOverhaul 3.0.0 - Puddles & Colors
Switched to MidnightConfig (No need to seperately download AutoConfig & ClothConfig anymore) Adds puddles which spawn during rain and can be used to fill a water bottle. (Game rule: "puddleSpawnRate") Also, snow layers can now pile up during snow storms. (Game rule: "snowStackChance") Items which are colored in their block form also show the color corresponding to the biome as an item. (Toggleable via config)
This commit is contained in:
@@ -5,13 +5,14 @@ import eu.midnightdust.visualoverhaul.block.renderer.BrewingStandBlockEntityRend
|
||||
import eu.midnightdust.visualoverhaul.block.renderer.FurnaceBlockEntityRenderer;
|
||||
import eu.midnightdust.visualoverhaul.block.renderer.JukeboxBlockEntityRenderer;
|
||||
import eu.midnightdust.visualoverhaul.config.VOConfig;
|
||||
import me.sargunvohra.mcmods.autoconfig1u.AutoConfig;
|
||||
import me.sargunvohra.mcmods.autoconfig1u.serializer.JanksonConfigSerializer;
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
|
||||
import net.fabricmc.fabric.api.client.rendereregistry.v1.BlockEntityRendererRegistry;
|
||||
import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry;
|
||||
import net.fabricmc.fabric.api.object.builder.v1.client.model.FabricModelPredicateProviderRegistry;
|
||||
import net.fabricmc.fabric.api.resource.ResourceManagerHelper;
|
||||
import net.fabricmc.fabric.impl.blockrenderlayer.BlockRenderLayerMapImpl;
|
||||
import net.fabricmc.fabric.impl.client.rendering.ColorProviderRegistryImpl;
|
||||
import net.fabricmc.fabric.impl.networking.ClientSidePacketRegistryImpl;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.block.Block;
|
||||
@@ -23,23 +24,30 @@ import net.minecraft.block.entity.JukeboxBlockEntity;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.item.MusicDiscItem;
|
||||
import net.minecraft.potion.PotionUtil;
|
||||
import net.minecraft.potion.Potions;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.collection.DefaultedList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.BuiltinBiomes;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import static eu.midnightdust.visualoverhaul.VisualOverhaul.*;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class VisualOverhaulClient implements ClientModInitializer {
|
||||
public static VOConfig VO_CONFIG;
|
||||
public static Block JukeBoxTop = new JukeboxTop();
|
||||
|
||||
public static Block JukeBoxTop = new JukeboxTop();
|
||||
private final MinecraftClient client = MinecraftClient.getInstance();
|
||||
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
AutoConfig.register(VOConfig.class, JanksonConfigSerializer::new);
|
||||
VO_CONFIG = AutoConfig.getConfigHolder(VOConfig.class).getConfig();
|
||||
VOConfig.init("visualoverhaul", VOConfig.class);
|
||||
|
||||
// Block only registered on client, because it's just used for the renderer //
|
||||
Registry.register(Registry.BLOCK, new Identifier("visualoverhaul","jukebox_top"), JukeBoxTop);
|
||||
@@ -58,7 +66,6 @@ public class VisualOverhaulClient implements ClientModInitializer {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
ClientSidePacketRegistryImpl.INSTANCE.register(UPDATE_POTION_BOTTLES,
|
||||
(packetContext, attachedData) -> {
|
||||
BlockPos pos = attachedData.readBlockPos();
|
||||
@@ -67,12 +74,14 @@ public class VisualOverhaulClient implements ClientModInitializer {
|
||||
inv.set(i, attachedData.readItemStack());
|
||||
}
|
||||
packetContext.getTaskQueue().execute(() -> {
|
||||
BrewingStandBlockEntity blockEntity = (BrewingStandBlockEntity) MinecraftClient.getInstance().world.getBlockEntity(pos);
|
||||
blockEntity.setStack(0,inv.get(0));
|
||||
blockEntity.setStack(1,inv.get(1));
|
||||
blockEntity.setStack(2,inv.get(2));
|
||||
blockEntity.setStack(3,inv.get(3));
|
||||
blockEntity.setStack(4,inv.get(4));
|
||||
if (client.world != null && client.world.getBlockEntity(pos) != null && client.world.getBlockEntity(pos) instanceof BrewingStandBlockEntity) {
|
||||
BrewingStandBlockEntity blockEntity = (BrewingStandBlockEntity) client.world.getBlockEntity(pos);
|
||||
blockEntity.setStack(0, inv.get(0));
|
||||
blockEntity.setStack(1, inv.get(1));
|
||||
blockEntity.setStack(2, inv.get(2));
|
||||
blockEntity.setStack(3, inv.get(3));
|
||||
blockEntity.setStack(4, inv.get(4));
|
||||
}
|
||||
});
|
||||
});
|
||||
ClientSidePacketRegistryImpl.INSTANCE.register(UPDATE_RECORD,
|
||||
@@ -80,8 +89,10 @@ public class VisualOverhaulClient implements ClientModInitializer {
|
||||
BlockPos pos = attachedData.readBlockPos();
|
||||
ItemStack record = attachedData.readItemStack();
|
||||
packetContext.getTaskQueue().execute(() -> {
|
||||
JukeboxBlockEntity blockEntity = (JukeboxBlockEntity)MinecraftClient.getInstance().world.getBlockEntity(pos);
|
||||
blockEntity.setRecord(record);
|
||||
if (client.world != null && client.world.getBlockEntity(pos) != null && client.world.getBlockEntity(pos) instanceof JukeboxBlockEntity) {
|
||||
JukeboxBlockEntity blockEntity = (JukeboxBlockEntity) client.world.getBlockEntity(pos);
|
||||
blockEntity.setRecord(record);
|
||||
}
|
||||
});
|
||||
});
|
||||
ClientSidePacketRegistryImpl.INSTANCE.register(UPDATE_FURNACE_ITEMS,
|
||||
@@ -92,16 +103,54 @@ public class VisualOverhaulClient implements ClientModInitializer {
|
||||
inv.set(i, attachedData.readItemStack());
|
||||
}
|
||||
packetContext.getTaskQueue().execute(() -> {
|
||||
FurnaceBlockEntity blockEntity = (FurnaceBlockEntity)MinecraftClient.getInstance().world.getBlockEntity(pos);
|
||||
blockEntity.setStack(0,inv.get(0));
|
||||
blockEntity.setStack(1,inv.get(1));
|
||||
blockEntity.setStack(2,inv.get(2));
|
||||
if (client.world != null && client.world.getBlockEntity(pos) != null && client.world.getBlockEntity(pos) instanceof FurnaceBlockEntity) {
|
||||
FurnaceBlockEntity blockEntity = (FurnaceBlockEntity) client.world.getBlockEntity(pos);
|
||||
blockEntity.setStack(0, inv.get(0));
|
||||
blockEntity.setStack(1, inv.get(1));
|
||||
blockEntity.setStack(2, inv.get(2));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Register builtin resourcepacks
|
||||
FabricLoader.getInstance().getModContainer("visualoverhaul").ifPresent(modContainer -> {
|
||||
ResourceManagerHelper.registerBuiltinResourcePack(new Identifier("visualoverhaul:nobottles"), "resourcepacks/nobrewingbottles", modContainer, true);
|
||||
ResourceManagerHelper.registerBuiltinResourcePack(new Identifier("visualoverhaul:fancyfurnace"), "resourcepacks/fancyfurnace", modContainer, true);
|
||||
ResourceManagerHelper.registerBuiltinResourcePack(new Identifier("visualoverhaul:coloredwaterbucket"), "resourcepacks/coloredwaterbucket", modContainer, true);
|
||||
});
|
||||
|
||||
// Context Colored Items
|
||||
if (VOConfig.coloredItems) {
|
||||
ClientTickEvents.END_CLIENT_TICK.register(client -> {
|
||||
int waterColor;
|
||||
int foliageColor;
|
||||
if (client.world != null) {
|
||||
Biome biome = client.world.getBiome(client.player.getBlockPos());
|
||||
waterColor = biome.getWaterColor();
|
||||
foliageColor = biome.getFoliageColor();
|
||||
} else {
|
||||
waterColor = BuiltinBiomes.PLAINS.getWaterColor();
|
||||
foliageColor = BuiltinBiomes.PLAINS.getFoliageColor();
|
||||
}
|
||||
ColorProviderRegistry.ITEM.register((stack, tintIndex) -> waterColor, VisualOverhaul.Puddle);
|
||||
ColorProviderRegistry.ITEM.register((stack, tintIndex) -> tintIndex == 0 ? -1 : waterColor, Items.WATER_BUCKET);
|
||||
ColorProviderRegistry.ITEM.register((stack, tintIndex) -> foliageColor, Items.GRASS_BLOCK);
|
||||
ColorProviderRegistry.ITEM.register((stack, tintIndex) -> foliageColor, Items.ACACIA_LEAVES);
|
||||
ColorProviderRegistry.ITEM.register((stack, tintIndex) -> foliageColor, Items.DARK_OAK_LEAVES);
|
||||
ColorProviderRegistry.ITEM.register((stack, tintIndex) -> foliageColor, Items.JUNGLE_LEAVES);
|
||||
ColorProviderRegistry.ITEM.register((stack, tintIndex) -> foliageColor, Items.OAK_LEAVES);
|
||||
ColorProviderRegistry.ITEM.register((stack, tintIndex) -> {
|
||||
if (PotionUtil.getPotion(stack) == Potions.WATER && tintIndex == 0) {
|
||||
return waterColor;
|
||||
}
|
||||
return tintIndex > 0 ? -1 : PotionUtil.getColor(stack);
|
||||
}, Items.POTION);
|
||||
});
|
||||
}
|
||||
// Else just register a static color for our puddle item
|
||||
else {
|
||||
ColorProviderRegistry.ITEM.register((stack, tintIndex) -> BuiltinBiomes.PLAINS.getWaterColor(), Puddle);
|
||||
}
|
||||
ColorProviderRegistry.BLOCK.register((state, view, pos, tintIndex) -> Objects.requireNonNull(ColorProviderRegistryImpl.BLOCK.get(Blocks.WATER)).getColor(state, view, pos, tintIndex), Puddle);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user