mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2025-02-04 01:04:58 +01:00
More porty
- Ported blockzapper beams - Terrainzapper now uses outliner utility
This commit is contained in:
parent
57edbe0c38
commit
68b656c6be
13 changed files with 106 additions and 190 deletions
|
@ -4,11 +4,10 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import com.simibubi.create.content.contraptions.KineticDebugger;
|
import com.simibubi.create.content.contraptions.KineticDebugger;
|
||||||
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
|
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
|
||||||
import com.simibubi.create.content.contraptions.components.turntable.TurntableHandler;
|
import com.simibubi.create.content.contraptions.components.turntable.TurntableHandler;
|
||||||
import com.simibubi.create.content.contraptions.relays.belt.item.BeltConnectorHandler;
|
|
||||||
import com.simibubi.create.content.curiosities.zapper.terrainzapper.TerrainZapperRenderHandler;
|
|
||||||
import com.simibubi.create.foundation.config.AllConfigs;
|
import com.simibubi.create.foundation.config.AllConfigs;
|
||||||
import com.simibubi.create.foundation.gui.ScreenOpener;
|
import com.simibubi.create.foundation.gui.ScreenOpener;
|
||||||
import com.simibubi.create.foundation.item.TooltipHelper;
|
import com.simibubi.create.foundation.item.TooltipHelper;
|
||||||
|
@ -18,6 +17,7 @@ import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.ActiveRenderInfo;
|
import net.minecraft.client.renderer.ActiveRenderInfo;
|
||||||
|
import net.minecraft.client.renderer.Atlases;
|
||||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||||
import net.minecraft.client.renderer.texture.OverlayTexture;
|
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
@ -59,13 +59,7 @@ public class ClientEvents {
|
||||||
}
|
}
|
||||||
|
|
||||||
ScreenOpener.tick();
|
ScreenOpener.tick();
|
||||||
onGameTick();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void onGameTick() {
|
|
||||||
CreateClient.gameTick();
|
CreateClient.gameTick();
|
||||||
BeltConnectorHandler.gameTick();
|
|
||||||
TerrainZapperRenderHandler.tick();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
|
@ -76,7 +70,6 @@ public class ClientEvents {
|
||||||
|
|
||||||
ms.push();
|
ms.push();
|
||||||
ms.translate(-view.getX(), -view.getY(), -view.getZ());
|
ms.translate(-view.getX(), -view.getY(), -view.getZ());
|
||||||
|
|
||||||
IRenderTypeBuffer.Impl buffer = Minecraft.getInstance()
|
IRenderTypeBuffer.Impl buffer = Minecraft.getInstance()
|
||||||
.getBufferBuilders()
|
.getBufferBuilders()
|
||||||
.getEntityVertexConsumers();
|
.getEntityVertexConsumers();
|
||||||
|
@ -84,10 +77,7 @@ public class ClientEvents {
|
||||||
CreateClient.schematicHandler.render(ms, buffer, 0xF000F0, OverlayTexture.DEFAULT_UV);
|
CreateClient.schematicHandler.render(ms, buffer, 0xF000F0, OverlayTexture.DEFAULT_UV);
|
||||||
CreateClient.outliner.renderOutlines(ms, buffer);
|
CreateClient.outliner.renderOutlines(ms, buffer);
|
||||||
KineticDebugger.renderSourceOutline(ms, buffer);
|
KineticDebugger.renderSourceOutline(ms, buffer);
|
||||||
TerrainZapperRenderHandler.render(ms, buffer);
|
|
||||||
|
|
||||||
ms.pop();
|
ms.pop();
|
||||||
|
|
||||||
buffer.draw();
|
buffer.draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,9 @@ import java.util.function.Function;
|
||||||
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
|
import com.simibubi.create.content.contraptions.base.KineticTileEntityRenderer;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.ChassisRangeDisplay;
|
import com.simibubi.create.content.contraptions.components.structureMovement.ChassisRangeDisplay;
|
||||||
import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionRenderer;
|
import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionRenderer;
|
||||||
|
import com.simibubi.create.content.contraptions.relays.belt.item.BeltConnectorHandler;
|
||||||
|
import com.simibubi.create.content.curiosities.zapper.ZapperRenderHandler;
|
||||||
|
import com.simibubi.create.content.curiosities.zapper.terrainzapper.TerrainZapperRenderHandler;
|
||||||
import com.simibubi.create.content.schematics.ClientSchematicLoader;
|
import com.simibubi.create.content.schematics.ClientSchematicLoader;
|
||||||
import com.simibubi.create.content.schematics.client.SchematicAndQuillHandler;
|
import com.simibubi.create.content.schematics.client.SchematicAndQuillHandler;
|
||||||
import com.simibubi.create.content.schematics.client.SchematicHandler;
|
import com.simibubi.create.content.schematics.client.SchematicHandler;
|
||||||
|
@ -89,11 +92,14 @@ public class CreateClient {
|
||||||
schematicSender.tick();
|
schematicSender.tick();
|
||||||
schematicAndQuillHandler.tick();
|
schematicAndQuillHandler.tick();
|
||||||
schematicHandler.tick();
|
schematicHandler.tick();
|
||||||
|
BeltConnectorHandler.gameTick();
|
||||||
FilteringRenderer.tick();
|
FilteringRenderer.tick();
|
||||||
LinkRenderer.tick();
|
LinkRenderer.tick();
|
||||||
ScrollValueRenderer.tick();
|
ScrollValueRenderer.tick();
|
||||||
ChassisRangeDisplay.tick();
|
ChassisRangeDisplay.tick();
|
||||||
EdgeInteractionRenderer.tick();
|
EdgeInteractionRenderer.tick();
|
||||||
|
TerrainZapperRenderHandler.tick();
|
||||||
|
ZapperRenderHandler.tick();
|
||||||
outliner.tickOutlines();
|
outliner.tickOutlines();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -84,11 +84,6 @@ public abstract class KineticBlock extends Block implements IRotate {
|
||||||
kte.updateSpeed = true;
|
kte.updateSpeed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Override // TODO 1.15 register layer
|
|
||||||
// public boolean canRenderInLayer(BlockState state, BlockRenderLayer layer) {
|
|
||||||
// return hasStaticPart() && layer == getRenderLayer();
|
|
||||||
// }
|
|
||||||
|
|
||||||
protected abstract boolean hasStaticPart();
|
protected abstract boolean hasStaticPart();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -16,9 +16,9 @@ import com.simibubi.create.content.contraptions.relays.belt.BeltBlock.Slope;
|
||||||
import com.simibubi.create.content.contraptions.relays.belt.transport.TransportedItemStack;
|
import com.simibubi.create.content.contraptions.relays.belt.transport.TransportedItemStack;
|
||||||
import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer;
|
import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer;
|
||||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||||
|
import com.simibubi.create.foundation.utility.MatrixStacker;
|
||||||
import com.simibubi.create.foundation.utility.ShadowRenderHelper;
|
import com.simibubi.create.foundation.utility.ShadowRenderHelper;
|
||||||
import com.simibubi.create.foundation.utility.SuperByteBuffer;
|
import com.simibubi.create.foundation.utility.SuperByteBuffer;
|
||||||
import com.simibubi.create.foundation.utility.TessellatorHelper;
|
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
@ -36,7 +36,6 @@ import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.util.math.Vec3i;
|
import net.minecraft.util.math.Vec3i;
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public class BeltRenderer extends SafeTileEntityRenderer<BeltTileEntity> {
|
public class BeltRenderer extends SafeTileEntityRenderer<BeltTileEntity> {
|
||||||
|
|
||||||
public BeltRenderer(TileEntityRendererDispatcher dispatcher) {
|
public BeltRenderer(TileEntityRendererDispatcher dispatcher) {
|
||||||
|
@ -112,7 +111,7 @@ public class BeltRenderer extends SafeTileEntityRenderer<BeltTileEntity> {
|
||||||
|
|
||||||
for (TransportedItemStack transported : te.getInventory().getItems()) {
|
for (TransportedItemStack transported : te.getInventory().getItems()) {
|
||||||
ms.push();
|
ms.push();
|
||||||
TessellatorHelper.fightZFighting(transported.angle, ms);
|
MatrixStacker.of(ms).nudge(transported.angle);
|
||||||
float offset = MathHelper.lerp(partialTicks, transported.prevBeltPosition, transported.beltPosition);
|
float offset = MathHelper.lerp(partialTicks, transported.prevBeltPosition, transported.beltPosition);
|
||||||
float sideOffset = MathHelper.lerp(partialTicks, transported.prevSideOffset, transported.sideOffset);
|
float sideOffset = MathHelper.lerp(partialTicks, transported.prevSideOffset, transported.sideOffset);
|
||||||
float verticalMovement = verticality;
|
float verticalMovement = verticality;
|
||||||
|
|
|
@ -5,23 +5,19 @@ import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
import org.lwjgl.opengl.GL11;
|
|
||||||
|
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
|
||||||
import com.simibubi.create.AllSoundEvents;
|
import com.simibubi.create.AllSoundEvents;
|
||||||
import com.simibubi.create.foundation.utility.TessellatorHelper;
|
import com.simibubi.create.CreateClient;
|
||||||
|
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||||
|
import com.simibubi.create.foundation.utility.ColorHelper;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.entity.player.AbstractClientPlayerEntity;
|
import net.minecraft.client.entity.player.AbstractClientPlayerEntity;
|
||||||
import net.minecraft.client.entity.player.ClientPlayerEntity;
|
import net.minecraft.client.entity.player.ClientPlayerEntity;
|
||||||
import net.minecraft.client.renderer.BufferBuilder;
|
|
||||||
import net.minecraft.client.renderer.FirstPersonRenderer;
|
import net.minecraft.client.renderer.FirstPersonRenderer;
|
||||||
import net.minecraft.client.renderer.Tessellator;
|
|
||||||
import net.minecraft.client.renderer.Vector3f;
|
import net.minecraft.client.renderer.Vector3f;
|
||||||
import net.minecraft.client.renderer.entity.PlayerRenderer;
|
import net.minecraft.client.renderer.entity.PlayerRenderer;
|
||||||
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
import net.minecraft.client.renderer.model.ItemCameraTransforms;
|
||||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
|
||||||
import net.minecraft.client.world.ClientWorld;
|
import net.minecraft.client.world.ClientWorld;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.particles.ParticleTypes;
|
import net.minecraft.particles.ParticleTypes;
|
||||||
|
@ -33,13 +29,9 @@ import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.client.event.RenderHandEvent;
|
import net.minecraftforge.client.event.RenderHandEvent;
|
||||||
import net.minecraftforge.client.event.RenderWorldLastEvent;
|
|
||||||
import net.minecraftforge.event.TickEvent.ClientTickEvent;
|
|
||||||
import net.minecraftforge.event.TickEvent.Phase;
|
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
@EventBusSubscriber(value = Dist.CLIENT)
|
@EventBusSubscriber(value = Dist.CLIENT)
|
||||||
public class ZapperRenderHandler {
|
public class ZapperRenderHandler {
|
||||||
|
|
||||||
|
@ -79,7 +71,8 @@ public class ZapperRenderHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Vec3d getExactBarrelPos(boolean mainHand) {
|
public static Vec3d getExactBarrelPos(boolean mainHand) {
|
||||||
float partialTicks = Minecraft.getInstance().getRenderPartialTicks();
|
float partialTicks = Minecraft.getInstance()
|
||||||
|
.getRenderPartialTicks();
|
||||||
ClientPlayerEntity player = Minecraft.getInstance().player;
|
ClientPlayerEntity player = Minecraft.getInstance().player;
|
||||||
float yaw = (float) ((player.getYaw(partialTicks)) / -180 * Math.PI);
|
float yaw = (float) ((player.getYaw(partialTicks)) / -180 * Math.PI);
|
||||||
float pitch = (float) ((player.getPitch(partialTicks)) / -180 * Math.PI);
|
float pitch = (float) ((player.getPitch(partialTicks)) / -180 * Math.PI);
|
||||||
|
@ -87,22 +80,14 @@ public class ZapperRenderHandler {
|
||||||
float zOffset = ((float) Minecraft.getInstance().gameSettings.fov - 70) / -100;
|
float zOffset = ((float) Minecraft.getInstance().gameSettings.fov - 70) / -100;
|
||||||
Vec3d barrelPosNoTransform = new Vec3d(rightHand ? -.35f : .35f, -0.115f, .75f + zOffset);
|
Vec3d barrelPosNoTransform = new Vec3d(rightHand ? -.35f : .35f, -0.115f, .75f + zOffset);
|
||||||
Vec3d barrelPos = player.getEyePosition(partialTicks)
|
Vec3d barrelPos = player.getEyePosition(partialTicks)
|
||||||
.add(barrelPosNoTransform.rotatePitch(pitch).rotateYaw(yaw));
|
.add(barrelPosNoTransform.rotatePitch(pitch)
|
||||||
|
.rotateYaw(yaw));
|
||||||
return barrelPos;
|
return barrelPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
public static void tick() {
|
||||||
public static void onClientTick(ClientTickEvent event) {
|
|
||||||
if (event.phase == Phase.START)
|
|
||||||
return;
|
|
||||||
if (cachedBeams == null)
|
if (cachedBeams == null)
|
||||||
cachedBeams = new LinkedList<>();
|
cachedBeams = new LinkedList<>();
|
||||||
ClientWorld world = Minecraft.getInstance().world;
|
|
||||||
if (world == null)
|
|
||||||
return;
|
|
||||||
ClientPlayerEntity player = Minecraft.getInstance().player;
|
|
||||||
if (player == null)
|
|
||||||
return;
|
|
||||||
cachedBeams.removeIf(b -> b.itensity < .1f);
|
cachedBeams.removeIf(b -> b.itensity < .1f);
|
||||||
cachedBeams.forEach(b -> b.itensity *= .4f);
|
cachedBeams.forEach(b -> b.itensity *= .4f);
|
||||||
|
|
||||||
|
@ -110,28 +95,16 @@ public class ZapperRenderHandler {
|
||||||
lastRightHandAnimation = rightHandAnimation;
|
lastRightHandAnimation = rightHandAnimation;
|
||||||
leftHandAnimation *= 0.8f;
|
leftHandAnimation *= 0.8f;
|
||||||
rightHandAnimation *= 0.8f;
|
rightHandAnimation *= 0.8f;
|
||||||
}
|
|
||||||
|
|
||||||
@SubscribeEvent
|
|
||||||
public static void onRenderWorld(RenderWorldLastEvent event) {
|
|
||||||
if (cachedBeams == null || cachedBeams.isEmpty())
|
if (cachedBeams == null || cachedBeams.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
cachedBeams.forEach(beam -> {
|
cachedBeams.forEach(beam -> {
|
||||||
// TODO 1.15 buffered render
|
CreateClient.outliner.showLine(beam, beam.getStart(), beam.end)
|
||||||
TessellatorHelper.prepareForDrawing();
|
.disableNormals()
|
||||||
RenderSystem.disableTexture();
|
.colored(ColorHelper.mixColors(0xffffff, ColorHelper.rainbowColor(AnimationTickHolder.ticks),
|
||||||
RenderSystem.lineWidth(beam.itensity * 40);
|
MathHelper.clamp(beam.itensity * 3, 0, 1)))
|
||||||
|
.lineWidth(beam.itensity * 1 / 4f);
|
||||||
BufferBuilder bufferBuilder = Tessellator.getInstance().getBuffer();
|
|
||||||
bufferBuilder.begin(GL11.GL_LINE_STRIP, DefaultVertexFormats.POSITION);
|
|
||||||
bufferBuilder.vertex(beam.getStart().x, beam.getStart().y, beam.getStart().z).endVertex();
|
|
||||||
bufferBuilder.vertex(beam.end.x, beam.end.y, beam.end.z).endVertex();
|
|
||||||
Tessellator.getInstance().draw();
|
|
||||||
|
|
||||||
RenderSystem.lineWidth(1);
|
|
||||||
RenderSystem.enableTexture();
|
|
||||||
TessellatorHelper.cleanUpAfterDrawing();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,7 +123,8 @@ public class ZapperRenderHandler {
|
||||||
|
|
||||||
public static void playSound(Hand hand, BlockPos position) {
|
public static void playSound(Hand hand, BlockPos position) {
|
||||||
float pitch = hand == Hand.MAIN_HAND ? 2f : 0.9f;
|
float pitch = hand == Hand.MAIN_HAND ? 2f : 0.9f;
|
||||||
Minecraft.getInstance().world.playSound(position, AllSoundEvents.BLOCKZAPPER_PLACE.get(), SoundCategory.BLOCKS, 0.8f, pitch, false);
|
Minecraft.getInstance().world.playSound(position, AllSoundEvents.BLOCKZAPPER_PLACE.get(), SoundCategory.BLOCKS,
|
||||||
|
0.8f, pitch, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addBeam(LaserBeam beam) {
|
public static void addBeam(LaserBeam beam) {
|
||||||
|
@ -181,9 +155,7 @@ public class ZapperRenderHandler {
|
||||||
|
|
||||||
MatrixStack ms = event.getMatrixStack();
|
MatrixStack ms = event.getMatrixStack();
|
||||||
|
|
||||||
// TODO 1.15 buffered render
|
|
||||||
ms.push();
|
ms.push();
|
||||||
|
|
||||||
float recoil = rightHand ? MathHelper.lerp(event.getPartialTicks(), lastRightHandAnimation, rightHandAnimation)
|
float recoil = rightHand ? MathHelper.lerp(event.getPartialTicks(), lastRightHandAnimation, rightHandAnimation)
|
||||||
: MathHelper.lerp(event.getPartialTicks(), lastLeftHandAnimation, leftHandAnimation);
|
: MathHelper.lerp(event.getPartialTicks(), lastLeftHandAnimation, leftHandAnimation);
|
||||||
|
|
||||||
|
@ -208,18 +180,22 @@ public class ZapperRenderHandler {
|
||||||
ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(f * f6 * 70.0F));
|
ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(f * f6 * 70.0F));
|
||||||
ms.multiply(Vector3f.POSITIVE_Z.getDegreesQuaternion(f * f5 * -20.0F));
|
ms.multiply(Vector3f.POSITIVE_Z.getDegreesQuaternion(f * f5 * -20.0F));
|
||||||
AbstractClientPlayerEntity abstractclientplayerentity = mc.player;
|
AbstractClientPlayerEntity abstractclientplayerentity = mc.player;
|
||||||
mc.getTextureManager().bindTexture(abstractclientplayerentity.getLocationSkin());
|
mc.getTextureManager()
|
||||||
|
.bindTexture(abstractclientplayerentity.getLocationSkin());
|
||||||
ms.translate(f * -1.0F, 3.6F, 3.5F);
|
ms.translate(f * -1.0F, 3.6F, 3.5F);
|
||||||
ms.multiply(Vector3f.POSITIVE_Z.getDegreesQuaternion(f * 120.0F));
|
ms.multiply(Vector3f.POSITIVE_Z.getDegreesQuaternion(f * 120.0F));
|
||||||
ms.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(200.0F));
|
ms.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(200.0F));
|
||||||
ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(f * -135.0F));
|
ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(f * -135.0F));
|
||||||
ms.translate(f * 5.6F, 0.0F, 0.0F);
|
ms.translate(f * 5.6F, 0.0F, 0.0F);
|
||||||
ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(f * 40.0F));
|
ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(f * 40.0F));
|
||||||
PlayerRenderer playerrenderer = (PlayerRenderer) mc.getRenderManager().getRenderer(abstractclientplayerentity);
|
PlayerRenderer playerrenderer = (PlayerRenderer) mc.getRenderManager()
|
||||||
|
.getRenderer(abstractclientplayerentity);
|
||||||
if (rightHand) {
|
if (rightHand) {
|
||||||
playerrenderer.renderRightArm(event.getMatrixStack(), event.getBuffers(), event.getLight(), abstractclientplayerentity);
|
playerrenderer.renderRightArm(event.getMatrixStack(), event.getBuffers(), event.getLight(),
|
||||||
|
abstractclientplayerentity);
|
||||||
} else {
|
} else {
|
||||||
playerrenderer.renderLeftArm(event.getMatrixStack(), event.getBuffers(), event.getLight(), abstractclientplayerentity);
|
playerrenderer.renderLeftArm(event.getMatrixStack(), event.getBuffers(), event.getLight(),
|
||||||
|
abstractclientplayerentity);
|
||||||
}
|
}
|
||||||
ms.pop();
|
ms.pop();
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ import com.mojang.blaze3d.platform.GlStateManager.SourceFactor;
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import com.simibubi.create.foundation.gui.AbstractSimiScreen;
|
import com.simibubi.create.foundation.gui.AbstractSimiScreen;
|
||||||
import com.simibubi.create.foundation.gui.AllGuiTextures;
|
import com.simibubi.create.foundation.gui.AllGuiTextures;
|
||||||
|
import com.simibubi.create.foundation.gui.GuiGameElement;
|
||||||
import com.simibubi.create.foundation.gui.widgets.IconButton;
|
import com.simibubi.create.foundation.gui.widgets.IconButton;
|
||||||
import com.simibubi.create.foundation.networking.AllPackets;
|
import com.simibubi.create.foundation.networking.AllPackets;
|
||||||
import com.simibubi.create.foundation.networking.NbtPacket;
|
import com.simibubi.create.foundation.networking.NbtPacket;
|
||||||
|
@ -167,9 +168,7 @@ public class ZapperScreen extends AbstractSimiScreen {
|
||||||
|
|
||||||
RenderSystem.translated(0, -5, 0);
|
RenderSystem.translated(0, -5, 0);
|
||||||
|
|
||||||
minecraft.getBlockRendererDispatcher().renderBlock(state, new MatrixStack(),
|
GuiGameElement.of(state).render();
|
||||||
getMinecraft().getBufferBuilders().getEffectVertexConsumers(), 0xF000F0, OverlayTexture.DEFAULT_UV,
|
|
||||||
EmptyModelData.INSTANCE);
|
|
||||||
|
|
||||||
RenderSystem.popMatrix();
|
RenderSystem.popMatrix();
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@ import com.simibubi.create.foundation.utility.Lang;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.util.math.shapes.VoxelShape;
|
|
||||||
|
|
||||||
public abstract class Brush {
|
public abstract class Brush {
|
||||||
|
|
||||||
|
@ -47,8 +46,6 @@ public abstract class Brush {
|
||||||
return BlockPos.ZERO;
|
return BlockPos.ZERO;
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract VoxelShape getSelectionBox();
|
|
||||||
|
|
||||||
abstract List<BlockPos> getIncludedPositions();
|
abstract List<BlockPos> getIncludedPositions();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,21 +6,16 @@ import java.util.stream.Collectors;
|
||||||
|
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.Direction.AxisDirection;
|
import net.minecraft.util.Direction.AxisDirection;
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.util.math.shapes.VoxelShape;
|
|
||||||
import net.minecraft.util.math.shapes.VoxelShapes;
|
|
||||||
|
|
||||||
public class CuboidBrush extends Brush {
|
public class CuboidBrush extends Brush {
|
||||||
|
|
||||||
public static final int MAX_SIZE = 32;
|
public static final int MAX_SIZE = 32;
|
||||||
private VoxelShape shape;
|
|
||||||
private List<BlockPos> positions;
|
private List<BlockPos> positions;
|
||||||
|
|
||||||
public CuboidBrush() {
|
public CuboidBrush() {
|
||||||
super(3);
|
super(3);
|
||||||
shape = VoxelShapes.empty();
|
|
||||||
positions = new ArrayList<>();
|
positions = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,16 +23,13 @@ public class CuboidBrush extends Brush {
|
||||||
public void set(int param0, int param1, int param2) {
|
public void set(int param0, int param1, int param2) {
|
||||||
boolean updateShape = this.param0 != param0 || this.param1 != param1 || this.param2 != param2;
|
boolean updateShape = this.param0 != param0 || this.param1 != param1 || this.param2 != param2;
|
||||||
super.set(param0, param1, param2);
|
super.set(param0, param1, param2);
|
||||||
|
|
||||||
if (updateShape) {
|
if (updateShape) {
|
||||||
BlockPos zero = BlockPos.ZERO;
|
BlockPos zero = BlockPos.ZERO;
|
||||||
shape = VoxelShapes.create(new AxisAlignedBB(zero).grow(1 / 32f)
|
|
||||||
.grow(((param0 - 1) / 2f), ((param1 - 1) / 2f), ((param2 - 1) / 2f))
|
|
||||||
.offset((1 - param0 % 2) * .5f, (1 - param1 % 2) * .5f, (1 - param2 % 2) * .5f));
|
|
||||||
positions = BlockPos
|
positions = BlockPos
|
||||||
.getAllInBox(zero.add((param0 - 1) / -2, (param1 - 1) / -2, (param2 - 1) / -2),
|
.getAllInBox(zero.add((param0 - 1) / -2, (param1 - 1) / -2, (param2 - 1) / -2),
|
||||||
zero.add((param0) / 2, (param1) / 2, (param2) / 2))
|
zero.add((param0) / 2, (param1) / 2, (param2) / 2))
|
||||||
.map(BlockPos::new).collect(Collectors.toList());
|
.map(BlockPos::new)
|
||||||
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,8 +54,8 @@ public class CuboidBrush extends Brush {
|
||||||
int y = (param1 + (param1 == 0 ? 0 : offset)) / 2;
|
int y = (param1 + (param1 == 0 ? 0 : offset)) / 2;
|
||||||
int z = (param2 + (param2 == 0 ? 0 : offset)) / 2;
|
int z = (param2 + (param2 == 0 ? 0 : offset)) / 2;
|
||||||
|
|
||||||
return BlockPos.ZERO.offset(face,
|
return BlockPos.ZERO.offset(face, face.getAxis()
|
||||||
face.getAxis().getCoordinate(x, y, z) * (option == PlacementOptions.Attached ? 1 : -1));
|
.getCoordinate(x, y, z) * (option == PlacementOptions.Attached ? 1 : -1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -71,9 +63,4 @@ public class CuboidBrush extends Brush {
|
||||||
return positions;
|
return positions;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
VoxelShape getSelectionBox() {
|
|
||||||
return shape;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,46 +11,37 @@ import org.apache.commons.lang3.tuple.Pair;
|
||||||
import com.simibubi.create.foundation.utility.Lang;
|
import com.simibubi.create.foundation.utility.Lang;
|
||||||
import com.simibubi.create.foundation.utility.VecHelper;
|
import com.simibubi.create.foundation.utility.VecHelper;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.Direction.AxisDirection;
|
import net.minecraft.util.Direction.AxisDirection;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.util.math.shapes.VoxelShape;
|
|
||||||
import net.minecraft.util.math.shapes.VoxelShapes;
|
|
||||||
|
|
||||||
public class CylinderBrush extends Brush {
|
public class CylinderBrush extends Brush {
|
||||||
|
|
||||||
public static final int MAX_RADIUS = 6;
|
public static final int MAX_RADIUS = 8;
|
||||||
public static final int MAX_HEIGHT = 8;
|
public static final int MAX_HEIGHT = 8;
|
||||||
private Map<Pair<Integer, Integer>, Pair<List<BlockPos>, VoxelShape>> cachedBrushes;
|
private Map<Pair<Integer, Integer>, List<BlockPos>> cachedBrushes;
|
||||||
|
|
||||||
public CylinderBrush() {
|
public CylinderBrush() {
|
||||||
super(2);
|
super(2);
|
||||||
|
|
||||||
cachedBrushes = new HashMap<>();
|
cachedBrushes = new HashMap<>();
|
||||||
VoxelShape fullCube = Block.makeCuboidShape(-.5f, -.5f, -.5f, 16.5f, 16.5f, 16.5f);
|
|
||||||
|
|
||||||
for (int i = 0; i <= MAX_RADIUS; i++) {
|
for (int i = 0; i <= MAX_RADIUS; i++) {
|
||||||
int radius = i;
|
int radius = i;
|
||||||
VoxelShape shape = VoxelShapes.empty();
|
|
||||||
List<BlockPos> positions =
|
List<BlockPos> positions =
|
||||||
BlockPos.getAllInBox(BlockPos.ZERO.add(-i - 1, 0, -i - 1), BlockPos.ZERO.add(i + 1, 0, i + 1))
|
BlockPos.getAllInBox(BlockPos.ZERO.add(-i - 1, 0, -i - 1), BlockPos.ZERO.add(i + 1, 0, i + 1))
|
||||||
.map(BlockPos::new).filter(p -> VecHelper.getCenterOf(p)
|
.map(BlockPos::new)
|
||||||
|
.filter(p -> VecHelper.getCenterOf(p)
|
||||||
.distanceTo(VecHelper.getCenterOf(BlockPos.ZERO)) < radius + .42f)
|
.distanceTo(VecHelper.getCenterOf(BlockPos.ZERO)) < radius + .42f)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
for (BlockPos p : positions)
|
|
||||||
shape = VoxelShapes.or(shape, fullCube.withOffset(p.getX(), p.getY(), p.getZ()));
|
|
||||||
for (int h = 0; h <= MAX_HEIGHT; h++) {
|
for (int h = 0; h <= MAX_HEIGHT; h++) {
|
||||||
List<BlockPos> stackedPositions = new ArrayList<>();
|
List<BlockPos> stackedPositions = new ArrayList<>();
|
||||||
VoxelShape stackedShape = shape.simplify();
|
|
||||||
for (int layer = 0; layer < h; layer++) {
|
for (int layer = 0; layer < h; layer++) {
|
||||||
int yOffset = layer - h / 2;
|
int yOffset = layer - h / 2;
|
||||||
stackedShape = VoxelShapes.or(stackedShape, shape.withOffset(0, yOffset, 0));
|
|
||||||
for (BlockPos p : positions)
|
for (BlockPos p : positions)
|
||||||
stackedPositions.add(p.up(yOffset));
|
stackedPositions.add(p.up(yOffset));
|
||||||
}
|
}
|
||||||
cachedBrushes.put(Pair.of(i, h), Pair.of(stackedPositions, stackedShape.simplify()));
|
cachedBrushes.put(Pair.of(i, h), stackedPositions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,8 +57,8 @@ public class CylinderBrush extends Brush {
|
||||||
int r = (param0 + 1 + offset);
|
int r = (param0 + 1 + offset);
|
||||||
int y = (param1 + (param1 == 0 ? 0 : yOffset)) / 2;
|
int y = (param1 + (param1 == 0 ? 0 : yOffset)) / 2;
|
||||||
|
|
||||||
return BlockPos.ZERO.offset(face,
|
return BlockPos.ZERO.offset(face, (face.getAxis()
|
||||||
(face.getAxis().isVertical() ? y : r) * (option == PlacementOptions.Attached ? 1 : -1));
|
.isVertical() ? y : r) * (option == PlacementOptions.Attached ? 1 : -1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -85,18 +76,9 @@ public class CylinderBrush extends Brush {
|
||||||
return paramIndex == 0 ? Lang.translate("generic.radius") : super.getParamLabel(paramIndex);
|
return paramIndex == 0 ? Lang.translate("generic.radius") : super.getParamLabel(paramIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
VoxelShape getSelectionBox() {
|
|
||||||
return getEntry(param0, param1).getRight();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<BlockPos> getIncludedPositions() {
|
public List<BlockPos> getIncludedPositions() {
|
||||||
return getEntry(param0, param1).getLeft();
|
return cachedBrushes.get(Pair.of(Integer.valueOf(param0), Integer.valueOf(param1)));
|
||||||
}
|
|
||||||
|
|
||||||
protected Pair<List<BlockPos>, VoxelShape> getEntry(int radius, int height) {
|
|
||||||
return cachedBrushes.get(Pair.of(Integer.valueOf(radius), Integer.valueOf(height)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,22 +5,17 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
|
||||||
|
|
||||||
import com.simibubi.create.foundation.utility.Lang;
|
import com.simibubi.create.foundation.utility.Lang;
|
||||||
import com.simibubi.create.foundation.utility.VecHelper;
|
import com.simibubi.create.foundation.utility.VecHelper;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.util.math.shapes.VoxelShape;
|
|
||||||
import net.minecraft.util.math.shapes.VoxelShapes;
|
|
||||||
|
|
||||||
public class SphereBrush extends Brush {
|
public class SphereBrush extends Brush {
|
||||||
|
|
||||||
public static final int MAX_RADIUS = 6;
|
public static final int MAX_RADIUS = 10;
|
||||||
private Map<Integer, Pair<List<BlockPos>, VoxelShape>> cachedBrushes;
|
private Map<Integer, List<BlockPos>> cachedBrushes;
|
||||||
|
|
||||||
public SphereBrush() {
|
public SphereBrush() {
|
||||||
super(1);
|
super(1);
|
||||||
|
@ -28,17 +23,12 @@ public class SphereBrush extends Brush {
|
||||||
cachedBrushes = new HashMap<>();
|
cachedBrushes = new HashMap<>();
|
||||||
for (int i = 0; i <= MAX_RADIUS; i++) {
|
for (int i = 0; i <= MAX_RADIUS; i++) {
|
||||||
int radius = i;
|
int radius = i;
|
||||||
VoxelShape shape = VoxelShapes.empty();
|
|
||||||
List<BlockPos> positions =
|
List<BlockPos> positions =
|
||||||
BlockPos.getAllInBox(BlockPos.ZERO.add(-i - 1, -i - 1, -i - 1), BlockPos.ZERO.add(i + 1, i + 1, i + 1))
|
BlockPos.getAllInBox(BlockPos.ZERO.add(-i - 1, -i - 1, -i - 1), BlockPos.ZERO.add(i + 1, i + 1, i + 1))
|
||||||
.map(BlockPos::new).filter(p -> VecHelper.getCenterOf(p)
|
.map(BlockPos::new).filter(p -> VecHelper.getCenterOf(p)
|
||||||
.distanceTo(VecHelper.getCenterOf(BlockPos.ZERO)) < radius + .5f)
|
.distanceTo(VecHelper.getCenterOf(BlockPos.ZERO)) < radius + .5f)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
VoxelShape fullCube = Block.makeCuboidShape(-.5f, -.5f, -.5f, 16.5f, 16.5f, 16.5f);
|
cachedBrushes.put(i, positions);
|
||||||
for (BlockPos p : positions)
|
|
||||||
shape = VoxelShapes.or(shape, fullCube.withOffset(p.getX(), p.getY(), p.getZ()));
|
|
||||||
shape = shape.simplify();
|
|
||||||
cachedBrushes.put(i, Pair.of(positions, shape));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,11 +48,6 @@ public class SphereBrush extends Brush {
|
||||||
return MAX_RADIUS;
|
return MAX_RADIUS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
VoxelShape getSelectionBox() {
|
|
||||||
return getEntry(param0).getRight();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
String getParamLabel(int paramIndex) {
|
String getParamLabel(int paramIndex) {
|
||||||
return Lang.translate("generic.radius");
|
return Lang.translate("generic.radius");
|
||||||
|
@ -70,11 +55,7 @@ public class SphereBrush extends Brush {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
List<BlockPos> getIncludedPositions() {
|
List<BlockPos> getIncludedPositions() {
|
||||||
return getEntry(param0).getLeft();
|
return cachedBrushes.get(Integer.valueOf(param0));
|
||||||
}
|
|
||||||
|
|
||||||
protected Pair<List<BlockPos>, VoxelShape> getEntry(int size) {
|
|
||||||
return cachedBrushes.get(Integer.valueOf(size));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,15 @@
|
||||||
package com.simibubi.create.content.curiosities.zapper.terrainzapper;
|
package com.simibubi.create.content.curiosities.zapper.terrainzapper;
|
||||||
|
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import com.simibubi.create.AllItems;
|
import com.simibubi.create.AllItems;
|
||||||
|
import com.simibubi.create.AllSpecialTextures;
|
||||||
|
import com.simibubi.create.CreateClient;
|
||||||
import com.simibubi.create.foundation.utility.NBTHelper;
|
import com.simibubi.create.foundation.utility.NBTHelper;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.entity.player.ClientPlayerEntity;
|
import net.minecraft.client.entity.player.ClientPlayerEntity;
|
||||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
|
||||||
import net.minecraft.client.renderer.RenderType;
|
|
||||||
import net.minecraft.client.renderer.WorldRenderer;
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.nbt.NBTUtil;
|
import net.minecraft.nbt.NBTUtil;
|
||||||
|
@ -19,14 +20,27 @@ import net.minecraft.util.math.RayTraceContext.BlockMode;
|
||||||
import net.minecraft.util.math.RayTraceContext.FluidMode;
|
import net.minecraft.util.math.RayTraceContext.FluidMode;
|
||||||
import net.minecraft.util.math.RayTraceResult.Type;
|
import net.minecraft.util.math.RayTraceResult.Type;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.util.math.shapes.VoxelShape;
|
|
||||||
|
|
||||||
public class TerrainZapperRenderHandler {
|
public class TerrainZapperRenderHandler {
|
||||||
|
|
||||||
private static VoxelShape renderedShape;
|
private static Iterable<BlockPos> renderedShape;
|
||||||
private static BlockPos renderedPosition;
|
private static BlockPos renderedPosition;
|
||||||
|
|
||||||
public static void tick() {
|
public static void tick() {
|
||||||
|
gatherSelectedBlocks();
|
||||||
|
if (renderedPosition == null)
|
||||||
|
return;
|
||||||
|
List<BlockPos> shape = (List<BlockPos>) renderedShape;
|
||||||
|
|
||||||
|
CreateClient.outliner.showCluster("terrainZapper", shape.stream()
|
||||||
|
.map(pos -> pos.add(renderedPosition))
|
||||||
|
.collect(Collectors.toList()))
|
||||||
|
.disableNormals()
|
||||||
|
.lineWidth(1 / 32f)
|
||||||
|
.withFaceTexture(AllSpecialTextures.CHECKERED);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static void gatherSelectedBlocks() {
|
||||||
ClientPlayerEntity player = Minecraft.getInstance().player;
|
ClientPlayerEntity player = Minecraft.getInstance().player;
|
||||||
ItemStack heldMain = player.getHeldItemMainhand();
|
ItemStack heldMain = player.getHeldItemMainhand();
|
||||||
ItemStack heldOff = player.getHeldItemOffhand();
|
ItemStack heldOff = player.getHeldItemOffhand();
|
||||||
|
@ -56,16 +70,19 @@ public class TerrainZapperRenderHandler {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Brush brush = NBTHelper.readEnum(tag.getString("Brush"), TerrainBrushes.class).get();
|
Brush brush = NBTHelper.readEnum(tag.getString("Brush"), TerrainBrushes.class)
|
||||||
|
.get();
|
||||||
PlacementOptions placement = NBTHelper.readEnum(tag.getString("Placement"), PlacementOptions.class);
|
PlacementOptions placement = NBTHelper.readEnum(tag.getString("Placement"), PlacementOptions.class);
|
||||||
BlockPos params = NBTUtil.readBlockPos(tag.getCompound("BrushParams"));
|
BlockPos params = NBTUtil.readBlockPos(tag.getCompound("BrushParams"));
|
||||||
brush.set(params.getX(), params.getY(), params.getZ());
|
brush.set(params.getX(), params.getY(), params.getZ());
|
||||||
renderedShape = brush.getSelectionBox();
|
renderedShape = brush.getIncludedPositions();
|
||||||
|
|
||||||
Vec3d start = player.getPositionVec().add(0, player.getEyeHeight(), 0);
|
Vec3d start = player.getPositionVec()
|
||||||
Vec3d range = player.getLookVec().scale(128);
|
.add(0, player.getEyeHeight(), 0);
|
||||||
BlockRayTraceResult raytrace = player.world.rayTraceBlocks(
|
Vec3d range = player.getLookVec()
|
||||||
new RayTraceContext(start, start.add(range), BlockMode.OUTLINE, FluidMode.NONE, player));
|
.scale(128);
|
||||||
|
BlockRayTraceResult raytrace = player.world
|
||||||
|
.rayTraceBlocks(new RayTraceContext(start, start.add(range), BlockMode.OUTLINE, FluidMode.NONE, player));
|
||||||
if (raytrace == null || raytrace.getType() == Type.MISS) {
|
if (raytrace == null || raytrace.getType() == Type.MISS) {
|
||||||
renderedPosition = null;
|
renderedPosition = null;
|
||||||
return;
|
return;
|
||||||
|
@ -75,24 +92,4 @@ public class TerrainZapperRenderHandler {
|
||||||
renderedPosition = pos.add(brush.getOffset(player.getLookVec(), raytrace.getFace(), placement));
|
renderedPosition = pos.add(brush.getOffset(player.getLookVec(), raytrace.getFace(), placement));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void render(MatrixStack ms, IRenderTypeBuffer buffer) {
|
|
||||||
if (renderedPosition == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// TODO 1.15 buffered render
|
|
||||||
// RenderSystem.lineWidth(2);
|
|
||||||
// TessellatorHelper.prepareForDrawing();
|
|
||||||
// RenderSystem.disableTexture();
|
|
||||||
|
|
||||||
ms.push();
|
|
||||||
ms.translate(renderedPosition.getX(), renderedPosition.getY(), renderedPosition.getZ());
|
|
||||||
WorldRenderer.func_228431_a_(ms, buffer.getBuffer(RenderType.getLines()), renderedShape, 0, 0, 0, 0f, 0f, 0f, 0.5f);
|
|
||||||
|
|
||||||
// RenderSystem.enableTexture();
|
|
||||||
// TessellatorHelper.cleanUpAfterDrawing();
|
|
||||||
// RenderSystem.lineWidth(1);
|
|
||||||
|
|
||||||
ms.pop();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,11 +17,6 @@ public class MoveTool extends PlacementToolBase {
|
||||||
@Override
|
@Override
|
||||||
public void updateSelection() {
|
public void updateSelection() {
|
||||||
super.updateSelection();
|
super.updateSelection();
|
||||||
|
|
||||||
if (!schematicSelected)
|
|
||||||
return;
|
|
||||||
|
|
||||||
renderSelectedFace = selectedFace.getAxis().isHorizontal();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -15,6 +15,7 @@ import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
|
import net.minecraft.util.math.Vec3d;
|
||||||
|
|
||||||
public class Outliner {
|
public class Outliner {
|
||||||
|
|
||||||
|
@ -27,6 +28,17 @@ public class Outliner {
|
||||||
return box.getParams();
|
return box.getParams();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public OutlineParams showLine(Object slot, Vec3d start, Vec3d end) {
|
||||||
|
if (!outlines.containsKey(slot)) {
|
||||||
|
LineOutline outline = new LineOutline();
|
||||||
|
outlines.put(slot, new OutlineEntry(outline));
|
||||||
|
}
|
||||||
|
OutlineEntry entry = outlines.get(slot);
|
||||||
|
entry.ticksTillRemoval = 1;
|
||||||
|
((LineOutline) entry.outline).set(start, end);
|
||||||
|
return entry.outline.getParams();
|
||||||
|
}
|
||||||
|
|
||||||
public OutlineParams showAABB(Object slot, AxisAlignedBB bb) {
|
public OutlineParams showAABB(Object slot, AxisAlignedBB bb) {
|
||||||
createAABBOutlineIfMissing(slot, bb);
|
createAABBOutlineIfMissing(slot, bb);
|
||||||
ChasingAABBOutline outline = getAndRefreshAABB(slot);
|
ChasingAABBOutline outline = getAndRefreshAABB(slot);
|
||||||
|
|
Loading…
Reference in a new issue