mirror of
https://github.com/TeamMidnightDust/VisualOverhaul.git
synced 2025-12-16 14:05:08 +01:00
VisualOverhaul 5.0.0 - The Iconic Update
- Port to 1.19.4 - Use Architectury -> Forge & native Quilt support! - New Feature: Icon Buttons! - Makes buttons look less bland by adding icons to them - Loaded from resourcepacks - Currently uses vanilla items as icons - Organize config screen in tabs
This commit is contained in:
@@ -3,7 +3,6 @@ plugins {
|
||||
}
|
||||
|
||||
architectury {
|
||||
injectInjectables = false
|
||||
platformSetupLoomIde()
|
||||
forge()
|
||||
}
|
||||
@@ -32,7 +31,7 @@ dependencies {
|
||||
// Remove the next line if you don't want to depend on the API
|
||||
modApi "dev.architectury:architectury-forge:${rootProject.architectury_version}"
|
||||
modImplementation "maven.modrinth:midnightlib:${rootProject.midnightlib_version}-forge"
|
||||
include "maven.modrinth:midnightlib:${rootProject.midnightlib_version}-forge"
|
||||
//include "maven.modrinth:midnightlib:${rootProject.midnightlib_version}-forge"
|
||||
|
||||
common(project(path: ":common", configuration: "namedElements")) { transitive false }
|
||||
shadowCommon(project(path: ":common", configuration: "transformProductionForge")) { transitive = false }
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package eu.midnightdust.visualoverhaul.forge;
|
||||
|
||||
import eu.midnightdust.visualoverhaul.IconicButtons;
|
||||
import eu.midnightdust.visualoverhaul.block.model.FurnaceWoodenPlanksModel;
|
||||
import eu.midnightdust.visualoverhaul.block.renderer.BrewingStandBlockEntityRenderer;
|
||||
import eu.midnightdust.visualoverhaul.block.renderer.FurnaceBlockEntityRenderer;
|
||||
@@ -9,11 +10,11 @@ import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.color.world.BiomeColors;
|
||||
import net.minecraft.resource.*;
|
||||
import net.minecraft.resource.metadata.PackResourceMetadata;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.EntityRenderersEvent;
|
||||
import net.minecraftforge.client.event.RegisterClientReloadListenersEvent;
|
||||
import net.minecraftforge.event.AddPackFindersEvent;
|
||||
import net.minecraftforge.event.TickEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
@@ -22,8 +23,6 @@ import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.forgespi.locating.IModFile;
|
||||
import net.minecraftforge.resource.PathPackResources;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static eu.midnightdust.visualoverhaul.VisualOverhaul.MOD_ID;
|
||||
|
||||
@Mod.EventBusSubscriber(modid = MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
|
||||
@@ -57,6 +56,16 @@ public class VisualOverhaulClientEvents {
|
||||
event.registerBlockEntityRenderer(BlockEntityType.BLAST_FURNACE, FurnaceBlockEntityRenderer::new);
|
||||
}
|
||||
@SubscribeEvent
|
||||
public static void addReloadListener(RegisterClientReloadListenersEvent event) {
|
||||
event.registerReloadListener(new IconReloadListener());
|
||||
}
|
||||
public static class IconReloadListener implements SynchronousResourceReloader {
|
||||
@Override
|
||||
public void reload(ResourceManager manager) {
|
||||
IconicButtons.reload(manager);
|
||||
}
|
||||
}
|
||||
@SubscribeEvent
|
||||
public static void addPackFinders(AddPackFindersEvent event) {
|
||||
if (event.getPackType() == ResourceType.CLIENT_RESOURCES) {
|
||||
registerResourcePack(event, new Identifier(MOD_ID,"nobrewingbottles"), false, true);
|
||||
@@ -66,13 +75,15 @@ public class VisualOverhaulClientEvents {
|
||||
}
|
||||
}
|
||||
private static void registerResourcePack(AddPackFindersEvent event, Identifier id, boolean alwaysEnabled, boolean defaultEnabled) {
|
||||
event.addRepositorySource(((profileAdder, factory) -> {
|
||||
event.addRepositorySource(((profileAdder) -> {
|
||||
IModFile file = ModList.get().getModFileById(id.getNamespace()).getFile();
|
||||
try (PathPackResources pack = new PathPackResources(id.toString(), file.findResource("resourcepacks/" +id.getPath()))) {
|
||||
ResourcePackProfile packProfile = new ResourcePackProfile(id.toString(), alwaysEnabled, () -> pack, Text.of(id.getNamespace()+"/"+id.getPath()), pack.parseMetadata(PackResourceMetadata.READER).getDescription().copy().append(" §7(built-in)"), ResourcePackCompatibility.COMPATIBLE, ResourcePackProfile.InsertionPosition.TOP, false, ResourcePackSource.PACK_SOURCE_BUILTIN, false);
|
||||
profileAdder.accept(packProfile);
|
||||
if (defaultEnabled && !alwaysEnabled) VisualOverhaulClientForge.defaultEnabledPacks.add(packProfile);
|
||||
} catch (IOException | NullPointerException e) {e.printStackTrace();}
|
||||
try (PathPackResources pack = new PathPackResources(id.toString(), true, file.findResource("resourcepacks/" +id.getPath()))) {
|
||||
ResourcePackProfile packProfile = ResourcePackProfile.create(id.toString(), Text.of(id.getNamespace()+"/"+id.getPath()), alwaysEnabled, a -> pack, ResourceType.CLIENT_RESOURCES, ResourcePackProfile.InsertionPosition.TOP, ResourcePackSource.BUILTIN);
|
||||
if (packProfile != null) {
|
||||
profileAdder.accept(packProfile);
|
||||
if (defaultEnabled && !alwaysEnabled) VisualOverhaulClientForge.defaultEnabledPacks.add(packProfile);
|
||||
}
|
||||
} catch (NullPointerException e) {e.printStackTrace();}
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import dev.architectury.networking.NetworkManager;
|
||||
import eu.midnightdust.lib.config.MidnightConfig;
|
||||
import eu.midnightdust.visualoverhaul.VisualOverhaulClient;
|
||||
import eu.midnightdust.visualoverhaul.block.JukeboxTop;
|
||||
import eu.midnightdust.visualoverhaul.mixin.JukeboxBlockEntityAccessor;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.entity.AbstractFurnaceBlockEntity;
|
||||
@@ -84,7 +85,7 @@ public class VisualOverhaulClientForge {
|
||||
ItemStack record = attachedData.readItemStack();
|
||||
client.execute(() -> {
|
||||
if (client.world != null && client.world.getBlockEntity(pos) != null && client.world.getBlockEntity(pos) instanceof JukeboxBlockEntity blockEntity) {
|
||||
blockEntity.setRecord(record);
|
||||
((JukeboxBlockEntityAccessor)blockEntity).getInventory().set(0, record);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -46,7 +46,7 @@ public abstract class MixinJukeboxBlock extends BlockWithEntity {
|
||||
Stream<ServerPlayerEntity> watchingPlayers = ((ServerChunkManager)world.getChunkManager()).threadedAnvilChunkStorage.getPlayersWatchingChunk(new ChunkPos(pos), false).stream();
|
||||
PacketByteBuf passedData = new PacketByteBuf(Unpooled.buffer());
|
||||
passedData.writeBlockPos(pos);
|
||||
passedData.writeItemStack(blockEntity.getRecord());
|
||||
passedData.writeItemStack(blockEntity.getStack());
|
||||
|
||||
watchingPlayers.forEach(player -> NetworkManager.sendToPlayer(player, VisualOverhaul.UPDATE_RECORD, passedData));
|
||||
JukeboxPacketUpdate.invUpdate = false;
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package eu.midnightdust.visualoverhaul.util.forge;
|
||||
|
||||
import net.minecraftforge.fml.ModList;
|
||||
import net.minecraftforge.forgespi.language.IModInfo;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
public class ModIconUtilImpl {
|
||||
public static Path getPath(String modid) {
|
||||
IModInfo mod = ModList.get().getMods().stream().filter(modInfo -> modInfo.getModId().equals(modid)).findFirst().orElseThrow(() -> new RuntimeException("Cannot get ModContainer for Forge mod with id "));
|
||||
return mod.getOwningFile().getFile().findResource(mod.getLogoFile().orElseThrow());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user