Skip to content

Commit

Permalink
Alpha Support
Browse files Browse the repository at this point in the history
  • Loading branch information
Direwolf20-MC committed Feb 24, 2024
1 parent 230312c commit 012cfec
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.direwolf20.justdirethings.client.renderers.DireVertexConsumerSquished;
import com.direwolf20.justdirethings.client.renderers.OurRenderTypes;
import com.direwolf20.justdirethings.common.blockentities.gooblocks.GooBlockBE_Base;
import com.direwolf20.justdirethings.setup.Registration;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import net.minecraft.client.Minecraft;
Expand All @@ -23,7 +24,6 @@
import net.minecraft.util.Mth;
import net.minecraft.util.RandomSource;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.neoforged.neoforge.client.model.data.ModelData;
import org.joml.Matrix3f;
Expand All @@ -41,7 +41,8 @@ public GooBlockRender_Base(BlockEntityRendererProvider.Context p_173636_) {
public void render(T blockentity, float partialTicks, PoseStack matrixStackIn, MultiBufferSource bufferIn, int combinedLightsIn, int combinedOverlayIn) {
Level level = blockentity.getLevel();
BlockPos pos = blockentity.getBlockPos().above(0);
BlockState renderState = Blocks.FURNACE.defaultBlockState();
//BlockState renderState = Blocks.FURNACE.defaultBlockState();
BlockState renderState = Registration.GooBlock_Tier1.get().defaultBlockState();
BlockRenderDispatcher blockrendererdispatcher = Minecraft.getInstance().getBlockRenderer();
BakedModel ibakedmodel = blockrendererdispatcher.getBlockModel(renderState);
BlockColors blockColors = Minecraft.getInstance().getBlockColors();
Expand Down Expand Up @@ -95,7 +96,7 @@ public void renderTexturePattern(Level level, BlockPos pos, PoseStack matrixStac
VertexConsumer vertexconsumer = bufferIn.getBuffer(OurRenderTypes.dragonExplosionAlpha(DRAGON_EXPLODING_LOCATION));

matrixStackIn.pushPose();
matrixStackIn.translate(0, 0, -0.003f);
matrixStackIn.translate(0, 0, -0.0003f);

PoseStack.Pose posestack$pose = matrixStackIn.last();
Matrix4f matrix4f = posestack$pose.pose();
Expand All @@ -121,7 +122,7 @@ public void renderTexturePattern(Level level, BlockPos pos, PoseStack matrixStac
1
);
matrixStackIn.popPose();
matrixStackIn.translate(0, 0, -0.002f);
matrixStackIn.translate(0, 0, -0.0002f);

float[] afloat = new float[Direction.values().length * 2];
BitSet bitset = new BitSet(3);
Expand All @@ -133,7 +134,7 @@ public void renderTexturePattern(Level level, BlockPos pos, PoseStack matrixStac
Direction direction = Direction.NORTH;

VertexConsumer builder = bufferIn.getBuffer(OurRenderTypes.RenderBlockBackface);
DireVertexConsumerSquished chunksConsumer = new DireVertexConsumerSquished(builder, 0, 0, 0, 1, 1, 1, matrixStackIn.last().pose());
DireVertexConsumerSquished chunksConsumer = new DireVertexConsumerSquished(builder, 0, 0, 0, 1, 1, 1, matrixStackIn.last().pose(), 1f, 1f, 1f, 0.5f);

chunksConsumer.adjustUV = adjustUV;
chunksConsumer.bottomUp = bottomUp;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class DireVertexConsumerSquished extends VertexConsumerWrapper {
private float red = -1;
private float green = -1;
private float blue = -1;
private float alpha = -1;

public DireVertexConsumerSquished(VertexConsumer parent, float minX, float minY, float minZ, float maxX, float maxY, float maxZ, Matrix4f matrix4f) {
super(parent);
Expand All @@ -34,7 +35,7 @@ public DireVertexConsumerSquished(VertexConsumer parent, float minX, float minY,
this.matrix4f = matrix4f;
}

public DireVertexConsumerSquished(VertexConsumer parent, float minX, float minY, float minZ, float maxX, float maxY, float maxZ, Matrix4f matrix4f, float red, float green, float blue) {
public DireVertexConsumerSquished(VertexConsumer parent, float minX, float minY, float minZ, float maxX, float maxY, float maxZ, Matrix4f matrix4f, float red, float green, float blue, float alpha) {
super(parent);
this.minX = minX;
this.minY = minY;
Expand All @@ -46,6 +47,7 @@ public DireVertexConsumerSquished(VertexConsumer parent, float minX, float minY,
this.red = red;
this.green = green;
this.blue = blue;
this.alpha = alpha;
}

@Override
Expand All @@ -56,7 +58,8 @@ public VertexConsumer color(int r, int g, int b, int a) {
int rCol = (int) Mth.lerp(red, 0, r);
int gCol = (int) Mth.lerp(green, 0, g);
int bCol = (int) Mth.lerp(blue, 0, b);
parent.color(rCol, gCol, bCol, a);
int aCol = (int) Mth.lerp(alpha, 0, a);
parent.color(rCol, gCol, bCol, aCol);
}
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public static void updateRenders() {
.setLightmapState(LIGHTMAP)
.setTextureState(BLOCK_SHEET)
//.setLayeringState(RenderStateShard.NO_LAYERING)
//.setTransparencyState(TRANSLUCENT_TRANSPARENCY)
.setTransparencyState(TRANSLUCENT_TRANSPARENCY)
.setDepthTestState(GREATER_DEPTH_TEST)
.setCullState(CULL)
//.setWriteMaskState(RenderStateShard.COLOR_DEPTH_WRITE)
Expand Down

0 comments on commit 012cfec

Please sign in to comment.