Allow blocks to render in multiple layers

This commit is contained in:
Chicken-Bones 2014-12-26 15:39:12 +10:00
parent 0923c2c2b8
commit 0cbc685d3c
4 changed files with 42 additions and 1 deletions

View file

@ -161,7 +161,7 @@
}
protected ItemStack func_180643_i(IBlockState p_180643_1_)
@@ -971,6 +989,1019 @@
@@ -971,6 +989,1028 @@
return Block.EnumOffsetType.NONE;
}
@ -1153,6 +1153,15 @@
+ return func_176221_a(state, world, pos);
+ }
+
+ /**
+ * Queries if this block should render in a given layer.
+ * ISmartBlockModel can use MinecraftForgeClient.getRenderLayer to alter their model based on layer
+ */
+ public boolean canRenderInLayer(EnumWorldBlockLayer layer)
+ {
+ return func_180664_k() == layer;
+ }
+
+ // For Internal use only to capture droped items inside getDrops
+ protected static ThreadLocal<Boolean> captureDrops = new ThreadLocal<Boolean>()
+ {

View file

@ -9,3 +9,22 @@
{
TileEntity tileentity = regionrendercache.func_175625_s(new BlockPos(mutableblockpos));
@@ -160,7 +160,9 @@
}
}
- EnumWorldBlockLayer enumworldblocklayer1 = block.func_180664_k();
+ for(EnumWorldBlockLayer enumworldblocklayer1 : EnumWorldBlockLayer.values()) {
+ if(!block.canRenderInLayer(enumworldblocklayer1)) continue;
+ net.minecraftforge.client.ForgeHooksClient.setRenderLayer(enumworldblocklayer1);
int i = enumworldblocklayer1.ordinal();
if (block.func_149645_b() != -1)
@@ -178,6 +180,7 @@
compiledchunk.func_178486_a(enumworldblocklayer1);
}
}
+ }
}
EnumWorldBlockLayer[] aenumworldblocklayer = EnumWorldBlockLayer.values();

View file

@ -26,6 +26,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.EnumWorldBlockLayer;
import net.minecraft.util.IRegistry;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.IBlockAccess;
@ -272,6 +273,12 @@ public class ForgeHooksClient
renderPass = pass;
}
static EnumWorldBlockLayer renderLayer = EnumWorldBlockLayer.SOLID;
public static void setRenderLayer(EnumWorldBlockLayer layer)
{
renderLayer = layer;
}
public static ModelBase getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int slotID, ModelBase _default)
{
ModelBase modelbase = itemStack.getItem().getArmorModel(entityLiving, itemStack, slotID);

View file

@ -12,6 +12,7 @@ import com.google.common.collect.Maps;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumWorldBlockLayer;
import net.minecraftforge.client.IItemRenderer.ItemRenderType;
public class MinecraftForgeClient
@ -46,6 +47,11 @@ public class MinecraftForgeClient
return ForgeHooksClient.renderPass;
}
public static EnumWorldBlockLayer getRenderLayer()
{
return ForgeHooksClient.renderLayer;
}
private static BitSet stencilBits = new BitSet(8);
static
{