Icons for modifier settings and replace modes. Rendering mirror lines and areas in world.
Removed shaders.
This commit is contained in:
@@ -26,15 +26,21 @@ public class AllIcons implements ScreenElement {
|
||||
private int iconY;
|
||||
|
||||
public static final AllIcons
|
||||
I_SETTINGS = newRow(),
|
||||
I_UNDO = next(),
|
||||
I_REDO = next(),
|
||||
I_REPLACE = next();
|
||||
I_SETTINGS = newRow(),
|
||||
I_UNDO = next(),
|
||||
I_REDO = next(),
|
||||
I_REPLACE = next(),
|
||||
I_REPLACE_AIR = next(),
|
||||
I_REPLACE_BLOCKS_AND_AIR = next(),
|
||||
I_REPLACE_BLOCKS = next(),
|
||||
I_REPLACE_OFFHAND_FILTERED = next(),
|
||||
I_PROTECT_TILE_ENTITIES = next();
|
||||
|
||||
|
||||
public static final AllIcons
|
||||
I_DISABLE = newRow(),
|
||||
I_SINGLE = next(),
|
||||
I_LINE = next(),
|
||||
I_DISABLE = newRow(),
|
||||
I_SINGLE = next(),
|
||||
I_LINE = next(),
|
||||
I_WALL = next(),
|
||||
I_FLOOR = next(),
|
||||
I_CUBE = next(),
|
||||
@@ -71,7 +77,15 @@ public class AllIcons implements ScreenElement {
|
||||
I_HIDE_LINES = next(),
|
||||
I_SHOW_LINES = next(),
|
||||
I_HIDE_AREAS = next(),
|
||||
I_SHOW_AREAS = next();
|
||||
I_SHOW_AREAS = next(),
|
||||
I_X_OFF = next(),
|
||||
I_X_ON = next(),
|
||||
I_Y_OFF = next(),
|
||||
I_Y_ON = next(),
|
||||
I_Z_OFF = next(),
|
||||
I_Z_ON = next(),
|
||||
I_ALTERNATE_OFF = next(),
|
||||
I_ALTERNATE_ON = next();
|
||||
|
||||
|
||||
public AllIcons(int x, int y) {
|
||||
|
||||
@@ -115,11 +115,11 @@ public class ModeOptions {
|
||||
OPEN_MODIFIER_SETTINGS("open_modifier_settings", AllIcons.I_SETTINGS),
|
||||
OPEN_PLAYER_SETTINGS("open_player_settings", AllIcons.I_SETTINGS),
|
||||
|
||||
REPLACE_ONLY_AIR("replace_only_air", AllIcons.I_REPLACE),
|
||||
REPLACE_BLOCKS_AND_AIR("replace_blocks_and_air", AllIcons.I_REPLACE),
|
||||
REPLACE_ONLY_BLOCKS("replace_only_blocks", AllIcons.I_REPLACE),
|
||||
REPLACE_FILTERED_BY_OFFHAND("replace_filtered_by_offhand", AllIcons.I_REPLACE),
|
||||
TOGGLE_PROTECT_TILE_ENTITIES("toggle_protect_tile_entities", AllIcons.I_REPLACE),
|
||||
REPLACE_ONLY_AIR("replace_only_air", AllIcons.I_REPLACE_AIR),
|
||||
REPLACE_BLOCKS_AND_AIR("replace_blocks_and_air", AllIcons.I_REPLACE_BLOCKS_AND_AIR),
|
||||
REPLACE_ONLY_BLOCKS("replace_only_blocks", AllIcons.I_REPLACE_BLOCKS),
|
||||
REPLACE_FILTERED_BY_OFFHAND("replace_filtered_by_offhand", AllIcons.I_REPLACE_OFFHAND_FILTERED),
|
||||
TOGGLE_PROTECT_TILE_ENTITIES("toggle_protect_tile_entities", AllIcons.I_PROTECT_TILE_ENTITIES),
|
||||
|
||||
NORMAL_SPEED("normal_speed", AllIcons.I_NORMAL_SPEED),
|
||||
FAST_SPEED("fast_speed", AllIcons.I_FAST_SPEED),
|
||||
|
||||
@@ -91,21 +91,21 @@ public class RadialMirror extends BaseModifier {
|
||||
if (angleToCenter < -0.751 * Math.PI || angleToCenter > 0.749 * Math.PI) {
|
||||
blockEntry.rotation = blockEntry.rotation.getRotated(Rotation.CLOCKWISE_180);
|
||||
if (alternate) {
|
||||
blockEntry.mirrorZ = !blockEntry.mirrorZ;
|
||||
// blockEntry.mirrorX = !blockEntry.mirrorX;
|
||||
}
|
||||
} else if (angleToCenter < -0.251 * Math.PI) {
|
||||
blockEntry.rotation = blockEntry.rotation.getRotated(Rotation.CLOCKWISE_90);
|
||||
if (alternate) {
|
||||
blockEntry.mirrorX = !blockEntry.mirrorX;
|
||||
// blockEntry.mirrorZ = !blockEntry.mirrorZ;
|
||||
}
|
||||
} else if (angleToCenter > 0.249 * Math.PI) {
|
||||
blockEntry.rotation = blockEntry.rotation.getRotated(Rotation.COUNTERCLOCKWISE_90);
|
||||
if (alternate) {
|
||||
blockEntry.mirrorX = !blockEntry.mirrorX;
|
||||
// blockEntry.mirrorZ = !blockEntry.mirrorZ;
|
||||
}
|
||||
} else {
|
||||
if (alternate) {
|
||||
blockEntry.mirrorZ = !blockEntry.mirrorZ;
|
||||
// blockEntry.mirrorX = !blockEntry.mirrorX;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,13 +47,13 @@ public class PartialItemModelRenderer {
|
||||
render(model, RenderTypes.getItemPartialSolid(), light);
|
||||
}
|
||||
|
||||
public void renderSolidGlowing(BakedModel model, int light) {
|
||||
render(model, RenderTypes.getGlowingSolid(), light);
|
||||
}
|
||||
|
||||
public void renderGlowing(BakedModel model, int light) {
|
||||
render(model, RenderTypes.getGlowingTranslucent(), light);
|
||||
}
|
||||
// public void renderSolidGlowing(BakedModel model, int light) {
|
||||
// render(model, RenderTypes.getGlowingSolid(), light);
|
||||
// }
|
||||
//
|
||||
// public void renderGlowing(BakedModel model, int light) {
|
||||
// render(model, RenderTypes.getGlowingTranslucent(), light);
|
||||
// }
|
||||
|
||||
public void render(BakedModel model, RenderType type, int light) {
|
||||
if (stack.isEmpty())
|
||||
|
||||
@@ -20,7 +20,7 @@ import java.io.IOException;
|
||||
// TODO 1.17: use custom shaders instead of vanilla ones
|
||||
public class RenderTypes extends RenderStateShard {
|
||||
|
||||
public static final ShaderStateShard GLOWING_SHADER = new ShaderStateShard(() -> Shaders.glowingShader);
|
||||
// public static final ShaderStateShard GLOWING_SHADER = new ShaderStateShard(() -> Shaders.glowingShader);
|
||||
|
||||
private static final RenderType OUTLINE_SOLID =
|
||||
RenderType.create(createLayerName("outline_solid"), DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256, false,
|
||||
@@ -49,33 +49,33 @@ public class RenderTypes extends RenderStateShard {
|
||||
.createCompositeState(false));
|
||||
}
|
||||
|
||||
public static RenderType getGlowingSolid(ResourceLocation texture) {
|
||||
return RenderType.create(createLayerName("glowing_solid"), DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256,
|
||||
true, false, RenderType.CompositeState.builder()
|
||||
.setShaderState(GLOWING_SHADER)
|
||||
.setTextureState(new TextureStateShard(texture, false, false))
|
||||
.setCullState(CULL)
|
||||
.setLightmapState(LIGHTMAP)
|
||||
.setOverlayState(OVERLAY)
|
||||
.createCompositeState(true));
|
||||
}
|
||||
// public static RenderType getGlowingSolid(ResourceLocation texture) {
|
||||
// return RenderType.create(createLayerName("glowing_solid"), DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256,
|
||||
// true, false, RenderType.CompositeState.builder()
|
||||
// .setShaderState(GLOWING_SHADER)
|
||||
// .setTextureState(new TextureStateShard(texture, false, false))
|
||||
// .setCullState(CULL)
|
||||
// .setLightmapState(LIGHTMAP)
|
||||
// .setOverlayState(OVERLAY)
|
||||
// .createCompositeState(true));
|
||||
// }
|
||||
//
|
||||
// private static final RenderType GLOWING_SOLID_DEFAULT = getGlowingSolid(InventoryMenu.BLOCK_ATLAS);
|
||||
//
|
||||
// public static RenderType getGlowingSolid() {
|
||||
// return GLOWING_SOLID_DEFAULT;
|
||||
// }
|
||||
|
||||
private static final RenderType GLOWING_SOLID_DEFAULT = getGlowingSolid(InventoryMenu.BLOCK_ATLAS);
|
||||
|
||||
public static RenderType getGlowingSolid() {
|
||||
return GLOWING_SOLID_DEFAULT;
|
||||
}
|
||||
|
||||
public static RenderType getGlowingTranslucent(ResourceLocation texture) {
|
||||
return RenderType.create(createLayerName("glowing_translucent"), DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS,
|
||||
256, true, true, RenderType.CompositeState.builder()
|
||||
.setShaderState(GLOWING_SHADER)
|
||||
.setTextureState(new TextureStateShard(texture, false, false))
|
||||
.setTransparencyState(TRANSLUCENT_TRANSPARENCY)
|
||||
.setLightmapState(LIGHTMAP)
|
||||
.setOverlayState(OVERLAY)
|
||||
.createCompositeState(true));
|
||||
}
|
||||
// public static RenderType getGlowingTranslucent(ResourceLocation texture) {
|
||||
// return RenderType.create(createLayerName("glowing_translucent"), DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS,
|
||||
// 256, true, true, RenderType.CompositeState.builder()
|
||||
// .setShaderState(GLOWING_SHADER)
|
||||
// .setTextureState(new TextureStateShard(texture, false, false))
|
||||
// .setTransparencyState(TRANSLUCENT_TRANSPARENCY)
|
||||
// .setLightmapState(LIGHTMAP)
|
||||
// .setOverlayState(OVERLAY)
|
||||
// .createCompositeState(true));
|
||||
// }
|
||||
|
||||
private static final RenderType ADDITIVE = RenderType.create(createLayerName("additive"), DefaultVertexFormat.BLOCK,
|
||||
VertexFormat.Mode.QUADS, 256, true, true, RenderType.CompositeState.builder()
|
||||
@@ -91,11 +91,11 @@ public class RenderTypes extends RenderStateShard {
|
||||
return ADDITIVE;
|
||||
}
|
||||
|
||||
private static final RenderType GLOWING_TRANSLUCENT_DEFAULT = getGlowingTranslucent(InventoryMenu.BLOCK_ATLAS);
|
||||
// private static final RenderType GLOWING_TRANSLUCENT_DEFAULT = getGlowingTranslucent(InventoryMenu.BLOCK_ATLAS);
|
||||
|
||||
public static RenderType getGlowingTranslucent() {
|
||||
return GLOWING_TRANSLUCENT_DEFAULT;
|
||||
}
|
||||
// public static RenderType getGlowingTranslucent() {
|
||||
// return GLOWING_TRANSLUCENT_DEFAULT;
|
||||
// }
|
||||
|
||||
private static final RenderType ITEM_PARTIAL_SOLID =
|
||||
RenderType.create(createLayerName("item_partial_solid"), DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256, true,
|
||||
@@ -146,15 +146,15 @@ public class RenderTypes extends RenderStateShard {
|
||||
super(null, null, null);
|
||||
}
|
||||
|
||||
@EventBusSubscriber(value = Dist.CLIENT, bus = EventBusSubscriber.Bus.MOD)
|
||||
private static class Shaders {
|
||||
private static ShaderInstance glowingShader;
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onRegisterShaders(RegisterShadersEvent event) throws IOException {
|
||||
ResourceManager resourceManager = event.getResourceManager();
|
||||
event.registerShader(new ShaderInstance(resourceManager, Create.asResource("glowing_shader"), DefaultVertexFormat.NEW_ENTITY), shader -> glowingShader = shader);
|
||||
}
|
||||
}
|
||||
// @EventBusSubscriber(value = Dist.CLIENT, bus = EventBusSubscriber.Bus.MOD)
|
||||
// private static class Shaders {
|
||||
// private static ShaderInstance glowingShader;
|
||||
//
|
||||
// @SubscribeEvent
|
||||
// public static void onRegisterShaders(RegisterShadersEvent event) throws IOException {
|
||||
// ResourceManager resourceManager = event.getResourceManager();
|
||||
// event.registerShader(new ShaderInstance(resourceManager, Create.asResource("glowing_shader"), DefaultVertexFormat.NEW_ENTITY), shader -> glowingShader = shader);
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ public class MirrorEntry extends BaseModifierEntry<Mirror> {
|
||||
//Axis buttons
|
||||
for (int i = 0; i < 3; i++) {
|
||||
final int index = i;
|
||||
IconButton button = new IconButton(0, 0, AllIcons.I_SHOW_LINES)
|
||||
IconButton button = new IconButton(0, 0, i == 0 ? AllIcons.I_X_ON : i == 1 ? AllIcons.I_Y_OFF : AllIcons.I_Z_OFF)
|
||||
.withCallback(() -> {
|
||||
modifier.toggleMirrorAxis(index);
|
||||
onValueChanged();
|
||||
@@ -191,42 +191,42 @@ public class MirrorEntry extends BaseModifierEntry<Mirror> {
|
||||
//Toggle offset button
|
||||
if (modifier.position.x == Math.floor(modifier.position.x)) {
|
||||
toggleOffsetButton.setIcon(AllIcons.I_BLOCK_CENTER);
|
||||
toggleOffsetButton.setToolTip(Components.literal("Set mirror position to center of block, for uneven numbered builds."));
|
||||
toggleOffsetButton.setToolTip(Components.literal("Set position to center of block, for uneven numbered builds."));
|
||||
}
|
||||
else {
|
||||
toggleOffsetButton.setIcon(AllIcons.I_BLOCK_CORNER);
|
||||
toggleOffsetButton.setToolTip(Components.literal("Set mirror position to corner of block, for even numbered builds."));
|
||||
toggleOffsetButton.setToolTip(Components.literal("Set position to corner of block, for even numbered builds."));
|
||||
}
|
||||
|
||||
//Axis buttons
|
||||
for (int i = 0; i < 3; i++) {
|
||||
IconButton button = axisButtons.get(i);
|
||||
if (modifier.getMirrorAxis(i)) {
|
||||
button.setIcon(AllIcons.I_SHOW_LINES);
|
||||
button.setIcon(i == 0 ? AllIcons.I_X_ON : i == 1 ? AllIcons.I_Y_ON : AllIcons.I_Z_ON);
|
||||
}
|
||||
else {
|
||||
button.setIcon(AllIcons.I_HIDE_LINES);
|
||||
button.setIcon(i == 0 ? AllIcons.I_X_OFF : i == 1 ? AllIcons.I_Y_OFF : AllIcons.I_Z_OFF);
|
||||
}
|
||||
}
|
||||
|
||||
//Show lines button
|
||||
if (modifier.drawLines) {
|
||||
showLinesButton.setIcon(AllIcons.I_SHOW_LINES);
|
||||
showLinesButton.setToolTip(Components.literal("Hide mirror lines"));
|
||||
showLinesButton.setToolTip(Components.literal("Showing mirror lines"));
|
||||
}
|
||||
else {
|
||||
showLinesButton.setIcon(AllIcons.I_HIDE_LINES);
|
||||
showLinesButton.setToolTip(Components.literal("Show mirror lines"));
|
||||
showLinesButton.setToolTip(Components.literal("Not showing mirror lines"));
|
||||
}
|
||||
|
||||
//Show areas button
|
||||
if (modifier.drawPlanes) {
|
||||
showAreasButton.setIcon(AllIcons.I_SHOW_AREAS);
|
||||
showAreasButton.setToolTip(Components.literal("Hide mirror areas"));
|
||||
showAreasButton.setToolTip(Components.literal("Showing mirror areas"));
|
||||
}
|
||||
else {
|
||||
showAreasButton.setIcon(AllIcons.I_HIDE_AREAS);
|
||||
showAreasButton.setToolTip(Components.literal("Show mirror areas"));
|
||||
showAreasButton.setToolTip(Components.literal("Not showing mirror areas"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ public class RadialMirrorEntry extends BaseModifierEntry<RadialMirror> {
|
||||
listeners.add(slicesInput);
|
||||
|
||||
//Alternate
|
||||
alternateButton = new IconButton(0, 0, AllIcons.I_SHOW_AREAS)
|
||||
alternateButton = new IconButton(0, 0, AllIcons.I_ALTERNATE_OFF)
|
||||
.withCallback(() -> {
|
||||
modifier.alternate = !modifier.alternate;
|
||||
onValueChanged();
|
||||
@@ -108,7 +108,9 @@ public class RadialMirrorEntry extends BaseModifierEntry<RadialMirror> {
|
||||
//Radius
|
||||
radiusInput = new LabeledScrollInput(0, 0, 27, 18)
|
||||
.withRange(0, ReachHelper.getMaxMirrorRadius(Minecraft.getInstance().player))
|
||||
.titled(Component.literal("Radius. Use Reach Upgrade items to increase maximum."))
|
||||
.titled(Minecraft.getInstance().player.isCreative() ?
|
||||
Component.literal("Radius") :
|
||||
Component.literal("Radius. Use Reach Upgrade items to increase maximum."))
|
||||
.calling(value -> {
|
||||
modifier.radius = value;
|
||||
onValueChanged();
|
||||
@@ -199,41 +201,41 @@ public class RadialMirrorEntry extends BaseModifierEntry<RadialMirror> {
|
||||
//Toggle offset button
|
||||
if (modifier.position.x == Math.floor(modifier.position.x)) {
|
||||
toggleOffsetButton.setIcon(AllIcons.I_BLOCK_CENTER);
|
||||
toggleOffsetButton.setToolTip(Components.literal("Set radialMirror position to center of block, for uneven numbered builds."));
|
||||
toggleOffsetButton.setToolTip(Components.literal("Set position to center of block, for uneven numbered builds."));
|
||||
}
|
||||
else {
|
||||
toggleOffsetButton.setIcon(AllIcons.I_BLOCK_CORNER);
|
||||
toggleOffsetButton.setToolTip(Components.literal("Set radialMirror position to corner of block, for even numbered builds."));
|
||||
toggleOffsetButton.setToolTip(Components.literal("Set position to corner of block, for even numbered builds."));
|
||||
}
|
||||
|
||||
//Toggle alternate button
|
||||
if (modifier.alternate) {
|
||||
alternateButton.setIcon(AllIcons.I_SHOW_AREAS);
|
||||
alternateButton.setToolTip(Components.literal("Alternate the direction of every other slice: Currently ON"));
|
||||
alternateButton.setIcon(AllIcons.I_ALTERNATE_ON);
|
||||
alternateButton.setToolTip(Components.literal("Alternating the direction of every other slice."));
|
||||
}
|
||||
else {
|
||||
alternateButton.setIcon(AllIcons.I_HIDE_AREAS);
|
||||
alternateButton.setToolTip(Components.literal("Alternate the direction of every other slice. Currently OFF"));
|
||||
alternateButton.setIcon(AllIcons.I_ALTERNATE_OFF);
|
||||
alternateButton.setToolTip(Components.literal("Alternate the direction of every other slice. Currently off."));
|
||||
}
|
||||
|
||||
//Show lines button
|
||||
if (modifier.drawLines) {
|
||||
showLinesButton.setIcon(AllIcons.I_SHOW_LINES);
|
||||
showLinesButton.setToolTip(Components.literal("Hide radial mirror lines"));
|
||||
showLinesButton.setToolTip(Components.literal("Showing mirror lines"));
|
||||
}
|
||||
else {
|
||||
showLinesButton.setIcon(AllIcons.I_HIDE_LINES);
|
||||
showLinesButton.setToolTip(Components.literal("Show radial mirror lines"));
|
||||
showLinesButton.setToolTip(Components.literal("Not showing mirror lines"));
|
||||
}
|
||||
|
||||
//Show areas button
|
||||
if (modifier.drawPlanes) {
|
||||
showAreasButton.setIcon(AllIcons.I_SHOW_AREAS);
|
||||
showAreasButton.setToolTip(Components.literal("Hide radial mirror areas"));
|
||||
showAreasButton.setToolTip(Components.literal("Showing mirror areas"));
|
||||
}
|
||||
else {
|
||||
showAreasButton.setIcon(AllIcons.I_HIDE_AREAS);
|
||||
showAreasButton.setToolTip(Components.literal("Show radial mirror areas"));
|
||||
showAreasButton.setToolTip(Components.literal("Not showing mirror areas"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,33 +1,16 @@
|
||||
package nl.requios.effortlessbuilding.render;
|
||||
|
||||
import com.mojang.blaze3d.shaders.Uniform;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
|
||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
||||
import net.minecraft.client.renderer.RenderStateShard;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.ShaderInstance;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import nl.requios.effortlessbuilding.EffortlessBuilding;
|
||||
|
||||
import java.util.OptionalDouble;
|
||||
|
||||
|
||||
public class BuildRenderTypes extends RenderType {
|
||||
public static ResourceLocation shaderMaskTextureLocation = new ResourceLocation(EffortlessBuilding.MODID, "textures/shader_mask.png");
|
||||
|
||||
public static final RenderType LINES;
|
||||
public static final RenderType PLANES;
|
||||
|
||||
public static ShaderInstance dissolveShaderInstance;
|
||||
private static final ShaderStateShard RENDERTYPE_DISSOLVE_SHADER = new ShaderStateShard(() -> dissolveShaderInstance);
|
||||
|
||||
//Between 0 and 7, but dont override vanilla textures
|
||||
//Also update dissolve.fsh SamplerX
|
||||
private static final int maskTextureIndex = 2;
|
||||
|
||||
static {
|
||||
final LineStateShard LINE = new LineStateShard(OptionalDouble.of(2.0));
|
||||
final int INITIAL_BUFFER_SIZE = 128;
|
||||
@@ -64,69 +47,7 @@ public class BuildRenderTypes extends RenderType {
|
||||
DefaultVertexFormat.POSITION_COLOR, VertexFormat.Mode.TRIANGLE_STRIP, INITIAL_BUFFER_SIZE, false, false, renderState);
|
||||
}
|
||||
|
||||
|
||||
// Dummy constructor needed to make java happy
|
||||
public BuildRenderTypes(String p_173178_, VertexFormat p_173179_, VertexFormat.Mode p_173180_, int p_173181_, boolean p_173182_, boolean p_173183_, Runnable p_173184_, Runnable p_173185_) {
|
||||
super(p_173178_, p_173179_, p_173180_, p_173181_, p_173182_, p_173183_, p_173184_, p_173185_);
|
||||
}
|
||||
|
||||
public static RenderType getBlockPreviewRenderType(float dissolve, BlockPos blockPos, BlockPos firstPos, BlockPos secondPos, boolean red) {
|
||||
|
||||
String stateName = "eb_texturing_" + dissolve + "_" + blockPos + "_" + firstPos + "_" + secondPos + "_" + red;
|
||||
TexturingStateShard MY_TEXTURING = new TexturingStateShard(stateName, () -> {
|
||||
setShaderParameters(dissolveShaderInstance, dissolve, Vec3.atLowerCornerOf(blockPos), Vec3.atLowerCornerOf(firstPos), Vec3.atLowerCornerOf(secondPos), blockPos == secondPos, red);
|
||||
RenderSystem.setShaderColor(1f, 1f, 1f, 0.8f);
|
||||
}, () -> {});
|
||||
|
||||
RenderType.CompositeState renderState = RenderType.CompositeState.builder()
|
||||
.setShaderState(RENDERTYPE_DISSOLVE_SHADER)
|
||||
.setTexturingState(MY_TEXTURING)
|
||||
.setTextureState(RenderStateShard.BLOCK_SHEET_MIPPED)
|
||||
.setTransparencyState(TRANSLUCENT_TRANSPARENCY)
|
||||
.setLightmapState(RenderStateShard.NO_LIGHTMAP)
|
||||
.setCullState(RenderStateShard.CULL)
|
||||
.setOutputState(RenderStateShard.TRANSLUCENT_TARGET)
|
||||
.createCompositeState(true);
|
||||
//Unique name for every combination, otherwise it will reuse the previous one
|
||||
String name = "eb_block_previews_" + dissolve + "_" + blockPos + "_" + firstPos + "_" + secondPos + "_" + red;
|
||||
return RenderType.create(name,
|
||||
DefaultVertexFormat.BLOCK, VertexFormat.Mode.QUADS, 2097152, true, true, renderState);
|
||||
}
|
||||
|
||||
private static void setShaderParameters(ShaderInstance shader, final float dissolve, final Vec3 blockpos,
|
||||
final Vec3 firstpos, final Vec3 secondpos,
|
||||
final boolean highlight, final boolean red) {
|
||||
Uniform percentileUniform = shader.getUniform("dissolve");
|
||||
Uniform highlightUniform = shader.getUniform("highlight");
|
||||
Uniform redUniform = shader.getUniform("red");
|
||||
Uniform blockposUniform = shader.getUniform("blockpos");
|
||||
Uniform firstposUniform = shader.getUniform("firstpos");
|
||||
Uniform secondposUniform = shader.getUniform("secondpos");
|
||||
|
||||
RenderSystem.setShaderTexture(maskTextureIndex, shaderMaskTextureLocation);
|
||||
|
||||
if (percentileUniform != null) percentileUniform.set(dissolve); else EffortlessBuilding.log("percentileUniform is null");
|
||||
if (highlightUniform != null) highlightUniform.set(highlight ? 1 : 0); else EffortlessBuilding.log("highlightUniform is null");
|
||||
if (redUniform != null) redUniform.set(red ? 1 : 0); else EffortlessBuilding.log("redUniform is null");
|
||||
|
||||
if (blockposUniform != null) blockposUniform.set((float) blockpos.x, (float) blockpos.y, (float) blockpos.z); else EffortlessBuilding.log("blockposUniform is null");
|
||||
if (firstposUniform != null) firstposUniform.set((float) firstpos.x, (float) firstpos.y, (float) firstpos.z); else EffortlessBuilding.log("firstposUniform is null");
|
||||
if (secondposUniform != null) secondposUniform.set((float) secondpos.x, (float) secondpos.y, (float) secondpos.z); else EffortlessBuilding.log("secondposUniform is null");
|
||||
}
|
||||
|
||||
private class ShaderInfo {
|
||||
float dissolve;
|
||||
Vec3 blockPos;
|
||||
Vec3 firstPos;
|
||||
Vec3 secondPos;
|
||||
boolean red;
|
||||
|
||||
public ShaderInfo(float dissolve, Vec3 blockPos, Vec3 firstPos, Vec3 secondPos, boolean red) {
|
||||
this.dissolve = dissolve;
|
||||
this.blockPos = blockPos;
|
||||
this.firstPos = firstPos;
|
||||
this.secondPos = secondPos;
|
||||
this.red = red;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,165 +2,181 @@ package nl.requios.effortlessbuilding.render;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.MultiBufferSource.BufferSource;
|
||||
import com.mojang.math.Matrix4f;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import nl.requios.effortlessbuilding.EffortlessBuildingClient;
|
||||
import nl.requios.effortlessbuilding.buildmodifier.BaseModifier;
|
||||
import nl.requios.effortlessbuilding.buildmodifier.Mirror;
|
||||
import nl.requios.effortlessbuilding.buildmodifier.RadialMirror;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.List;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class ModifierRenderer {
|
||||
|
||||
// protected static final Color colorX = new Color(255, 72, 52);
|
||||
// protected static final Color colorY = new Color(67, 204, 51);
|
||||
// protected static final Color colorZ = new Color(52, 247, 255);
|
||||
// protected static final Color colorRadial = new Color(52, 247, 255);
|
||||
// protected static final int lineAlpha = 200;
|
||||
// protected static final int planeAlpha = 50;
|
||||
// protected static final Vec3 epsilon = new Vec3(0.001, 0.001, 0.001); //prevents z-fighting
|
||||
//
|
||||
// public static void render(PoseStack matrixStack, MultiBufferSource.BufferSource renderTypeBuffer, ModifierSettingsManager.ModifierSettings modifierSettings) {
|
||||
// //Mirror lines and areas
|
||||
// Mirror.MirrorSettings m = modifierSettings.getMirrorSettings();
|
||||
// if (m != null && m.enabled && (m.mirrorX || m.mirrorY || m.mirrorZ)) {
|
||||
// Vec3 pos = m.position.add(epsilon);
|
||||
// int radius = m.radius;
|
||||
//
|
||||
// if (m.mirrorX) {
|
||||
// Vec3 posA = new Vec3(pos.x, pos.y - radius, pos.z - radius);
|
||||
// Vec3 posB = new Vec3(pos.x, pos.y + radius, pos.z + radius);
|
||||
//
|
||||
// drawMirrorPlane(matrixStack, renderTypeBuffer, posA, posB, colorX, m.drawLines, m.drawPlanes, true);
|
||||
// }
|
||||
// if (m.mirrorY) {
|
||||
// Vec3 posA = new Vec3(pos.x - radius, pos.y, pos.z - radius);
|
||||
// Vec3 posB = new Vec3(pos.x + radius, pos.y, pos.z + radius);
|
||||
//
|
||||
// drawMirrorPlaneY(matrixStack, renderTypeBuffer, posA, posB, colorY, m.drawLines, m.drawPlanes);
|
||||
// }
|
||||
// if (m.mirrorZ) {
|
||||
// Vec3 posA = new Vec3(pos.x - radius, pos.y - radius, pos.z);
|
||||
// Vec3 posB = new Vec3(pos.x + radius, pos.y + radius, pos.z);
|
||||
//
|
||||
// drawMirrorPlane(matrixStack, renderTypeBuffer, posA, posB, colorZ, m.drawLines, m.drawPlanes, true);
|
||||
// }
|
||||
//
|
||||
// //Draw axis coordinated colors if two or more axes are enabled
|
||||
// //(If only one is enabled the lines are that planes color)
|
||||
// if (m.drawLines && ((m.mirrorX && m.mirrorY) || (m.mirrorX && m.mirrorZ) || (m.mirrorY && m.mirrorZ))) {
|
||||
// drawMirrorLines(matrixStack, renderTypeBuffer, m);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// //Radial mirror lines and areas
|
||||
// RadialMirror.RadialMirrorSettings r = modifierSettings.getRadialMirrorSettings();
|
||||
// if (r != null && r.enabled) {
|
||||
// Vec3 pos = r.position.add(epsilon);
|
||||
// int radius = r.radius;
|
||||
//
|
||||
// float angle = 2f * ((float) Math.PI) / r.slices;
|
||||
// Vec3 relStartVec = new Vec3(radius, 0, 0);
|
||||
// if (r.slices % 4 == 2) relStartVec = relStartVec.yRot(angle / 2f);
|
||||
//
|
||||
// for (int i = 0; i < r.slices; i++) {
|
||||
// Vec3 relNewVec = relStartVec.yRot(angle * i);
|
||||
// Vec3 newVec = pos.add(relNewVec);
|
||||
//
|
||||
// Vec3 posA = new Vec3(pos.x, pos.y - radius, pos.z);
|
||||
// Vec3 posB = new Vec3(newVec.x, pos.y + radius, newVec.z);
|
||||
// drawMirrorPlane(matrixStack, renderTypeBuffer, posA, posB, colorRadial, r.drawLines, r.drawPlanes, false);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
// //----Mirror----
|
||||
//
|
||||
// protected static void drawMirrorPlane(PoseStack matrixStack, MultiBufferSource.BufferSource renderTypeBuffer, Vec3 posA, Vec3 posB, Color c, boolean drawLines, boolean drawPlanes, boolean drawVerticalLines) {
|
||||
//
|
||||
//// GL11.glColor4d(c.getRed(), c.getGreen(), c.getBlue(), planeAlpha);
|
||||
// Matrix4f matrixPos = matrixStack.last().pose();
|
||||
//
|
||||
// if (drawPlanes) {
|
||||
// VertexConsumer buffer = RenderHandler.beginPlanes(renderTypeBuffer);
|
||||
//
|
||||
// buffer.vertex(matrixPos, (float) posA.x, (float) posA.y, (float) posA.z).color(c.getRed(), c.getGreen(), c.getBlue(), planeAlpha).endVertex();
|
||||
// buffer.vertex(matrixPos, (float) posA.x, (float) posB.y, (float) posA.z).color(c.getRed(), c.getGreen(), c.getBlue(), planeAlpha).endVertex();
|
||||
// buffer.vertex(matrixPos, (float) posB.x, (float) posA.y, (float) posB.z).color(c.getRed(), c.getGreen(), c.getBlue(), planeAlpha).endVertex();
|
||||
// buffer.vertex(matrixPos, (float) posB.x, (float) posB.y, (float) posB.z).color(c.getRed(), c.getGreen(), c.getBlue(), planeAlpha).endVertex();
|
||||
// //backface (using triangle strip)
|
||||
// buffer.vertex(matrixPos, (float) posA.x, (float) posA.y, (float) posA.z).color(c.getRed(), c.getGreen(), c.getBlue(), planeAlpha).endVertex();
|
||||
// buffer.vertex(matrixPos, (float) posA.x, (float) posB.y, (float) posA.z).color(c.getRed(), c.getGreen(), c.getBlue(), planeAlpha).endVertex();
|
||||
//
|
||||
// RenderHandler.endPlanes(renderTypeBuffer);
|
||||
// }
|
||||
//
|
||||
// if (drawLines) {
|
||||
// VertexConsumer buffer = RenderHandler.beginLines(renderTypeBuffer);
|
||||
//
|
||||
// Vec3 middle = posA.add(posB).scale(0.5);
|
||||
// buffer.vertex(matrixPos, (float) posA.x, (float) middle.y, (float) posA.z).color(c.getRed(), c.getGreen(), c.getBlue(), lineAlpha).endVertex();
|
||||
// buffer.vertex(matrixPos, (float) posB.x, (float) middle.y, (float) posB.z).color(c.getRed(), c.getGreen(), c.getBlue(), lineAlpha).endVertex();
|
||||
// if (drawVerticalLines) {
|
||||
// buffer.vertex(matrixPos, (float) middle.x, (float) posA.y, (float) middle.z).color(c.getRed(), c.getGreen(), c.getBlue(), lineAlpha).endVertex();
|
||||
// buffer.vertex(matrixPos, (float) middle.x, (float) posB.y, (float) middle.z).color(c.getRed(), c.getGreen(), c.getBlue(), lineAlpha).endVertex();
|
||||
// }
|
||||
//
|
||||
// RenderHandler.endLines(renderTypeBuffer);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// protected static void drawMirrorPlaneY(PoseStack matrixStack, MultiBufferSource.BufferSource renderTypeBuffer, Vec3 posA, Vec3 posB, Color c, boolean drawLines, boolean drawPlanes) {
|
||||
//
|
||||
//// GL11.glColor4d(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha());
|
||||
// Matrix4f matrixPos = matrixStack.last().pose();
|
||||
//
|
||||
// if (drawPlanes) {
|
||||
// VertexConsumer buffer = RenderHandler.beginPlanes(renderTypeBuffer);
|
||||
//
|
||||
// buffer.vertex(matrixPos, (float) posA.x, (float) posA.y, (float) posA.z).color(c.getRed(), c.getGreen(), c.getBlue(), planeAlpha).endVertex();
|
||||
// buffer.vertex(matrixPos, (float) posA.x, (float) posA.y, (float) posB.z).color(c.getRed(), c.getGreen(), c.getBlue(), planeAlpha).endVertex();
|
||||
// buffer.vertex(matrixPos, (float) posB.x, (float) posA.y, (float) posA.z).color(c.getRed(), c.getGreen(), c.getBlue(), planeAlpha).endVertex();
|
||||
// buffer.vertex(matrixPos, (float) posB.x, (float) posA.y, (float) posB.z).color(c.getRed(), c.getGreen(), c.getBlue(), planeAlpha).endVertex();
|
||||
// //backface (using triangle strip)
|
||||
// buffer.vertex(matrixPos, (float) posA.x, (float) posA.y, (float) posA.z).color(c.getRed(), c.getGreen(), c.getBlue(), planeAlpha).endVertex();
|
||||
// buffer.vertex(matrixPos, (float) posA.x, (float) posA.y, (float) posB.z).color(c.getRed(), c.getGreen(), c.getBlue(), planeAlpha).endVertex();
|
||||
//
|
||||
// RenderHandler.endPlanes(renderTypeBuffer);
|
||||
// }
|
||||
//
|
||||
// if (drawLines) {
|
||||
// VertexConsumer buffer = RenderHandler.beginLines(renderTypeBuffer);
|
||||
//
|
||||
// Vec3 middle = posA.add(posB).scale(0.5);
|
||||
// buffer.vertex(matrixPos, (float) middle.x, (float) middle.y, (float) posA.z).color(c.getRed(), c.getGreen(), c.getBlue(), lineAlpha).endVertex();
|
||||
// buffer.vertex(matrixPos, (float) middle.x, (float) middle.y, (float) posB.z).color(c.getRed(), c.getGreen(), c.getBlue(), lineAlpha).endVertex();
|
||||
// buffer.vertex(matrixPos, (float) posA.x, (float) middle.y, (float) middle.z).color(c.getRed(), c.getGreen(), c.getBlue(), lineAlpha).endVertex();
|
||||
// buffer.vertex(matrixPos, (float) posB.x, (float) middle.y, (float) middle.z).color(c.getRed(), c.getGreen(), c.getBlue(), lineAlpha).endVertex();
|
||||
//
|
||||
// RenderHandler.endLines(renderTypeBuffer);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// protected static void drawMirrorLines(PoseStack matrixStack, MultiBufferSource.BufferSource renderTypeBuffer, Mirror.MirrorSettings m) {
|
||||
//
|
||||
//// GL11.glColor4d(100, 100, 100, 255);
|
||||
// VertexConsumer buffer = RenderHandler.beginLines(renderTypeBuffer);
|
||||
// Matrix4f matrixPos = matrixStack.last().pose();
|
||||
//
|
||||
// Vec3 pos = m.position.add(epsilon);
|
||||
//
|
||||
// buffer.vertex(matrixPos, (float) pos.x - m.radius, (float) pos.y, (float) pos.z).color(colorX.getRed(), colorX.getGreen(), colorX.getBlue(), lineAlpha).endVertex();
|
||||
// buffer.vertex(matrixPos, (float) pos.x + m.radius, (float) pos.y, (float) pos.z).color(colorX.getRed(), colorX.getGreen(), colorX.getBlue(), lineAlpha).endVertex();
|
||||
// buffer.vertex(matrixPos, (float) pos.x, (float) pos.y - m.radius, (float) pos.z).color(colorY.getRed(), colorY.getGreen(), colorY.getBlue(), lineAlpha).endVertex();
|
||||
// buffer.vertex(matrixPos, (float) pos.x, (float) pos.y + m.radius, (float) pos.z).color(colorY.getRed(), colorY.getGreen(), colorY.getBlue(), lineAlpha).endVertex();
|
||||
// buffer.vertex(matrixPos, (float) pos.x, (float) pos.y, (float) pos.z - m.radius).color(colorZ.getRed(), colorZ.getGreen(), colorZ.getBlue(), lineAlpha).endVertex();
|
||||
// buffer.vertex(matrixPos, (float) pos.x, (float) pos.y, (float) pos.z + m.radius).color(colorZ.getRed(), colorZ.getGreen(), colorZ.getBlue(), lineAlpha).endVertex();
|
||||
//
|
||||
// RenderHandler.endLines(renderTypeBuffer);
|
||||
// }
|
||||
protected static final Color colorX = new Color(255, 72, 52);
|
||||
protected static final Color colorY = new Color(67, 204, 51);
|
||||
protected static final Color colorZ = new Color(52, 247, 255);
|
||||
protected static final Color colorRadial = new Color(52, 247, 255);
|
||||
protected static final int lineAlpha = 200;
|
||||
protected static final int planeAlpha = 50;
|
||||
protected static final Vec3 epsilon = new Vec3(0.001, 0.001, 0.001); //prevents z-fighting
|
||||
|
||||
public static void render(PoseStack ms, BufferSource buffer) {
|
||||
List<BaseModifier> modifierSettingsList = EffortlessBuildingClient.BUILD_MODIFIERS.getModifierSettingsList();
|
||||
|
||||
for (BaseModifier modifierSettings : modifierSettingsList) {
|
||||
if (modifierSettings == null) continue;
|
||||
if (modifierSettings instanceof Mirror) {
|
||||
renderMirror(ms, buffer, (Mirror) modifierSettings);
|
||||
} else if (modifierSettings instanceof RadialMirror) {
|
||||
renderRadialMirror(ms, buffer, (RadialMirror) modifierSettings);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Mirror lines and areas
|
||||
private static void renderMirror(PoseStack ms, BufferSource buffer, Mirror m) {
|
||||
|
||||
if (m != null && m.enabled && (m.mirrorX || m.mirrorY || m.mirrorZ)) {
|
||||
Vec3 pos = m.position.add(epsilon);
|
||||
int radius = m.radius;
|
||||
|
||||
if (m.mirrorX) {
|
||||
Vec3 posA = new Vec3(pos.x, pos.y - radius, pos.z - radius);
|
||||
Vec3 posB = new Vec3(pos.x, pos.y + radius, pos.z + radius);
|
||||
|
||||
drawMirrorPlane(ms, buffer, posA, posB, colorX, m.drawLines, m.drawPlanes, true);
|
||||
}
|
||||
if (m.mirrorY) {
|
||||
Vec3 posA = new Vec3(pos.x - radius, pos.y, pos.z - radius);
|
||||
Vec3 posB = new Vec3(pos.x + radius, pos.y, pos.z + radius);
|
||||
|
||||
drawMirrorPlaneY(ms, buffer, posA, posB, colorY, m.drawLines, m.drawPlanes);
|
||||
}
|
||||
if (m.mirrorZ) {
|
||||
Vec3 posA = new Vec3(pos.x - radius, pos.y - radius, pos.z);
|
||||
Vec3 posB = new Vec3(pos.x + radius, pos.y + radius, pos.z);
|
||||
|
||||
drawMirrorPlane(ms, buffer, posA, posB, colorZ, m.drawLines, m.drawPlanes, true);
|
||||
}
|
||||
|
||||
//Draw axis coordinated colors if two or more axes are enabled
|
||||
//(If only one is enabled the lines are that planes color)
|
||||
if (m.drawLines && ((m.mirrorX && m.mirrorY) || (m.mirrorX && m.mirrorZ) || (m.mirrorY && m.mirrorZ))) {
|
||||
drawMirrorLines(ms, buffer, m);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Radial mirror lines and areas
|
||||
private static void renderRadialMirror(PoseStack ms, BufferSource buffer, RadialMirror r) {
|
||||
|
||||
if (r != null && r.enabled) {
|
||||
Vec3 pos = r.position.add(epsilon);
|
||||
int radius = r.radius;
|
||||
|
||||
float angle = 2f * ((float) Math.PI) / r.slices;
|
||||
Vec3 relStartVec = new Vec3(radius, 0, 0);
|
||||
if (r.slices % 4 == 2) relStartVec = relStartVec.yRot(angle / 2f);
|
||||
|
||||
for (int i = 0; i < r.slices; i++) {
|
||||
Vec3 relNewVec = relStartVec.yRot(angle * i);
|
||||
Vec3 newVec = pos.add(relNewVec);
|
||||
|
||||
Vec3 posA = new Vec3(pos.x, pos.y - radius, pos.z);
|
||||
Vec3 posB = new Vec3(newVec.x, pos.y + radius, newVec.z);
|
||||
drawMirrorPlane(ms, buffer, posA, posB, colorRadial, r.drawLines, r.drawPlanes, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected static void drawMirrorPlane(PoseStack ms, BufferSource renderTypeBuffer, Vec3 posA, Vec3 posB, Color c, boolean drawLines, boolean drawPlanes, boolean drawVerticalLines) {
|
||||
|
||||
// GL11.glColor4d(c.getRed(), c.getGreen(), c.getBlue(), planeAlpha);
|
||||
Matrix4f matrixPos = ms.last().pose();
|
||||
|
||||
if (drawPlanes) {
|
||||
VertexConsumer buffer = RenderHandler.beginPlanes(renderTypeBuffer);
|
||||
|
||||
buffer.vertex(matrixPos, (float) posA.x, (float) posA.y, (float) posA.z).color(c.getRed(), c.getGreen(), c.getBlue(), planeAlpha).endVertex();
|
||||
buffer.vertex(matrixPos, (float) posA.x, (float) posB.y, (float) posA.z).color(c.getRed(), c.getGreen(), c.getBlue(), planeAlpha).endVertex();
|
||||
buffer.vertex(matrixPos, (float) posB.x, (float) posA.y, (float) posB.z).color(c.getRed(), c.getGreen(), c.getBlue(), planeAlpha).endVertex();
|
||||
buffer.vertex(matrixPos, (float) posB.x, (float) posB.y, (float) posB.z).color(c.getRed(), c.getGreen(), c.getBlue(), planeAlpha).endVertex();
|
||||
//backface (using triangle strip)
|
||||
buffer.vertex(matrixPos, (float) posA.x, (float) posA.y, (float) posA.z).color(c.getRed(), c.getGreen(), c.getBlue(), planeAlpha).endVertex();
|
||||
buffer.vertex(matrixPos, (float) posA.x, (float) posB.y, (float) posA.z).color(c.getRed(), c.getGreen(), c.getBlue(), planeAlpha).endVertex();
|
||||
|
||||
RenderHandler.endPlanes(renderTypeBuffer);
|
||||
}
|
||||
|
||||
if (drawLines) {
|
||||
VertexConsumer buffer = RenderHandler.beginLines(renderTypeBuffer);
|
||||
|
||||
Vec3 middle = posA.add(posB).scale(0.5);
|
||||
buffer.vertex(matrixPos, (float) posA.x, (float) middle.y, (float) posA.z).color(c.getRed(), c.getGreen(), c.getBlue(), lineAlpha).endVertex();
|
||||
buffer.vertex(matrixPos, (float) posB.x, (float) middle.y, (float) posB.z).color(c.getRed(), c.getGreen(), c.getBlue(), lineAlpha).endVertex();
|
||||
if (drawVerticalLines) {
|
||||
buffer.vertex(matrixPos, (float) middle.x, (float) posA.y, (float) middle.z).color(c.getRed(), c.getGreen(), c.getBlue(), lineAlpha).endVertex();
|
||||
buffer.vertex(matrixPos, (float) middle.x, (float) posB.y, (float) middle.z).color(c.getRed(), c.getGreen(), c.getBlue(), lineAlpha).endVertex();
|
||||
}
|
||||
|
||||
RenderHandler.endLines(renderTypeBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
protected static void drawMirrorPlaneY(PoseStack matrixStack, BufferSource renderTypeBuffer, Vec3 posA, Vec3 posB, Color c, boolean drawLines, boolean drawPlanes) {
|
||||
|
||||
// GL11.glColor4d(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha());
|
||||
Matrix4f matrixPos = matrixStack.last().pose();
|
||||
|
||||
if (drawPlanes) {
|
||||
VertexConsumer buffer = RenderHandler.beginPlanes(renderTypeBuffer);
|
||||
|
||||
buffer.vertex(matrixPos, (float) posA.x, (float) posA.y, (float) posA.z).color(c.getRed(), c.getGreen(), c.getBlue(), planeAlpha).endVertex();
|
||||
buffer.vertex(matrixPos, (float) posA.x, (float) posA.y, (float) posB.z).color(c.getRed(), c.getGreen(), c.getBlue(), planeAlpha).endVertex();
|
||||
buffer.vertex(matrixPos, (float) posB.x, (float) posA.y, (float) posA.z).color(c.getRed(), c.getGreen(), c.getBlue(), planeAlpha).endVertex();
|
||||
buffer.vertex(matrixPos, (float) posB.x, (float) posA.y, (float) posB.z).color(c.getRed(), c.getGreen(), c.getBlue(), planeAlpha).endVertex();
|
||||
//backface (using triangle strip)
|
||||
buffer.vertex(matrixPos, (float) posA.x, (float) posA.y, (float) posA.z).color(c.getRed(), c.getGreen(), c.getBlue(), planeAlpha).endVertex();
|
||||
buffer.vertex(matrixPos, (float) posA.x, (float) posA.y, (float) posB.z).color(c.getRed(), c.getGreen(), c.getBlue(), planeAlpha).endVertex();
|
||||
|
||||
RenderHandler.endPlanes(renderTypeBuffer);
|
||||
}
|
||||
|
||||
if (drawLines) {
|
||||
VertexConsumer buffer = RenderHandler.beginLines(renderTypeBuffer);
|
||||
|
||||
Vec3 middle = posA.add(posB).scale(0.5);
|
||||
buffer.vertex(matrixPos, (float) middle.x, (float) middle.y, (float) posA.z).color(c.getRed(), c.getGreen(), c.getBlue(), lineAlpha).endVertex();
|
||||
buffer.vertex(matrixPos, (float) middle.x, (float) middle.y, (float) posB.z).color(c.getRed(), c.getGreen(), c.getBlue(), lineAlpha).endVertex();
|
||||
buffer.vertex(matrixPos, (float) posA.x, (float) middle.y, (float) middle.z).color(c.getRed(), c.getGreen(), c.getBlue(), lineAlpha).endVertex();
|
||||
buffer.vertex(matrixPos, (float) posB.x, (float) middle.y, (float) middle.z).color(c.getRed(), c.getGreen(), c.getBlue(), lineAlpha).endVertex();
|
||||
|
||||
RenderHandler.endLines(renderTypeBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
protected static void drawMirrorLines(PoseStack matrixStack, BufferSource renderTypeBuffer, Mirror m) {
|
||||
|
||||
// GL11.glColor4d(100, 100, 100, 255);
|
||||
VertexConsumer buffer = RenderHandler.beginLines(renderTypeBuffer);
|
||||
Matrix4f matrixPos = matrixStack.last().pose();
|
||||
|
||||
Vec3 pos = m.position.add(epsilon);
|
||||
|
||||
buffer.vertex(matrixPos, (float) pos.x - m.radius, (float) pos.y, (float) pos.z).color(colorX.getRed(), colorX.getGreen(), colorX.getBlue(), lineAlpha).endVertex();
|
||||
buffer.vertex(matrixPos, (float) pos.x + m.radius, (float) pos.y, (float) pos.z).color(colorX.getRed(), colorX.getGreen(), colorX.getBlue(), lineAlpha).endVertex();
|
||||
buffer.vertex(matrixPos, (float) pos.x, (float) pos.y - m.radius, (float) pos.z).color(colorY.getRed(), colorY.getGreen(), colorY.getBlue(), lineAlpha).endVertex();
|
||||
buffer.vertex(matrixPos, (float) pos.x, (float) pos.y + m.radius, (float) pos.z).color(colorY.getRed(), colorY.getGreen(), colorY.getBlue(), lineAlpha).endVertex();
|
||||
buffer.vertex(matrixPos, (float) pos.x, (float) pos.y, (float) pos.z - m.radius).color(colorZ.getRed(), colorZ.getGreen(), colorZ.getBlue(), lineAlpha).endVertex();
|
||||
buffer.vertex(matrixPos, (float) pos.x, (float) pos.y, (float) pos.z + m.radius).color(colorZ.getRed(), colorZ.getGreen(), colorZ.getBlue(), lineAlpha).endVertex();
|
||||
|
||||
RenderHandler.endLines(renderTypeBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,24 +29,21 @@ public class RenderHandler {
|
||||
public static void onRender(RenderLevelStageEvent event) {
|
||||
if (event.getStage() != RenderLevelStageEvent.Stage.AFTER_TRANSLUCENT_BLOCKS) return;
|
||||
|
||||
// Vec3 cameraPos = Minecraft.getInstance().gameRenderer.getMainCamera().getPosition();
|
||||
//
|
||||
PoseStack ms = event.getPoseStack();
|
||||
// BufferBuilder bufferBuilder = Tesselator.getInstance().getBuilder();
|
||||
// MultiBufferSource.BufferSource buffer = MultiBufferSource.immediate(bufferBuilder);
|
||||
//
|
||||
// Player player = Minecraft.getInstance().player;
|
||||
// ModifierSettingsManager.ModifierSettings modifierSettings = ModifierSettingsManager.getModifierSettings(player);
|
||||
//
|
||||
// ms.pushPose();
|
||||
// ms.translate(-cameraPos.x, -cameraPos.y, -cameraPos.z);
|
||||
//
|
||||
// //Mirror and radial mirror lines and areas
|
||||
// ModifierRenderer.render(ms, buffer, modifierSettings);
|
||||
//
|
||||
// ms.popPose();
|
||||
Vec3 cameraPos = Minecraft.getInstance().gameRenderer.getMainCamera().getPosition();
|
||||
|
||||
renderSubText(ms);
|
||||
PoseStack ms = event.getPoseStack();
|
||||
BufferBuilder bufferBuilder = Tesselator.getInstance().getBuilder();
|
||||
MultiBufferSource.BufferSource buffer = MultiBufferSource.immediate(bufferBuilder);
|
||||
|
||||
ms.pushPose();
|
||||
ms.translate(-cameraPos.x, -cameraPos.y, -cameraPos.z);
|
||||
|
||||
//Mirror and radial mirror lines and areas
|
||||
ModifierRenderer.render(ms, buffer);
|
||||
|
||||
ms.popPose();
|
||||
|
||||
// renderSubText(ms);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
||||
Reference in New Issue
Block a user