mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-18 03:25:17 +00:00
Leaf render mode edge case handling
This commit is contained in:
1 parent
986f1bd6a1
commit
d8d8cd93c5
7 files changed
+83
-170
No files matched your search
+8
-15
@@ -1,13 +1,10 @@
|
||||
package com.gtnewhorizons.angelica.mixins.late.notfine.leaves.thaumcraft;
|
||||
|
||||
import jss.notfine.gui.options.named.LeavesQuality;
|
||||
import jss.notfine.util.IFaceObstructionCheckHelper;
|
||||
import jss.notfine.util.ILeafBlock;
|
||||
import jss.notfine.core.Settings;
|
||||
import jss.notfine.core.SettingsManager;
|
||||
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;
|
||||
@@ -16,21 +13,12 @@ import org.spongepowered.asm.mixin.Shadow;
|
||||
import thaumcraft.common.blocks.BlockMagicalLeaves;
|
||||
|
||||
@Mixin(value = BlockMagicalLeaves.class)
|
||||
public abstract class MixinBlockMagicalLeaves extends Block implements ILeafBlock {
|
||||
public abstract class MixinBlockMagicalLeaves extends Block implements IFaceObstructionCheckHelper, ILeafBlock {
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
|
||||
int maskedMeta = world.getBlockMetadata(x, y, z) & 3;
|
||||
int renderMode;
|
||||
if(Settings.MODE_LEAVES.option.getStore() == LeavesQuality.SHELLED_FAST) {
|
||||
renderMode = world.getBlock(
|
||||
x + Facing.offsetsXForSide[side],
|
||||
y + Facing.offsetsYForSide[side],
|
||||
z + Facing.offsetsZForSide[side]
|
||||
) instanceof ILeafBlock ? 1 : 0;
|
||||
} else {
|
||||
renderMode = SettingsManager.leavesOpaque ? 1 : 0;
|
||||
}
|
||||
final int renderMode = LeafRenderUtil.selectRenderMode(world, x, y, z, side) ? 1 : 0;
|
||||
maskedMeta = maskedMeta > 1 ? 0 : maskedMeta;
|
||||
return icon[renderMode + maskedMeta * 2];
|
||||
}
|
||||
@@ -44,6 +32,11 @@ public abstract class MixinBlockMagicalLeaves extends Block implements ILeafBloc
|
||||
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) {
|
||||
return LeafRenderUtil.isFaceNonObstructing(world, x, y, z);
|
||||
}
|
||||
|
||||
private MixinBlockMagicalLeaves(Material material) {
|
||||
super(material);
|
||||
}
|
||||
|
||||
+2
-15
@@ -1,12 +1,8 @@
|
||||
package com.gtnewhorizons.angelica.mixins.late.notfine.leaves.twilightforest;
|
||||
|
||||
import jss.notfine.core.Settings;
|
||||
import jss.notfine.core.SettingsManager;
|
||||
import jss.notfine.gui.options.named.LeavesQuality;
|
||||
import jss.notfine.util.ILeafBlock;
|
||||
import jss.notfine.util.LeafRenderUtil;
|
||||
import net.minecraft.block.BlockLeaves;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.Facing;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@@ -18,16 +14,7 @@ public abstract class MixinBlockTFLeaves extends BlockLeaves {
|
||||
@Override
|
||||
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
|
||||
int maskedMeta = world.getBlockMetadata(x, y, z) & 3;
|
||||
int renderMode;
|
||||
if(Settings.MODE_LEAVES.option.getStore() == LeavesQuality.SHELLED_FAST) {
|
||||
renderMode = world.getBlock(
|
||||
x + Facing.offsetsXForSide[side],
|
||||
y + Facing.offsetsYForSide[side],
|
||||
z + Facing.offsetsZForSide[side]
|
||||
) instanceof ILeafBlock ? 1 : 0;
|
||||
} else {
|
||||
renderMode = SettingsManager.leavesOpaque ? 1 : 0;
|
||||
}
|
||||
int renderMode = LeafRenderUtil.selectRenderMode(world, x, y, z, side) ? 1 : 0;
|
||||
maskedMeta = maskedMeta > 1 ? 0 : maskedMeta;
|
||||
return Blocks.leaves.field_150129_M[renderMode][maskedMeta];
|
||||
}
|
||||
|
||||
+2
-15
@@ -1,12 +1,8 @@
|
||||
package com.gtnewhorizons.angelica.mixins.late.notfine.leaves.twilightforest;
|
||||
|
||||
import jss.notfine.core.Settings;
|
||||
import jss.notfine.core.SettingsManager;
|
||||
import jss.notfine.gui.options.named.LeavesQuality;
|
||||
import jss.notfine.util.ILeafBlock;
|
||||
import jss.notfine.util.LeafRenderUtil;
|
||||
import net.minecraft.block.BlockLeaves;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.Facing;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@@ -17,16 +13,7 @@ public abstract class MixinBlockTFLeaves3 extends BlockLeaves {
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
|
||||
int renderMode;
|
||||
if(Settings.MODE_LEAVES.option.getStore() == LeavesQuality.SHELLED_FAST) {
|
||||
renderMode = world.getBlock(
|
||||
x + Facing.offsetsXForSide[side],
|
||||
y + Facing.offsetsYForSide[side],
|
||||
z + Facing.offsetsZForSide[side]
|
||||
) instanceof ILeafBlock ? 1 : 0;
|
||||
} else {
|
||||
renderMode = SettingsManager.leavesOpaque ? 1 : 0;
|
||||
}
|
||||
final int renderMode = LeafRenderUtil.selectRenderMode(world, x, y, z, side) ? 1 : 0;
|
||||
return Blocks.leaves.field_150129_M[renderMode][0];
|
||||
}
|
||||
|
||||
|
||||
+5
-18
@@ -1,11 +1,7 @@
|
||||
package com.gtnewhorizons.angelica.mixins.late.notfine.leaves.twilightforest;
|
||||
|
||||
import jss.notfine.core.Settings;
|
||||
import jss.notfine.core.SettingsManager;
|
||||
import jss.notfine.gui.options.named.LeavesQuality;
|
||||
import jss.notfine.util.ILeafBlock;
|
||||
import jss.notfine.util.LeafRenderUtil;
|
||||
import net.minecraft.block.BlockLeaves;
|
||||
import net.minecraft.util.Facing;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@@ -17,21 +13,12 @@ public abstract class MixinBlockTFMagicLeaves extends BlockLeaves {
|
||||
@Override
|
||||
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
|
||||
int maskedMeta = world.getBlockMetadata(x, y, z) & 3;
|
||||
int renderMode;
|
||||
if(Settings.MODE_LEAVES.option.getStore() == LeavesQuality.SHELLED_FAST) {
|
||||
renderMode = world.getBlock(
|
||||
x + Facing.offsetsXForSide[side],
|
||||
y + Facing.offsetsYForSide[side],
|
||||
z + Facing.offsetsZForSide[side]
|
||||
) instanceof ILeafBlock ? 1 : 0;
|
||||
} else {
|
||||
renderMode = SettingsManager.leavesOpaque ? 1 : 0;
|
||||
}
|
||||
final boolean renderMode = LeafRenderUtil.selectRenderMode(world, x, y, z, side);
|
||||
maskedMeta = maskedMeta > 1 ? 0 : maskedMeta;
|
||||
return switch (maskedMeta) {
|
||||
case 1 -> renderMode == 1 ? SPR_TRANSLEAVES_OPAQUE : SPR_TRANSLEAVES;
|
||||
case 3 -> renderMode == 1 ? SPR_SORTLEAVES_OPAQUE : SPR_SORTLEAVES;
|
||||
default -> renderMode == 1 ? SPR_TIMELEAVES_OPAQUE : SPR_TIMELEAVES;
|
||||
case 1 -> renderMode ? SPR_TRANSLEAVES_OPAQUE : SPR_TRANSLEAVES;
|
||||
case 3 -> renderMode ? SPR_SORTLEAVES_OPAQUE : SPR_SORTLEAVES;
|
||||
default -> renderMode ? SPR_TIMELEAVES_OPAQUE : SPR_TIMELEAVES;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+2
-14
@@ -1,13 +1,10 @@
|
||||
package com.gtnewhorizons.angelica.mixins.late.notfine.leaves.witchery;
|
||||
|
||||
import com.emoniph.witchery.blocks.BlockWitchLeaves;
|
||||
import jss.notfine.core.Settings;
|
||||
import jss.notfine.core.SettingsManager;
|
||||
import jss.notfine.gui.options.named.LeavesQuality;
|
||||
import jss.notfine.util.ILeafBlock;
|
||||
import jss.notfine.util.LeafRenderUtil;
|
||||
import net.minecraft.block.BlockLeavesBase;
|
||||
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;
|
||||
@@ -29,16 +26,7 @@ public abstract class MixinBlockWitchLeaves extends BlockLeavesBase {
|
||||
@Override
|
||||
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
|
||||
int maskedMeta = world.getBlockMetadata(x, y, z) & 3;
|
||||
int renderMode;
|
||||
if(Settings.MODE_LEAVES.option.getStore() == LeavesQuality.SHELLED_FAST) {
|
||||
renderMode = world.getBlock(
|
||||
x + Facing.offsetsXForSide[side],
|
||||
y + Facing.offsetsYForSide[side],
|
||||
z + Facing.offsetsZForSide[side]
|
||||
) instanceof ILeafBlock ? 1 : 0;
|
||||
} else {
|
||||
renderMode = SettingsManager.leavesOpaque ? 1 : 0;
|
||||
}
|
||||
final int renderMode = LeafRenderUtil.selectRenderMode(world, x, y, z, side) ? 1 : 0;
|
||||
maskedMeta = maskedMeta > 1 ? 0 : maskedMeta;
|
||||
return iconsForModes[renderMode][maskedMeta];
|
||||
}
|
||||
|
||||
@@ -1,43 +1,11 @@
|
||||
package jss.notfine.util;
|
||||
|
||||
import jss.notfine.core.Settings;
|
||||
import jss.notfine.core.SettingsManager;
|
||||
import jss.notfine.gui.options.named.LeavesQuality;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
public interface ILeafBlock extends IFaceObstructionCheckHelper {
|
||||
public interface ILeafBlock {
|
||||
|
||||
@Override()
|
||||
default boolean isFaceNonObstructing(IBlockAccess worldIn, int x, int y, int z, int side, double otherMinX, double otherMinY, double otherMinZ, double otherMaxX, double otherMaxY, double otherMaxZ) {
|
||||
|
||||
if(Settings.MODE_LEAVES.option.getStore() == LeavesQuality.SHELLED_FAST) {
|
||||
Block otherBlock;
|
||||
otherBlock = worldIn.getBlock(x + 1, y, z);
|
||||
if(!(otherBlock instanceof ILeafBlock || otherBlock.isOpaqueCube())) {
|
||||
return true;
|
||||
}
|
||||
otherBlock = worldIn.getBlock(x - 1, y, z);
|
||||
if(!(otherBlock instanceof ILeafBlock || otherBlock.isOpaqueCube())) {
|
||||
return true;
|
||||
}
|
||||
otherBlock = worldIn.getBlock(x, y + 1, z);
|
||||
if(!(otherBlock instanceof ILeafBlock || otherBlock.isOpaqueCube())) {
|
||||
return true;
|
||||
}
|
||||
otherBlock = worldIn.getBlock(x, y - 1, z);
|
||||
if(!(otherBlock instanceof ILeafBlock || otherBlock.isOpaqueCube())) {
|
||||
return true;
|
||||
}
|
||||
otherBlock = worldIn.getBlock(x, y, z + 1);
|
||||
if(!(otherBlock instanceof ILeafBlock || otherBlock.isOpaqueCube())) {
|
||||
return true;
|
||||
}
|
||||
otherBlock = worldIn.getBlock(x, y, z - 1);
|
||||
return !(otherBlock instanceof ILeafBlock || otherBlock.isOpaqueCube());
|
||||
} else {
|
||||
return !SettingsManager.leavesOpaque;
|
||||
}
|
||||
default boolean isFullLeaf(IBlockAccess world, int x, int y, int z) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -25,12 +25,12 @@ public class LeafRenderUtil {
|
||||
5, 4, 1, 0, 3, 2
|
||||
};
|
||||
|
||||
public static boolean shouldSideBeRendered(IBlockAccess worldIn, int x, int y, int z, int side) {
|
||||
Block otherBlock = worldIn.getBlock(x, y, z);
|
||||
public static boolean shouldSideBeRendered(IBlockAccess world, int x, int y, int z, int side) {
|
||||
final Block otherBlock = world.getBlock(x, y, z);
|
||||
if(otherBlock.isOpaqueCube()) {
|
||||
return false;
|
||||
}
|
||||
if(otherBlock instanceof ILeafBlock) {
|
||||
if(otherBlock instanceof ILeafBlock otherLeaf && otherLeaf.isFullLeaf(world, x, y, z)) {
|
||||
switch ((LeavesQuality)Settings.MODE_LEAVES.option.getStore()) {
|
||||
case FAST, SMART -> {
|
||||
return false;
|
||||
@@ -40,76 +40,33 @@ public class LeafRenderUtil {
|
||||
y -= Facing.offsetsYForSide[side];
|
||||
z -= Facing.offsetsZForSide[side];
|
||||
int renderCheck = 0;
|
||||
otherBlock = worldIn.getBlock(x + 1, y, z);
|
||||
if(otherBlock instanceof ILeafBlock || otherBlock.isOpaqueCube()) {
|
||||
renderCheck++;
|
||||
}
|
||||
otherBlock = worldIn.getBlock(x - 1, y, z);
|
||||
if(otherBlock instanceof ILeafBlock || otherBlock.isOpaqueCube()) {
|
||||
renderCheck++;
|
||||
}
|
||||
otherBlock = worldIn.getBlock(x, y + 1, z);
|
||||
if(otherBlock instanceof ILeafBlock || otherBlock.isOpaqueCube()) {
|
||||
renderCheck++;
|
||||
}
|
||||
otherBlock = worldIn.getBlock(x, y - 1, z);
|
||||
if(otherBlock instanceof ILeafBlock || otherBlock.isOpaqueCube()) {
|
||||
renderCheck++;
|
||||
}
|
||||
otherBlock = worldIn.getBlock(x, y, z + 1);
|
||||
if(otherBlock instanceof ILeafBlock || otherBlock.isOpaqueCube()) {
|
||||
renderCheck++;
|
||||
}
|
||||
otherBlock = worldIn.getBlock(x, y, z - 1);
|
||||
if(otherBlock instanceof ILeafBlock || otherBlock.isOpaqueCube()) {
|
||||
renderCheck++;
|
||||
}
|
||||
renderCheck += ignoreWhenCulling(world, x + 1, y, z) ? 0 : 1;
|
||||
renderCheck += ignoreWhenCulling(world, x - 1, y, z) ? 0 : 1;
|
||||
renderCheck += ignoreWhenCulling(world, x, y + 1, z) ? 0 : 1;
|
||||
renderCheck += ignoreWhenCulling(world, x, y - 1, z) ? 0 : 1;
|
||||
renderCheck += ignoreWhenCulling(world, x, y, z + 1) ? 0 : 1;
|
||||
renderCheck += ignoreWhenCulling(world, x, y, z - 1) ? 0 : 1;
|
||||
boolean renderSide = renderCheck == 6;
|
||||
if (renderSide) {
|
||||
x += 2 * Facing.offsetsXForSide[side];
|
||||
y += 2 * Facing.offsetsYForSide[side];
|
||||
z += 2 * Facing.offsetsZForSide[side];
|
||||
otherBlock = worldIn.getBlock(x, y, z);
|
||||
if(otherBlock instanceof ILeafBlock || otherBlock.isOpaqueCube()) {
|
||||
if(!ignoreWhenCulling(world, x, y, z)) {
|
||||
renderSide = false;
|
||||
}
|
||||
x -= Facing.offsetsXForSide[side];
|
||||
y -= Facing.offsetsYForSide[side];
|
||||
z -= Facing.offsetsZForSide[side];
|
||||
int nextSide = relativeADirections[side];
|
||||
otherBlock = worldIn.getBlock(
|
||||
x + Facing.offsetsXForSide[nextSide],
|
||||
y + Facing.offsetsYForSide[nextSide],
|
||||
z + Facing.offsetsZForSide[nextSide]
|
||||
);
|
||||
if(!(otherBlock instanceof ILeafBlock || otherBlock.isOpaqueCube())) {
|
||||
if(ignoreWhenCulling(world, x, y, z, relativeADirections[side])) {
|
||||
return true;
|
||||
}
|
||||
nextSide = relativeBDirections[side];
|
||||
otherBlock = worldIn.getBlock(
|
||||
x + Facing.offsetsXForSide[nextSide],
|
||||
y + Facing.offsetsYForSide[nextSide],
|
||||
z + Facing.offsetsZForSide[nextSide]
|
||||
);
|
||||
if(!(otherBlock instanceof ILeafBlock || otherBlock.isOpaqueCube())) {
|
||||
if(ignoreWhenCulling(world, x, y, z, relativeBDirections[side])) {
|
||||
return true;
|
||||
}
|
||||
nextSide = relativeCDirections[side];
|
||||
otherBlock = worldIn.getBlock(
|
||||
x + Facing.offsetsXForSide[nextSide],
|
||||
y + Facing.offsetsYForSide[nextSide],
|
||||
z + Facing.offsetsZForSide[nextSide]
|
||||
);
|
||||
if(!(otherBlock instanceof ILeafBlock || otherBlock.isOpaqueCube())) {
|
||||
if(ignoreWhenCulling(world, x, y, z, relativeCDirections[side])) {
|
||||
return true;
|
||||
}
|
||||
nextSide = relativeDDirections[side];
|
||||
otherBlock = worldIn.getBlock(
|
||||
x + Facing.offsetsXForSide[nextSide],
|
||||
y + Facing.offsetsYForSide[nextSide],
|
||||
z + Facing.offsetsZForSide[nextSide]
|
||||
);
|
||||
if(!(otherBlock instanceof ILeafBlock || otherBlock.isOpaqueCube())) {
|
||||
if(ignoreWhenCulling(world, x, y, z, relativeDDirections[side])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -122,9 +79,55 @@ public class LeafRenderUtil {
|
||||
}
|
||||
//Check for IFaceObstructionCheckHelper
|
||||
if(otherBlock instanceof IFaceObstructionCheckHelper target) {
|
||||
return target.isFaceNonObstructing(worldIn, x, y, z, side, 0D, 0D, 0D, 1D, 1D, 1D);
|
||||
return target.isFaceNonObstructing(world, x, y, z, side, 0D, 0D, 0D, 1D, 1D, 1D);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean isFaceNonObstructing(IBlockAccess world, int x, int y, int z) {
|
||||
if(Settings.MODE_LEAVES.option.getStore() != LeavesQuality.SHELLED_FAST) {
|
||||
return !SettingsManager.leavesOpaque;
|
||||
}
|
||||
if(ignoreWhenCulling(world, x + 1, y, z)) {
|
||||
return true;
|
||||
}
|
||||
if(ignoreWhenCulling(world, x - 1, y, z)) {
|
||||
return true;
|
||||
}
|
||||
if(ignoreWhenCulling(world, x, y + 1, z)) {
|
||||
return true;
|
||||
}
|
||||
if(ignoreWhenCulling(world, x, y - 1, z)) {
|
||||
return true;
|
||||
}
|
||||
if(ignoreWhenCulling(world, x, y, z + 1)) {
|
||||
return true;
|
||||
}
|
||||
return ignoreWhenCulling(world, x, y, z - 1);
|
||||
}
|
||||
|
||||
public static boolean ignoreWhenCulling(IBlockAccess world, int x, int y, int z) {
|
||||
Block otherBlock = world.getBlock(x, y, z);
|
||||
return !(otherBlock instanceof ILeafBlock leafBlock && leafBlock.isFullLeaf(world, x, y, z) || otherBlock.isOpaqueCube());
|
||||
}
|
||||
|
||||
public static boolean ignoreWhenCulling(IBlockAccess world, int x, int y, int z, int side) {
|
||||
x += Facing.offsetsXForSide[side];
|
||||
y += Facing.offsetsYForSide[side];
|
||||
z += Facing.offsetsZForSide[side];
|
||||
final Block otherBlock = world.getBlock(x, y, z);
|
||||
return !(otherBlock instanceof ILeafBlock leafBlock && leafBlock.isFullLeaf(world, x, y, z) || otherBlock.isOpaqueCube());
|
||||
}
|
||||
|
||||
public static boolean selectRenderMode(IBlockAccess world, int x, int y, int z, int side) {
|
||||
if(Settings.MODE_LEAVES.option.getStore() == LeavesQuality.SHELLED_FAST) {
|
||||
x += Facing.offsetsXForSide[side];
|
||||
y += Facing.offsetsYForSide[side];
|
||||
z += Facing.offsetsZForSide[side];
|
||||
final Block otherBlock = world.getBlock(x, y, z);
|
||||
return otherBlock instanceof ILeafBlock leafBlock && leafBlock.isFullLeaf(world, x, y, z);
|
||||
}
|
||||
return SettingsManager.leavesOpaque;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user