From 894b9573db6a9ee48a2c70f288ab2191f01efa31 Mon Sep 17 00:00:00 2001 From: jss2a98aj Date: Sun, 5 May 2024 14:31:49 -0400 Subject: [PATCH] Natura + Tinker's Construct berry bush leaf mode support --- dependencies.gradle | 2 + .../gtnewhorizons/angelica/mixins/Mixins.java | 15 ++++ .../angelica/mixins/TargetedMod.java | 2 + .../notfine/leaves/natura/MixinBerryBush.java | 78 +++++++++++++++++++ .../leaves/natura/MixinNetherBerryBush.java | 78 +++++++++++++++++++ .../leaves/tconstruct/MixinOreberryBush.java | 78 +++++++++++++++++++ 6 files changed, 253 insertions(+) create mode 100644 src/main/java/com/gtnewhorizons/angelica/mixins/late/notfine/leaves/natura/MixinBerryBush.java create mode 100644 src/main/java/com/gtnewhorizons/angelica/mixins/late/notfine/leaves/natura/MixinNetherBerryBush.java create mode 100644 src/main/java/com/gtnewhorizons/angelica/mixins/late/notfine/leaves/tconstruct/MixinOreberryBush.java diff --git a/dependencies.gradle b/dependencies.gradle index dbe959fa5..13ea4929e 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -75,6 +75,8 @@ dependencies { runtimeOnlyNonPublishable("com.github.GTNewHorizons:Baubles:1.0.4:dev") compileOnly("com.github.GTNewHorizons:twilightforest:2.5.16:dev") { transitive = false } compileOnly(rfg.deobf('curse.maven:witchery-69673:2234410')) + compileOnly("com.github.GTNewHorizons:TinkersConstruct:1.12.0-GTNH:dev") + compileOnly("com.github.GTNewHorizons:Natura:2.6.1:dev") compileOnly("com.falsepattern:chunkapi-mc1.7.10:0.5.0:api") { transitive = false } compileOnly("com.falsepattern:endlessids-mc1.7.10:1.5-beta0002:dev") { transitive = false } diff --git a/src/main/java/com/gtnewhorizons/angelica/mixins/Mixins.java b/src/main/java/com/gtnewhorizons/angelica/mixins/Mixins.java index 695686b11..bc333201d 100644 --- a/src/main/java/com/gtnewhorizons/angelica/mixins/Mixins.java +++ b/src/main/java/com/gtnewhorizons/angelica/mixins/Mixins.java @@ -271,6 +271,15 @@ public enum Mixins { "MixinRenderItem" )) ), + NOTFINE_NATURA(new Builder("NotFine Natura compat") + .setSide(Side.CLIENT).setPhase(Phase.LATE) + .setApplyIf(() -> AngelicaConfig.enableNotFineFeatures) + .addTargetedMod(TargetedMod.NATURA) + .addMixinClasses(addPrefix("notfine.leaves.natura.", + "MixinBerryBush", + "MixinNetherBerryBush" + )) + ), NOTFINE_THAUMCRAFT(new Builder("NotFine Thaumcraft compat") .setSide(Side.CLIENT).setPhase(Phase.LATE) .setApplyIf(() -> AngelicaConfig.enableNotFineFeatures) @@ -287,6 +296,12 @@ public enum Mixins { "MixinBlockTable" )) ), + NOTFINE_TINKERS_CONSTRUCT(new Builder("NotFine Tinker's Construct compat") + .setSide(Side.CLIENT).setPhase(Phase.LATE) + .setApplyIf(() -> AngelicaConfig.enableNotFineFeatures) + .addTargetedMod(TargetedMod.TINKERS_CONSTRUCT) + .addMixinClasses("notfine.leaves.tconstruct.MixinOreberryBush") + ), NOTFINE_WITCHERY(new Builder("NotFine Witchery compat") .setSide(Side.CLIENT).setPhase(Phase.LATE) .setApplyIf(() -> AngelicaConfig.enableNotFineFeatures) diff --git a/src/main/java/com/gtnewhorizons/angelica/mixins/TargetedMod.java b/src/main/java/com/gtnewhorizons/angelica/mixins/TargetedMod.java index b7f4156be..ead8ec37d 100644 --- a/src/main/java/com/gtnewhorizons/angelica/mixins/TargetedMod.java +++ b/src/main/java/com/gtnewhorizons/angelica/mixins/TargetedMod.java @@ -21,9 +21,11 @@ public enum TargetedMod { , JOURNEYMAP("JourneyMap", null, "journeymap") , LWJGL3IFY("lwjgl3ify", "me.eigenraven.lwjgl3ify.core.Lwjgl3ifyCoremod", "lwjgl3ify") , MRTJPCORE("MrTJPCore", null, "MrTJPCoreMod") + , NATURA("Natura", null, "Natura") , PROJECTRED_ILLUMINATION("ProjectRed Illumination", null, "ProjRed|Illumination") , SMART_RENDER("Smart Render", null, "SmartRender") , THAUMCRAFT("Thaumcraft", null, "Thaumcraft") + , TINKERS_CONSTRUCT("Tinker's Construct", null, "TConstruct") , TWILIGHT_FOREST("TwilightForest", null, "TwilightForest") , WITCHERY("Witchery", null, "witchery") ; diff --git a/src/main/java/com/gtnewhorizons/angelica/mixins/late/notfine/leaves/natura/MixinBerryBush.java b/src/main/java/com/gtnewhorizons/angelica/mixins/late/notfine/leaves/natura/MixinBerryBush.java new file mode 100644 index 000000000..f01f4625a --- /dev/null +++ b/src/main/java/com/gtnewhorizons/angelica/mixins/late/notfine/leaves/natura/MixinBerryBush.java @@ -0,0 +1,78 @@ +package com.gtnewhorizons.angelica.mixins.late.notfine.leaves.natura; + +import jss.notfine.core.Settings; +import jss.notfine.core.SettingsManager; +import jss.notfine.gui.options.named.LeavesQuality; +import jss.notfine.util.IFaceObstructionCheckHelper; +import jss.notfine.util.ILeafBlock; +import jss.notfine.util.LeafRenderUtil; +import mods.natura.blocks.crops.BerryBush; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.util.Facing; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Overwrite; +import org.spongepowered.asm.mixin.Shadow; + +@Mixin(value = BerryBush.class) +public abstract class MixinBerryBush extends Block implements IFaceObstructionCheckHelper, ILeafBlock { + + @Override + public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { + final int metadata = world.getBlockMetadata(x, y, z); + int maskedMeta = metadata % 4 + (metadata < 12 ? 0 : 4); + boolean renderMode; + if(Settings.MODE_LEAVES.option.getStore() == LeavesQuality.SHELLED_FAST) { + if(metadata < 8) { + renderMode = false; + } else { + x += Facing.offsetsXForSide[side]; + y += Facing.offsetsYForSide[side]; + z += Facing.offsetsZForSide[side]; + final Block otherBlock = world.getBlock(x, y, z); + renderMode = otherBlock instanceof ILeafBlock leafBlock && leafBlock.isFullLeaf(world, x, y, z); + } + } else { + renderMode = SettingsManager.leavesOpaque; + } + maskedMeta = maskedMeta >= (renderMode ? fastIcons : fancyIcons).length ? 0 : maskedMeta; + return (renderMode ? fastIcons : fancyIcons)[maskedMeta]; + } + + /** + * @author jss2a98aj + * @reason Support new leaf rendering modes on Natura leaves. + */ + @Overwrite + public boolean shouldSideBeRendered(IBlockAccess world, int x, int y, int z, int side) { + if (side != 0 && maxY < 1f) { + return true; + } + return LeafRenderUtil.shouldSideBeRendered(world, x, y, z, side); + } + + @Override + public boolean isFaceNonObstructing(IBlockAccess world, int x, int y, int z, int side, double otherMinX, double otherMinY, double otherMinZ, double otherMaxX, double otherMaxY, double otherMaxZ) { + if(world.getBlockMetadata(x ,y, z) < 8) { + return true; + } + return LeafRenderUtil.isFaceNonObstructing(world, x, y, z); + } + + @Override + public boolean isFullLeaf(IBlockAccess world, int x, int y, int z) { + return world.getBlockMetadata(x ,y, z) >= 8; + } + + @Shadow(remap = false) + public IIcon[] fastIcons; + @Shadow(remap = false) + public IIcon[] fancyIcons; + + private MixinBerryBush(Material materialIn) { + super(materialIn); + } + +} diff --git a/src/main/java/com/gtnewhorizons/angelica/mixins/late/notfine/leaves/natura/MixinNetherBerryBush.java b/src/main/java/com/gtnewhorizons/angelica/mixins/late/notfine/leaves/natura/MixinNetherBerryBush.java new file mode 100644 index 000000000..ea99041c8 --- /dev/null +++ b/src/main/java/com/gtnewhorizons/angelica/mixins/late/notfine/leaves/natura/MixinNetherBerryBush.java @@ -0,0 +1,78 @@ +package com.gtnewhorizons.angelica.mixins.late.notfine.leaves.natura; + +import jss.notfine.core.Settings; +import jss.notfine.core.SettingsManager; +import jss.notfine.gui.options.named.LeavesQuality; +import jss.notfine.util.IFaceObstructionCheckHelper; +import jss.notfine.util.ILeafBlock; +import jss.notfine.util.LeafRenderUtil; +import mods.natura.blocks.crops.NetherBerryBush; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.util.Facing; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Overwrite; +import org.spongepowered.asm.mixin.Shadow; + +@Mixin(value = NetherBerryBush.class) +public abstract class MixinNetherBerryBush extends Block implements IFaceObstructionCheckHelper, ILeafBlock { + + @Override + public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { + final int metadata = world.getBlockMetadata(x, y, z); + int maskedMeta = metadata % 4 + (metadata < 12 ? 0 : 4); + boolean renderMode; + if(Settings.MODE_LEAVES.option.getStore() == LeavesQuality.SHELLED_FAST) { + if(metadata < 8) { + renderMode = false; + } else { + x += Facing.offsetsXForSide[side]; + y += Facing.offsetsYForSide[side]; + z += Facing.offsetsZForSide[side]; + final Block otherBlock = world.getBlock(x, y, z); + renderMode = otherBlock instanceof ILeafBlock leafBlock && leafBlock.isFullLeaf(world, x, y, z); + } + } else { + renderMode = SettingsManager.leavesOpaque; + } + maskedMeta = maskedMeta >= (renderMode ? fastIcons : fancyIcons).length ? 0 : maskedMeta; + return (renderMode ? fastIcons : fancyIcons)[maskedMeta]; + } + + /** + * @author jss2a98aj + * @reason Support new leaf rendering modes on Natura leaves. + */ + @Overwrite + public boolean shouldSideBeRendered(IBlockAccess world, int x, int y, int z, int side) { + if (side != 0 && maxY < 1f) { + return true; + } + return LeafRenderUtil.shouldSideBeRendered(world, x, y, z, side); + } + + @Override + public boolean isFaceNonObstructing(IBlockAccess world, int x, int y, int z, int side, double otherMinX, double otherMinY, double otherMinZ, double otherMaxX, double otherMaxY, double otherMaxZ) { + if(world.getBlockMetadata(x ,y, z) < 8) { + return true; + } + return LeafRenderUtil.isFaceNonObstructing(world, x, y, z); + } + + @Override + public boolean isFullLeaf(IBlockAccess world, int x, int y, int z) { + return world.getBlockMetadata(x ,y, z) >= 8; + } + + @Shadow(remap = false) + public IIcon[] fastIcons; + @Shadow(remap = false) + public IIcon[] fancyIcons; + + private MixinNetherBerryBush(Material materialIn) { + super(materialIn); + } + +} diff --git a/src/main/java/com/gtnewhorizons/angelica/mixins/late/notfine/leaves/tconstruct/MixinOreberryBush.java b/src/main/java/com/gtnewhorizons/angelica/mixins/late/notfine/leaves/tconstruct/MixinOreberryBush.java new file mode 100644 index 000000000..19787a8fe --- /dev/null +++ b/src/main/java/com/gtnewhorizons/angelica/mixins/late/notfine/leaves/tconstruct/MixinOreberryBush.java @@ -0,0 +1,78 @@ +package com.gtnewhorizons.angelica.mixins.late.notfine.leaves.tconstruct; + +import jss.notfine.core.Settings; +import jss.notfine.core.SettingsManager; +import jss.notfine.gui.options.named.LeavesQuality; +import jss.notfine.util.IFaceObstructionCheckHelper; +import jss.notfine.util.ILeafBlock; +import jss.notfine.util.LeafRenderUtil; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.util.Facing; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Overwrite; +import org.spongepowered.asm.mixin.Shadow; +import tconstruct.world.blocks.OreberryBush; + +@Mixin(value = OreberryBush.class) +public abstract class MixinOreberryBush extends Block implements IFaceObstructionCheckHelper, ILeafBlock { + + @Override + public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { + final int metadata = world.getBlockMetadata(x, y, z); + int maskedMeta = metadata % 4 + (metadata < 12 ? 0 : 4); + boolean renderMode; + if(Settings.MODE_LEAVES.option.getStore() == LeavesQuality.SHELLED_FAST) { + if(metadata < 8) { + renderMode = false; + } else { + x += Facing.offsetsXForSide[side]; + y += Facing.offsetsYForSide[side]; + z += Facing.offsetsZForSide[side]; + final Block otherBlock = world.getBlock(x, y, z); + renderMode = otherBlock instanceof ILeafBlock leafBlock && leafBlock.isFullLeaf(world, x, y, z); + } + } else { + renderMode = SettingsManager.leavesOpaque; + } + maskedMeta = maskedMeta >= (renderMode ? fastIcons : fancyIcons).length ? 0 : maskedMeta; + return (renderMode ? fastIcons : fancyIcons)[maskedMeta]; + } + + /** + * @author jss2a98aj + * @reason Support new leaf rendering modes on Tinker's Construct leaves. + */ + @Overwrite + public boolean shouldSideBeRendered(IBlockAccess world, int x, int y, int z, int side) { + if (side != 0 && maxY < 1f) { + return true; + } + return LeafRenderUtil.shouldSideBeRendered(world, x, y, z, side); + } + + @Override + public boolean isFaceNonObstructing(IBlockAccess world, int x, int y, int z, int side, double otherMinX, double otherMinY, double otherMinZ, double otherMaxX, double otherMaxY, double otherMaxZ) { + if(world.getBlockMetadata(x ,y, z) < 8) { + return true; + } + return LeafRenderUtil.isFaceNonObstructing(world, x, y, z); + } + + @Override + public boolean isFullLeaf(IBlockAccess world, int x, int y, int z) { + return world.getBlockMetadata(x ,y, z) >= 8; + } + + @Shadow(remap = false) + public IIcon[] fastIcons; + @Shadow(remap = false) + public IIcon[] fancyIcons; + + private MixinOreberryBush(Material material) { + super(material); + } + +}