mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-24 22:24:27 +00:00
Generalize non-terrain block's material ID setting (#1981)
This commit is contained in:
1 parent
6c5eedb7c1
commit
b5dd1c04ce
13 files changed
+514
-40
No files matched your search
@@ -293,8 +293,12 @@ public enum Mixins implements IMixins {
|
||||
, "shaders.MixinLocale"
|
||||
, "shaders.MixinRender"
|
||||
, "shaders.MixinRenderBiped"
|
||||
, "shaders.MixinRenderBlocks_FaceNormals"
|
||||
, "shaders.MixinRenderBlocks_FallingShading"
|
||||
, "shaders.MixinRenderBlocks_ItemId"
|
||||
, "shaders.MixinRenderDragon"
|
||||
, "shaders.MixinRenderEntityFlame"
|
||||
, "shaders.MixinRenderFallingBlock"
|
||||
, "shaders.MixinRendererLivingEntity"
|
||||
, "shaders.MixinRenderGlobal"
|
||||
, "shaders.AccessorEntityHorse"
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
package com.gtnewhorizons.angelica.rendering;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
|
||||
public final class FallingBlockMetaAccess implements IBlockAccess {
|
||||
|
||||
private IBlockAccess delegate;
|
||||
private int x;
|
||||
private int y;
|
||||
private int z;
|
||||
private int metadata;
|
||||
|
||||
public FallingBlockMetaAccess set(IBlockAccess delegate, int x, int y, int z, int metadata) {
|
||||
this.delegate = delegate;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.metadata = metadata;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
this.delegate = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBlockMetadata(int x, int y, int z) {
|
||||
if (x == this.x && y == this.y && z == this.z) {
|
||||
return this.metadata;
|
||||
}
|
||||
return delegate.getBlockMetadata(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block getBlock(int x, int y, int z) {
|
||||
return delegate.getBlock(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getTileEntity(int x, int y, int z) {
|
||||
return delegate.getTileEntity(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightBrightnessForSkyBlocks(int x, int y, int z, int lightValue) {
|
||||
return delegate.getLightBrightnessForSkyBlocks(x, y, z, lightValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int isBlockProvidingPowerTo(int x, int y, int z, int direction) {
|
||||
return delegate.isBlockProvidingPowerTo(x, y, z, direction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAirBlock(int x, int y, int z) {
|
||||
return delegate.isAirBlock(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeGenBase getBiomeGenForCoords(int x, int z) {
|
||||
return delegate.getBiomeGenForCoords(x, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return delegate.getHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean extendedLevelsInChunkCache() {
|
||||
return delegate.extendedLevelsInChunkCache();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSideSolid(int x, int y, int z, ForgeDirection side, boolean _default) {
|
||||
return delegate.isSideSolid(x, y, z, side, _default);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.gtnewhorizons.angelica.rendering;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.TessellatorManager;
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntMap;
|
||||
import it.unimi.dsi.fastutil.objects.Reference2ObjectMap;
|
||||
import net.coderbot.iris.block_rendering.BlockMaterialMapping;
|
||||
import net.coderbot.iris.block_rendering.BlockRenderingSettings;
|
||||
import net.coderbot.iris.gl.shader.ProgramCreator;
|
||||
import net.irisshaders.iris.api.v0.IrisApi;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
public final class FallingBlockRendering {
|
||||
|
||||
public static boolean active;
|
||||
|
||||
private static final FallingBlockMetaAccess META_ACCESS = new FallingBlockMetaAccess();
|
||||
|
||||
private FallingBlockRendering() {
|
||||
}
|
||||
|
||||
public static FallingBlockMetaAccess metaAccess(IBlockAccess world, int x, int y, int z, int metadata) {
|
||||
return META_ACCESS.set(world, x, y, z, metadata);
|
||||
}
|
||||
|
||||
public static void setEntityAttribute(Block block, int metadata) {
|
||||
if (!shadersActive()) return;
|
||||
GLStateManager.glVertexAttrib2s(ProgramCreator.MC_ENTITY, (short) blockMaterialId(block, metadata), (short) 0);
|
||||
}
|
||||
|
||||
public static void resetEntityAttribute() {
|
||||
if (!shadersActive()) return;
|
||||
GLStateManager.glVertexAttrib2s(ProgramCreator.MC_ENTITY, (short) -1, (short) -1);
|
||||
}
|
||||
|
||||
private static int blockMaterialId(Block block, int metadata) {
|
||||
final Reference2ObjectMap<Block, Int2IntMap> blockMetaMatches = BlockRenderingSettings.INSTANCE.getBlockMetaMatches();
|
||||
if (blockMetaMatches == null) return -1;
|
||||
|
||||
final Int2IntMap metaMap = blockMetaMatches.get(block);
|
||||
return metaMap != null ? BlockMaterialMapping.resolveId(metaMap, metadata) : -1;
|
||||
}
|
||||
|
||||
public static boolean isActive() {
|
||||
return active && shadersActive();
|
||||
}
|
||||
|
||||
private static boolean shadersActive() {
|
||||
return TessellatorManager.isOnMainThread() && IrisApi.getInstance().isShaderPackInUse();
|
||||
}
|
||||
|
||||
public static boolean skipDirectionalShading() {
|
||||
return isActive() && BlockRenderingSettings.INSTANCE.shouldDisableDirectionalShading();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user