mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2024-12-04 23:40:00 +00:00
Add back custom block highlights
Also bump Forge version to enable this
This commit is contained in:
parent
f3a330e330
commit
05eada427b
@ -3,5 +3,5 @@ mod_version=1.86.2
|
||||
|
||||
# Minecraft properties (update mods.toml when changing)
|
||||
mc_version=1.15.2
|
||||
forge_version=31.0.1
|
||||
forge_version=31.0.13
|
||||
mappings_version=20200124-1.15.1
|
||||
|
@ -41,10 +41,9 @@ public final class ComputerCraftProxyClient
|
||||
RenderTypeLookup.setRenderLayer( ComputerCraft.Blocks.turtleNormal, RenderType.translucent() );
|
||||
RenderTypeLookup.setRenderLayer( ComputerCraft.Blocks.turtleAdvanced, RenderType.translucent() );
|
||||
|
||||
// Monitors' textures have _entirely_ transparent sections which, while not translucent, requires being rendered
|
||||
// as transparent.
|
||||
RenderTypeLookup.setRenderLayer( ComputerCraft.Blocks.monitorNormal, RenderType.translucent() );
|
||||
RenderTypeLookup.setRenderLayer( ComputerCraft.Blocks.monitorAdvanced, RenderType.translucent() );
|
||||
// Monitors' textures have transparent fronts and so count as cutouts.
|
||||
RenderTypeLookup.setRenderLayer( ComputerCraft.Blocks.monitorNormal, RenderType.cutout() );
|
||||
RenderTypeLookup.setRenderLayer( ComputerCraft.Blocks.monitorAdvanced, RenderType.cutout() );
|
||||
|
||||
// Setup TESRs
|
||||
ClientRegistry.bindTileEntityRenderer( TileMonitor.FACTORY_NORMAL, TileEntityMonitorRenderer::new );
|
||||
|
@ -5,19 +5,20 @@
|
||||
*/
|
||||
package dan200.computercraft.client.render;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.shared.peripheral.modem.wired.BlockCable;
|
||||
import dan200.computercraft.shared.peripheral.modem.wired.CableShapes;
|
||||
import dan200.computercraft.shared.util.WorldUtil;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.ActiveRenderInfo;
|
||||
import net.minecraft.client.renderer.Matrix4f;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.WorldRenderer;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.world.World;
|
||||
@ -25,7 +26,6 @@ import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.DrawHighlightEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
@Mod.EventBusSubscriber( modid = ComputerCraft.MOD_ID, value = Dist.CLIENT )
|
||||
public final class CableHighlightRenderer
|
||||
@ -38,7 +38,7 @@ public final class CableHighlightRenderer
|
||||
* Draw an outline for a specific part of a cable "Multipart".
|
||||
*
|
||||
* @param event The event to observe
|
||||
* @see WorldRenderer#drawSelectionBox(ActiveRenderInfo, RayTraceResult, int)
|
||||
* @see WorldRenderer#drawSelectionBox(MatrixStack, IVertexBuilder, Entity, double, double, double, BlockPos, BlockState)
|
||||
*/
|
||||
@SubscribeEvent
|
||||
public static void drawHighlight( DrawHighlightEvent.HighlightBlock event )
|
||||
@ -58,31 +58,22 @@ public final class CableHighlightRenderer
|
||||
|
||||
event.setCanceled( true );
|
||||
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.blendFuncSeparate( GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO );
|
||||
RenderSystem.lineWidth( Math.max( 2.5F, mc.getMainWindow().getFramebufferWidth() / 1920.0F * 2.5F ) );
|
||||
RenderSystem.disableTexture();
|
||||
RenderSystem.depthMask( false );
|
||||
RenderSystem.matrixMode( GL11.GL_PROJECTION );
|
||||
RenderSystem.pushMatrix();
|
||||
RenderSystem.scalef( 1.0F, 1.0F, 0.999F );
|
||||
|
||||
VoxelShape shape = WorldUtil.isVecInside( CableShapes.getModemShape( state ), hit.getHitVec().subtract( pos.getX(), pos.getY(), pos.getZ() ) )
|
||||
? CableShapes.getModemShape( state )
|
||||
: CableShapes.getCableShape( state );
|
||||
|
||||
Vec3d cameraPos = info.getProjectedView();
|
||||
WorldRenderer.drawShape(
|
||||
shape, pos.getX() - cameraPos.getX(), pos.getY() - cameraPos.getY(), pos.getZ() - cameraPos.getZ(),
|
||||
0.0F, 0.0F, 0.0F, 0.4F
|
||||
);
|
||||
double xOffset = pos.getX() - cameraPos.getX();
|
||||
double yOffset = pos.getY() - cameraPos.getY();
|
||||
double zOffset = pos.getZ() - cameraPos.getZ();
|
||||
|
||||
RenderSystem.popMatrix();
|
||||
RenderSystem.matrixMode( GL11.GL_MODELVIEW );
|
||||
RenderSystem.depthMask( true );
|
||||
RenderSystem.enableTexture();
|
||||
RenderSystem.disableBlend();
|
||||
IVertexBuilder buffer = event.getBuffers().getBuffer( RenderType.lines() );
|
||||
Matrix4f matrix4f = event.getMatrix().getLast().getPositionMatrix();
|
||||
shape.forEachEdge( ( x1, y1, z1, x2, y2, z2 ) -> {
|
||||
buffer.pos( matrix4f, (float) (x1 + xOffset), (float) (y1 + yOffset), (float) (z1 + zOffset) )
|
||||
.color( 0, 0, 0, 0.4f ).endVertex();
|
||||
buffer.pos( matrix4f, (float) (x2 + xOffset), (float) (y2 + yOffset), (float) (z2 + zOffset) )
|
||||
.color( 0, 0, 0, 0.4f ).endVertex();
|
||||
} );
|
||||
}
|
||||
}
|
@ -9,7 +9,6 @@ import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.shared.peripheral.monitor.TileMonitor;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.Matrix4f;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
@ -26,11 +25,13 @@ import java.util.EnumSet;
|
||||
|
||||
import static net.minecraft.util.Direction.*;
|
||||
|
||||
/**
|
||||
* Overrides monitor highlighting to only render the outline of the <em>whole</em> monitor, rather than the current
|
||||
* block. This means you do not get an intrusive outline on top of the screen.
|
||||
*/
|
||||
@Mod.EventBusSubscriber( modid = ComputerCraft.MOD_ID, value = Dist.CLIENT )
|
||||
public final class MonitorHighlightRenderer
|
||||
{
|
||||
private static final float EXPAND = 0.002f;
|
||||
|
||||
private MonitorHighlightRenderer()
|
||||
{
|
||||
}
|
||||
@ -38,6 +39,7 @@ public final class MonitorHighlightRenderer
|
||||
@SubscribeEvent
|
||||
public static void drawHighlight( DrawHighlightEvent.HighlightBlock event )
|
||||
{
|
||||
// Preserve normal behaviour when crouching.
|
||||
if( event.getInfo().getRenderViewEntity().isCrouching() ) return;
|
||||
|
||||
World world = event.getInfo().getRenderViewEntity().getEntityWorld();
|
||||
@ -58,12 +60,13 @@ public final class MonitorHighlightRenderer
|
||||
if( monitor.getYIndex() != 0 ) faces.remove( monitor.getDown().getOpposite() );
|
||||
if( monitor.getYIndex() != monitor.getHeight() - 1 ) faces.remove( monitor.getDown() );
|
||||
|
||||
IVertexBuilder buffer = Minecraft.getInstance().func_228019_au_().func_228487_b_().getBuffer( RenderType.lines() );
|
||||
|
||||
MatrixStack transformStack = event.getMatrix();
|
||||
Vec3d cameraPos = event.getInfo().getProjectedView();
|
||||
transformStack.push();
|
||||
transformStack.translate( pos.getX() - cameraPos.getX(), pos.getY() - cameraPos.getY(), pos.getZ() - cameraPos.getZ() );
|
||||
|
||||
// I wish I could think of a better way to do this
|
||||
IVertexBuilder buffer = event.getBuffers().getBuffer( RenderType.lines() );
|
||||
Matrix4f transform = transformStack.getLast().getPositionMatrix();
|
||||
if( faces.contains( NORTH ) || faces.contains( WEST ) ) line( buffer, transform, 0, 0, 0, UP );
|
||||
if( faces.contains( SOUTH ) || faces.contains( WEST ) ) line( buffer, transform, 0, 0, 1, UP );
|
||||
@ -83,15 +86,11 @@ public final class MonitorHighlightRenderer
|
||||
|
||||
private static void line( IVertexBuilder buffer, Matrix4f transform, float x, float y, float z, Direction direction )
|
||||
{
|
||||
float minX = x == 0 ? -EXPAND : 1 + EXPAND;
|
||||
float minY = y == 0 ? -EXPAND : 1 + EXPAND;
|
||||
float minZ = z == 0 ? -EXPAND : 1 + EXPAND;
|
||||
|
||||
buffer.pos( transform, minX, minY, minZ ).color( 0, 0, 0, 0.4f ).endVertex();
|
||||
buffer.pos( transform, x, y, z ).color( 0, 0, 0, 0.4f ).endVertex();
|
||||
buffer.pos( transform,
|
||||
minX + direction.getXOffset() * (1 + EXPAND * 2),
|
||||
minY + direction.getYOffset() * (1 + EXPAND * 2),
|
||||
minZ + direction.getZOffset() * (1 + EXPAND * 2)
|
||||
x + direction.getXOffset(),
|
||||
y + direction.getYOffset(),
|
||||
z + direction.getZOffset()
|
||||
).color( 0, 0, 0, 0.4f ).endVertex();
|
||||
}
|
||||
}
|
@ -22,6 +22,7 @@ import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.world.World;
|
||||
@ -653,13 +654,12 @@ public class TileMonitor extends TileGeneric implements IPeripheralTile
|
||||
m_computers.remove( computer );
|
||||
}
|
||||
|
||||
/*
|
||||
@Nonnull
|
||||
@Override
|
||||
public AxisAlignedBB getRenderBoundingBox()
|
||||
{
|
||||
TileMonitor start = getNeighbour( 0, 0 );
|
||||
TileMonitor end = getNeighbour( width - 1, height - 1 );
|
||||
TileMonitor end = getNeighbour( m_width - 1, m_height - 1 );
|
||||
if( start != null && end != null )
|
||||
{
|
||||
BlockPos startPos = start.getPos();
|
||||
@ -678,5 +678,4 @@ public class TileMonitor extends TileGeneric implements IPeripheralTile
|
||||
return new AxisAlignedBB( pos.getX(), pos.getY(), pos.getZ(), pos.getX() + 1, pos.getY() + 1, pos.getZ() + 1 );
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
@ -19,6 +19,6 @@ CC: Tweaked is a fork of ComputerCraft, adding programmable computers, turtles a
|
||||
[[dependencies.computercraft]]
|
||||
modId="forge"
|
||||
mandatory=true
|
||||
versionRange="[31.0.1,32)"
|
||||
versionRange="[31.0.13,32)"
|
||||
ordering="NONE"
|
||||
side="BOTH"
|
||||
|
Loading…
Reference in New Issue
Block a user