Added config option to disable Forge's fix of Stair/Slab face culling.

Some vanilla resource packs exploit this issue in their custom models causing unintended rendering issues.
This commit is contained in:
LexManos 2016-07-30 10:31:46 -07:00
parent 4694152124
commit 0f6b16cada
8 changed files with 59 additions and 13 deletions

View File

@ -1,12 +1,15 @@
--- ../src-base/minecraft/net/minecraft/block/BlockSlab.java
+++ ../src-work/minecraft/net/minecraft/block/BlockSlab.java
@@ -50,6 +50,16 @@
@@ -50,6 +50,19 @@
return this.func_176552_j();
}
+ @Override
+ public boolean doesSideBlockRendering(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing face)
+ {
+ if (net.minecraftforge.common.ForgeModContainer.disableStairSlabCulling)
+ return super.doesSideBlockRendering(state, world, pos, face);
+
+ if ( state.func_185914_p() )
+ return true;
+
@ -17,7 +20,7 @@
public IBlockState func_180642_a(World p_180642_1_, BlockPos p_180642_2_, EnumFacing p_180642_3_, float p_180642_4_, float p_180642_5_, float p_180642_6_, int p_180642_7_, EntityLivingBase p_180642_8_)
{
IBlockState iblockstate = super.func_180642_a(p_180642_1_, p_180642_2_, p_180642_3_, p_180642_4_, p_180642_5_, p_180642_6_, p_180642_7_, p_180642_8_).func_177226_a(field_176554_a, BlockSlab.EnumBlockHalf.BOTTOM);
@@ -77,13 +87,14 @@
@@ -77,13 +90,14 @@
{
return false;
}

View File

@ -1,12 +1,15 @@
--- ../src-base/minecraft/net/minecraft/block/BlockStairs.java
+++ ../src-work/minecraft/net/minecraft/block/BlockStairs.java
@@ -445,6 +445,17 @@
@@ -445,6 +445,20 @@
return new BlockStateContainer(this, new IProperty[] {field_176309_a, field_176308_b, field_176310_M});
}
+ @Override
+ public boolean doesSideBlockRendering(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing face)
+ {
+ if (net.minecraftforge.common.ForgeModContainer.disableStairSlabCulling)
+ return super.doesSideBlockRendering(state, world, pos, face);
+
+ if ( state.func_185914_p() )
+ return true;
+

View File

@ -72,6 +72,7 @@ import net.minecraftforge.fml.client.FMLFileResourcePack;
import net.minecraftforge.fml.client.FMLFolderResourcePack;
import net.minecraftforge.fml.client.event.ConfigChangedEvent.OnConfigChangedEvent;
import net.minecraftforge.fml.common.DummyModContainer;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.FMLLog;
import net.minecraftforge.fml.common.ICrashCallable;
import net.minecraftforge.fml.common.LoadController;
@ -105,6 +106,7 @@ public class ForgeModContainer extends DummyModContainer implements WorldAccessC
public static boolean forgeLightPipelineEnabled = true;
public static boolean replaceVanillaBucketModel = true;
public static long java8Reminder = 0;
public static boolean disableStairSlabCulling = false; // Also known as the "DontCullStairsBecauseIUseACrappyTexturePackThatBreaksBasicBlockShapesSoICantTrustBasicBlockCulling" flag
private static Configuration config;
private static ForgeModContainer INSTANCE;
@ -285,6 +287,12 @@ public class ForgeModContainer extends DummyModContainer implements WorldAccessC
prop.setLanguageKey("forge.configgui.java8Reminder");
propOrder.add(prop.getName());
prop = config.get(Configuration.CATEGORY_CLIENT, "disableStairSlabCulling", disableStairSlabCulling,
"Disable culling of hidden faces next to stairs and slabs. Causes extra rendering, but may fix some resource packs that exploit this vanilla mechanic.");
disableStairSlabCulling = prop.getBoolean(disableStairSlabCulling);
prop.setLanguageKey("forge.configgui.disableStairSlabCulling").setRequiresMcRestart(false);
propOrder.add(prop.getName());
config.setCategoryPropertyOrder(CATEGORY_CLIENT, propOrder);
if (config.hasChanged())
@ -307,20 +315,32 @@ public class ForgeModContainer extends DummyModContainer implements WorldAccessC
@SubscribeEvent
public void onConfigChanged(OnConfigChangedEvent event)
{
if (getMetadata().modId.equals(event.getModID()) && !event.isWorldRunning())
if (getMetadata().modId.equals(event.getModID()))
{
if (Configuration.CATEGORY_GENERAL.equals(event.getConfigID()))
if (!event.isWorldRunning())
{
syncConfig(false);
if (Configuration.CATEGORY_GENERAL.equals(event.getConfigID()))
{
syncConfig(false);
}
else if ("chunkLoader".equals(event.getConfigID()))
{
ForgeChunkManager.syncConfigDefaults();
ForgeChunkManager.loadConfiguration();
}
else if (VERSION_CHECK_CAT.equals(event.getConfigID()))
{
syncConfig(false);
}
}
else if ("chunkLoader".equals(event.getConfigID()))
else
{
ForgeChunkManager.syncConfigDefaults();
ForgeChunkManager.loadConfiguration();
}
else if (VERSION_CHECK_CAT.equals(event.getConfigID()))
{
syncConfig(false);
boolean tmp = config.get(Configuration.CATEGORY_CLIENT, "disableStairSlabCulling", disableStairSlabCulling).getBoolean();
if (disableStairSlabCulling != tmp)
{
disableStairSlabCulling = tmp;
FMLCommonHandler.instance().reloadRenderers();
}
}
}
}

View File

@ -1032,4 +1032,10 @@ public class FMLClientHandler implements IFMLSidedHandler
// We can't handle many unicode points in the splash renderer
return CharMatcher.anyOf(ALLOWED_CHARS).retainFrom(StringUtils.stripControlCodes(message));
}
@Override
public void reloadRenderers()
{
this.client.renderGlobal.loadRenderers();
}
}

View File

@ -742,4 +742,8 @@ public class FMLCommonHandler
{
return sidedDelegate != null ? sidedDelegate.stripSpecialChars(message) : message;
}
public void reloadRenderers() {
sidedDelegate.reloadRenderers();
}
}

View File

@ -73,4 +73,6 @@ public interface IFMLSidedHandler
void processWindowMessages();
String stripSpecialChars(String message);
void reloadRenderers();
}

View File

@ -328,4 +328,10 @@ public class FMLServerHandler implements IFMLSidedHandler
{
return message;
}
@Override
public void reloadRenderers() {
// NOOP
}
}

View File

@ -47,6 +47,8 @@ forge.configgui.stencilbits=Enable GL Stencil Bits
forge.configgui.replaceBuckets=Use Forge's bucket model
forge.configgui.forgeLightPipelineEnabled=Forge Light Pipeline Enabled
forge.configgui.java8Reminder=Java 8 Reminder timestamp
forge.configgui.disableStairSlabCulling=Disable Stair/Slab culling.
forge.configgui.disableStairSlabCulling.tooltip=Enable this if you see through blocks touching stairs/slabs with your resource pack.
forge.configgui.modID.tooltip=The mod ID that you want to define override settings for.
forge.configgui.modID=Mod ID