diff --git a/build.gradle.kts b/build.gradle.kts index 3ff90c8b..624a0437 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -104,7 +104,7 @@ dependencies { // Stuff I care about implementation(fg.deobf(curse("enchantment_descriptions", 250419, 2689502))) implementation(fg.deobf(curse("enchantment_descriptions_sources", 250419, 2689503))) - implementation(fg.deobf(curse("fluidlogged_api", 485654, 3698755))) + compileOnly(fg.deobf(curse("fluidlogged_api", 485654, 3698755))) implementation(fg.deobf(curse("biomes_o_plenty", 220318, 2842510))) implementation("CraftTweaker2:CraftTweaker2-MC1120-Main:1.12-4.1.19.548") implementation(fg.deobf("mezz.jei:jei_1.12.2:4.15.0.+")) diff --git a/src/main/java/thedarkcolour/futuremc/FutureMC.kt b/src/main/java/thedarkcolour/futuremc/FutureMC.kt index 166857f2..77844b2a 100644 --- a/src/main/java/thedarkcolour/futuremc/FutureMC.kt +++ b/src/main/java/thedarkcolour/futuremc/FutureMC.kt @@ -165,7 +165,7 @@ object FutureMC { @EventHandler fun postInit(event: FMLPostInitializationEvent) { EntityBee.FLOWERS.removeIf { state -> - state.material == Material.AIR // try to fix #281 + state.material == Material.AIR || !ForgeRegistries.BLOCKS.containsValue(state.block) // try to fix #281 } Biomes.PLAINS.addFlower(FBlocks.CORNFLOWER.defaultState, 5) diff --git a/src/main/java/thedarkcolour/futuremc/asm/CoreTransformer.java b/src/main/java/thedarkcolour/futuremc/asm/CoreTransformer.java index 756ded5b..5ebf1293 100644 --- a/src/main/java/thedarkcolour/futuremc/asm/CoreTransformer.java +++ b/src/main/java/thedarkcolour/futuremc/asm/CoreTransformer.java @@ -39,6 +39,9 @@ public byte[] transform(String name, String transformedName, byte[] basicClass) //case "net.minecraft.client.renderer.RenderItem": // return ASMUtil.patchRenderItem(basicClass); + case "com.fuzs.gamblingstyle.handler.OpenContainerHandler": + return transformOpenContainerHandler(basicClass); + case "net.minecraft.block.BlockPistonBase": try { Class.forName("vazkii.quark.base.asm.LoadingPlugin"); @@ -126,6 +129,34 @@ private static byte[] transformBO3Loader(byte[] basicClass) { return ASMUtil.compile(classNode); } + private static byte[] transformOpenContainerHandler(byte[] basicClass) { + ClassNode classNode = ASMUtil.createClassNode(basicClass); + MethodNode mv = ASMUtil.findMethod(classNode, "onContainerOpen", "onContainerOpen", null); + + LabelNode label = null; + + try { + label = (LabelNode) mv.instructions.getFirst(); + } catch (ClassCastException e) { + for (int i = 0; i < 10; i++) { + AbstractInsnNode insn = mv.instructions.get(i); + System.out.println(insn.getClass() + ": " + insn.getOpcode()); + } + } + + InsnList list = new InsnList(); + list.add(new LabelNode(new Label())); + list.add(new FieldInsnNode(GETSTATIC, "thedarkcolour/futuremc/config/FConfig", "INSTANCE", "Lthedarkcolour/futuremc/config/FConfig;")); + list.add(new MethodInsnNode(INVOKEVIRTUAL, "thedarkcolour/futuremc/config/FConfig", "getVillageAndPillage", "()Lthedarkcolour/futuremc/config/FConfig$VillageAndPillage;", false)); + list.add(new FieldInsnNode(GETFIELD, "thedarkcolour/futuremc/config/FConfig$VillageAndPillage", "newVillagerGui", "Z")); + list.add(new JumpInsnNode(IFEQ, label)); + list.add(new InsnNode(RETURN)); + + mv.instructions.insertBefore(label, list); + + return ASMUtil.compile(classNode); + } + private static byte[] patchEntityRenderer(byte[] basicClass) { // fix incompatibility with vivecraft? if (Compat.checkVivecraft()) return basicClass; diff --git a/src/main/java/thedarkcolour/futuremc/config/FConfig.kt b/src/main/java/thedarkcolour/futuremc/config/FConfig.kt index 63b82e3c..a1c9a4f7 100644 --- a/src/main/java/thedarkcolour/futuremc/config/FConfig.kt +++ b/src/main/java/thedarkcolour/futuremc/config/FConfig.kt @@ -356,7 +356,7 @@ object FConfig { @Name("New Villager Gui Screen") @Comment("Whether the 1.12 villager screen is replaced by FutureMC's 1.14 villager screen") @JvmField - val newVillagerGui = true + var newVillagerGui = true @Name("New Walls") @Comment("Enable/disable any of the new walls from 1.14") diff --git a/src/main/java/thedarkcolour/futuremc/event/Events.kt b/src/main/java/thedarkcolour/futuremc/event/Events.kt index 00254e21..5bd64020 100644 --- a/src/main/java/thedarkcolour/futuremc/event/Events.kt +++ b/src/main/java/thedarkcolour/futuremc/event/Events.kt @@ -43,6 +43,7 @@ import net.minecraftforge.event.entity.player.PlayerInteractEvent import net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock import net.minecraftforge.event.terraingen.BiomeEvent import net.minecraftforge.fml.client.event.ConfigChangedEvent +import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.gameevent.TickEvent.Phase import net.minecraftforge.fml.common.gameevent.TickEvent.PlayerTickEvent import net.minecraftforge.fml.common.registry.ForgeRegistries @@ -106,7 +107,7 @@ object Events { // addListener(::onGetWaterColor) addListener(::healIronGolem) runOnClient { addListener(::onGuiOpen) } - addListener(::onContainerOpen) + addListener(::onContainerOpen, priority = EventPriority.HIGHEST) runOnClient { addListener(::onModelRegistry) } if (TODO()) addListener(::updateSwimAnimation) @@ -342,14 +343,16 @@ object Events { } private fun onContainerOpen(event: PlayerContainerEvent.Open) { - val container = event.container + if (FConfig.villageAndPillage.newVillagerGui) { + val container = event.container - if (container is ContainerMerchant && container !is ContainerVillager) { - val player = event.entityPlayer as EntityPlayerMP - val newContainer = ContainerVillager(player.inventory, container.merchant, null) + if (container is ContainerMerchant && container !is ContainerVillager) { + val player = event.entityPlayer as EntityPlayerMP + val newContainer = ContainerVillager(player.inventory, container.merchant, null) - newContainer.windowId = container.windowId - player.openContainer = newContainer + newContainer.windowId = container.windowId + player.openContainer = newContainer + } } }