mirror of
https://github.com/Eaglercraft-Archive/Eaglercraftx-1.8.8-src.git
synced 2025-06-28 02:48:14 -05:00
Update #48 - Added some features from OptiFine
This commit is contained in:
122
sources/main/java/net/optifine/render/Blender.java
Normal file
122
sources/main/java/net/optifine/render/Blender.java
Normal file
@ -0,0 +1,122 @@
|
||||
package net.optifine.render;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager;
|
||||
import net.optifine.Config;
|
||||
|
||||
public class Blender {
|
||||
public static final int BLEND_ALPHA = 0;
|
||||
public static final int BLEND_ADD = 1;
|
||||
public static final int BLEND_SUBSTRACT = 2;
|
||||
public static final int BLEND_MULTIPLY = 3;
|
||||
public static final int BLEND_DODGE = 4;
|
||||
public static final int BLEND_BURN = 5;
|
||||
public static final int BLEND_SCREEN = 6;
|
||||
public static final int BLEND_OVERLAY = 7;
|
||||
public static final int BLEND_REPLACE = 8;
|
||||
public static final int BLEND_DEFAULT = 1;
|
||||
|
||||
public static int parseBlend(String str) {
|
||||
if (str == null) {
|
||||
return 1;
|
||||
} else {
|
||||
str = str.toLowerCase().trim();
|
||||
|
||||
if (str.equals("alpha")) {
|
||||
return 0;
|
||||
} else if (str.equals("add")) {
|
||||
return 1;
|
||||
} else if (str.equals("subtract")) {
|
||||
return 2;
|
||||
} else if (str.equals("multiply")) {
|
||||
return 3;
|
||||
} else if (str.equals("dodge")) {
|
||||
return 4;
|
||||
} else if (str.equals("burn")) {
|
||||
return 5;
|
||||
} else if (str.equals("screen")) {
|
||||
return 6;
|
||||
} else if (str.equals("overlay")) {
|
||||
return 7;
|
||||
} else if (str.equals("replace")) {
|
||||
return 8;
|
||||
} else {
|
||||
Config.warn("Unknown blend: " + str);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void setupBlend(int blend, float brightness) {
|
||||
switch (blend) {
|
||||
case 0:
|
||||
GlStateManager.disableAlpha();
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.blendFunc(770, 771);
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F, brightness);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
GlStateManager.disableAlpha();
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.blendFunc(770, 1);
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F, brightness);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
GlStateManager.disableAlpha();
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.blendFunc(775, 0);
|
||||
GlStateManager.color(brightness, brightness, brightness, 1.0F);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
GlStateManager.disableAlpha();
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.blendFunc(774, 771);
|
||||
GlStateManager.color(brightness, brightness, brightness, brightness);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
GlStateManager.disableAlpha();
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.blendFunc(1, 1);
|
||||
GlStateManager.color(brightness, brightness, brightness, 1.0F);
|
||||
break;
|
||||
|
||||
case 5:
|
||||
GlStateManager.disableAlpha();
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.blendFunc(0, 769);
|
||||
GlStateManager.color(brightness, brightness, brightness, 1.0F);
|
||||
break;
|
||||
|
||||
case 6:
|
||||
GlStateManager.disableAlpha();
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.blendFunc(1, 769);
|
||||
GlStateManager.color(brightness, brightness, brightness, 1.0F);
|
||||
break;
|
||||
|
||||
case 7:
|
||||
GlStateManager.disableAlpha();
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.blendFunc(774, 768);
|
||||
GlStateManager.color(brightness, brightness, brightness, 1.0F);
|
||||
break;
|
||||
|
||||
case 8:
|
||||
GlStateManager.enableAlpha();
|
||||
GlStateManager.disableBlend();
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F, brightness);
|
||||
}
|
||||
|
||||
GlStateManager.enableTexture2D();
|
||||
}
|
||||
|
||||
public static void clearBlend(float rainBrightness) {
|
||||
GlStateManager.disableAlpha();
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.blendFunc(770, 1);
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F, rainBrightness);
|
||||
}
|
||||
}
|
265
sources/main/java/net/optifine/render/RenderEnv.java
Normal file
265
sources/main/java/net/optifine/render/RenderEnv.java
Normal file
@ -0,0 +1,265 @@
|
||||
package net.optifine.render;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.BitSet;
|
||||
import java.util.List;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockLeaves;
|
||||
import net.minecraft.block.state.BlockStateBase;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.BlockModelRenderer;
|
||||
import net.minecraft.client.renderer.RegionRenderCacheBuilder;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.BreakingFour;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumWorldBlockLayer;
|
||||
import net.optifine.Config;
|
||||
import net.optifine.model.ListQuadsOverlay;
|
||||
|
||||
public class RenderEnv {
|
||||
private IBlockState blockState;
|
||||
private BlockPos blockPos;
|
||||
private int blockId = -1;
|
||||
private int metadata = -1;
|
||||
private int breakingAnimation = -1;
|
||||
private int smartLeaves = -1;
|
||||
private float[] quadBounds = new float[EnumFacing._VALUES.length * 2];
|
||||
private BitSet boundsFlags = new BitSet(3);
|
||||
private BlockModelRenderer.AmbientOcclusionFace aoFace = new BlockModelRenderer.AmbientOcclusionFace();
|
||||
private BlockPos colorizerBlockPosM = null;
|
||||
private boolean[] borderFlags = null;
|
||||
private boolean[] borderFlags2 = null;
|
||||
private boolean[] borderFlags3 = null;
|
||||
private EnumFacing[] borderDirections = null;
|
||||
private List<BakedQuad> listQuadsCustomizer = new ArrayList();
|
||||
private List<BakedQuad> listQuadsCtmMultipass = new ArrayList();
|
||||
private BakedQuad[] arrayQuadsCtm1 = new BakedQuad[1];
|
||||
private BakedQuad[] arrayQuadsCtm2 = new BakedQuad[2];
|
||||
private BakedQuad[] arrayQuadsCtm3 = new BakedQuad[3];
|
||||
private BakedQuad[] arrayQuadsCtm4 = new BakedQuad[4];
|
||||
private RegionRenderCacheBuilder regionRenderCacheBuilder = null;
|
||||
private ListQuadsOverlay[] listsQuadsOverlay = new ListQuadsOverlay[EnumWorldBlockLayer.values().length];
|
||||
private boolean overlaysRendered = false;
|
||||
private static final int UNKNOWN = -1;
|
||||
private static final int FALSE = 0;
|
||||
private static final int TRUE = 1;
|
||||
|
||||
public RenderEnv(IBlockState blockState, BlockPos blockPos) {
|
||||
this.blockState = blockState;
|
||||
this.blockPos = blockPos;
|
||||
}
|
||||
|
||||
public void reset(IBlockState blockStateIn, BlockPos blockPosIn) {
|
||||
if (this.blockState != blockStateIn || this.blockPos != blockPosIn) {
|
||||
this.blockState = blockStateIn;
|
||||
this.blockPos = blockPosIn;
|
||||
this.blockId = -1;
|
||||
this.metadata = -1;
|
||||
this.breakingAnimation = -1;
|
||||
this.smartLeaves = -1;
|
||||
this.boundsFlags.clear();
|
||||
}
|
||||
}
|
||||
|
||||
public int getBlockId() {
|
||||
if (this.blockId < 0) {
|
||||
if (this.blockState instanceof BlockStateBase) {
|
||||
BlockStateBase blockstatebase = (BlockStateBase) this.blockState;
|
||||
this.blockId = blockstatebase.getBlockId();
|
||||
} else {
|
||||
this.blockId = Block.getIdFromBlock(this.blockState.getBlock());
|
||||
}
|
||||
}
|
||||
|
||||
return this.blockId;
|
||||
}
|
||||
|
||||
public int getMetadata() {
|
||||
if (this.metadata < 0) {
|
||||
if (this.blockState instanceof BlockStateBase) {
|
||||
BlockStateBase blockstatebase = (BlockStateBase) this.blockState;
|
||||
this.metadata = blockstatebase.getMetadata();
|
||||
} else {
|
||||
this.metadata = this.blockState.getBlock().getMetaFromState(this.blockState);
|
||||
}
|
||||
}
|
||||
|
||||
return this.metadata;
|
||||
}
|
||||
|
||||
public float[] getQuadBounds() {
|
||||
return this.quadBounds;
|
||||
}
|
||||
|
||||
public BitSet getBoundsFlags() {
|
||||
return this.boundsFlags;
|
||||
}
|
||||
|
||||
public BlockModelRenderer.AmbientOcclusionFace getAoFace() {
|
||||
return this.aoFace;
|
||||
}
|
||||
|
||||
public boolean isBreakingAnimation(List listQuads) {
|
||||
if (this.breakingAnimation == -1 && listQuads.size() > 0) {
|
||||
if (listQuads.get(0) instanceof BreakingFour) {
|
||||
this.breakingAnimation = 1;
|
||||
} else {
|
||||
this.breakingAnimation = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return this.breakingAnimation == 1;
|
||||
}
|
||||
|
||||
public boolean isBreakingAnimation(BakedQuad quad) {
|
||||
if (this.breakingAnimation < 0) {
|
||||
if (quad instanceof BreakingFour) {
|
||||
this.breakingAnimation = 1;
|
||||
} else {
|
||||
this.breakingAnimation = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return this.breakingAnimation == 1;
|
||||
}
|
||||
|
||||
public boolean isBreakingAnimation() {
|
||||
return this.breakingAnimation == 1;
|
||||
}
|
||||
|
||||
public IBlockState getBlockState() {
|
||||
return this.blockState;
|
||||
}
|
||||
|
||||
public BlockPos getColorizerBlockPosM() {
|
||||
if (this.colorizerBlockPosM == null) {
|
||||
this.colorizerBlockPosM = new BlockPos(0, 0, 0);
|
||||
}
|
||||
|
||||
return this.colorizerBlockPosM;
|
||||
}
|
||||
|
||||
public boolean[] getBorderFlags() {
|
||||
if (this.borderFlags == null) {
|
||||
this.borderFlags = new boolean[4];
|
||||
}
|
||||
|
||||
return this.borderFlags;
|
||||
}
|
||||
|
||||
public boolean[] getBorderFlags2() {
|
||||
if (this.borderFlags2 == null) {
|
||||
this.borderFlags2 = new boolean[4];
|
||||
}
|
||||
|
||||
return this.borderFlags2;
|
||||
}
|
||||
|
||||
public boolean[] getBorderFlags3() {
|
||||
if (this.borderFlags3 == null) {
|
||||
this.borderFlags3 = new boolean[4];
|
||||
}
|
||||
|
||||
return this.borderFlags3;
|
||||
}
|
||||
|
||||
public EnumFacing[] getBorderDirections() {
|
||||
if (this.borderDirections == null) {
|
||||
this.borderDirections = new EnumFacing[4];
|
||||
}
|
||||
|
||||
return this.borderDirections;
|
||||
}
|
||||
|
||||
public EnumFacing[] getBorderDirections(EnumFacing dir0, EnumFacing dir1, EnumFacing dir2, EnumFacing dir3) {
|
||||
EnumFacing[] aenumfacing = this.getBorderDirections();
|
||||
aenumfacing[0] = dir0;
|
||||
aenumfacing[1] = dir1;
|
||||
aenumfacing[2] = dir2;
|
||||
aenumfacing[3] = dir3;
|
||||
return aenumfacing;
|
||||
}
|
||||
|
||||
public boolean isSmartLeaves() {
|
||||
if (this.smartLeaves == -1) {
|
||||
if (Config.isTreesSmart() && this.blockState.getBlock() instanceof BlockLeaves) {
|
||||
this.smartLeaves = 1;
|
||||
} else {
|
||||
this.smartLeaves = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return this.smartLeaves == 1;
|
||||
}
|
||||
|
||||
public List<BakedQuad> getListQuadsCustomizer() {
|
||||
return this.listQuadsCustomizer;
|
||||
}
|
||||
|
||||
public BakedQuad[] getArrayQuadsCtm(BakedQuad quad) {
|
||||
this.arrayQuadsCtm1[0] = quad;
|
||||
return this.arrayQuadsCtm1;
|
||||
}
|
||||
|
||||
public BakedQuad[] getArrayQuadsCtm(BakedQuad quad0, BakedQuad quad1) {
|
||||
this.arrayQuadsCtm2[0] = quad0;
|
||||
this.arrayQuadsCtm2[1] = quad1;
|
||||
return this.arrayQuadsCtm2;
|
||||
}
|
||||
|
||||
public BakedQuad[] getArrayQuadsCtm(BakedQuad quad0, BakedQuad quad1, BakedQuad quad2) {
|
||||
this.arrayQuadsCtm3[0] = quad0;
|
||||
this.arrayQuadsCtm3[1] = quad1;
|
||||
this.arrayQuadsCtm3[2] = quad2;
|
||||
return this.arrayQuadsCtm3;
|
||||
}
|
||||
|
||||
public BakedQuad[] getArrayQuadsCtm(BakedQuad quad0, BakedQuad quad1, BakedQuad quad2, BakedQuad quad3) {
|
||||
this.arrayQuadsCtm4[0] = quad0;
|
||||
this.arrayQuadsCtm4[1] = quad1;
|
||||
this.arrayQuadsCtm4[2] = quad2;
|
||||
this.arrayQuadsCtm4[3] = quad3;
|
||||
return this.arrayQuadsCtm4;
|
||||
}
|
||||
|
||||
public List<BakedQuad> getListQuadsCtmMultipass(BakedQuad[] quads) {
|
||||
this.listQuadsCtmMultipass.clear();
|
||||
|
||||
if (quads != null) {
|
||||
for (int i = 0; i < quads.length; ++i) {
|
||||
BakedQuad bakedquad = quads[i];
|
||||
this.listQuadsCtmMultipass.add(bakedquad);
|
||||
}
|
||||
}
|
||||
|
||||
return this.listQuadsCtmMultipass;
|
||||
}
|
||||
|
||||
public RegionRenderCacheBuilder getRegionRenderCacheBuilder() {
|
||||
return this.regionRenderCacheBuilder;
|
||||
}
|
||||
|
||||
public void setRegionRenderCacheBuilder(RegionRenderCacheBuilder regionRenderCacheBuilder) {
|
||||
this.regionRenderCacheBuilder = regionRenderCacheBuilder;
|
||||
}
|
||||
|
||||
public ListQuadsOverlay getListQuadsOverlay(EnumWorldBlockLayer layer) {
|
||||
ListQuadsOverlay listquadsoverlay = this.listsQuadsOverlay[layer.ordinal()];
|
||||
|
||||
if (listquadsoverlay == null) {
|
||||
listquadsoverlay = new ListQuadsOverlay();
|
||||
this.listsQuadsOverlay[layer.ordinal()] = listquadsoverlay;
|
||||
}
|
||||
|
||||
return listquadsoverlay;
|
||||
}
|
||||
|
||||
public boolean isOverlaysRendered() {
|
||||
return this.overlaysRendered;
|
||||
}
|
||||
|
||||
public void setOverlaysRendered(boolean overlaysRendered) {
|
||||
this.overlaysRendered = overlaysRendered;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user