1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-08-29 00:32:18 +00:00

style: some spaces and imports

This commit is contained in:
Nikita Savyolov 2021-10-07 00:25:18 +03:00
parent 1c254e3bb0
commit 11272b8d00
No known key found for this signature in database
GPG Key ID: 32C1EF023AFC184B
85 changed files with 303 additions and 354 deletions

View File

@ -2,7 +2,7 @@ plugins {
id 'fabric-loom' version '0.9-SNAPSHOT' id 'fabric-loom' version '0.9-SNAPSHOT'
id 'maven-publish' id 'maven-publish'
id "checkstyle" id "checkstyle"
id "com.github.hierynomus.license" version "0.15.0" id "com.github.hierynomus.license" version "0.16.1"
} }
java { java {
@ -37,7 +37,7 @@ configurations {
} }
dependencies { dependencies {
checkstyle "com.puppycrawl.tools:checkstyle:8.25" checkstyle 'com.puppycrawl.tools:checkstyle:8.45.1'
minecraft "com.mojang:minecraft:${mc_version}" minecraft "com.mojang:minecraft:${mc_version}"
mappings "net.fabricmc:yarn:${mc_version}+build.${mappings_version}:v2" mappings "net.fabricmc:yarn:${mc_version}+build.${mappings_version}:v2"

View File

@ -58,13 +58,13 @@
<module name="SimplifyBooleanExpression" /> <module name="SimplifyBooleanExpression" />
<module name="SimplifyBooleanReturn" /> <module name="SimplifyBooleanReturn" />
<module name="StringLiteralEquality" /> <module name="StringLiteralEquality" />
<module name="UnnecessaryParentheses" /> <!-- <module name="UnnecessaryParentheses" /> -->
<module name="UnnecessarySemicolonAfterTypeMemberDeclaration" /> <module name="UnnecessarySemicolonAfterTypeMemberDeclaration" />
<module name="UnnecessarySemicolonInTryWithResources" /> <module name="UnnecessarySemicolonInTryWithResources" />
<module name="UnnecessarySemicolonInEnumeration" /> <module name="UnnecessarySemicolonInEnumeration" />
<!-- Imports --> <!-- Imports -->
<module name="CustomImportOrder" /> <!--<module name="CustomImportOrder" />-->
<module name="IllegalImport" /> <module name="IllegalImport" />
<module name="RedundantImport" /> <module name="RedundantImport" />
<module name="UnusedImports" /> <module name="UnusedImports" />

View File

@ -133,30 +133,30 @@ public class FakePlayer extends ServerPlayerEntity
{ {
} }
// @Override // @Override
// public void onSlotUpdate( ScreenHandler container, int slot, ItemStack stack ) // public void onSlotUpdate( ScreenHandler container, int slot, ItemStack stack )
// { // {
// } // }
// //
// @Override // @Override
// public void onHandlerRegistered( ScreenHandler container, DefaultedList<ItemStack> defaultedList ) // public void onHandlerRegistered( ScreenHandler container, DefaultedList<ItemStack> defaultedList )
// { // {
// } // }
// //
// @Override // @Override
// public void onPropertyUpdate( ScreenHandler container, int key, int value ) // public void onPropertyUpdate( ScreenHandler container, int key, int value )
// { // {
// } // }
@Override @Override
public void closeHandledScreen() public void closeHandledScreen()
{ {
} }
// @Override // @Override
// public void updateCursorStack() // public void updateCursorStack()
// { // {
// } // }
@Override @Override
public int unlockRecipes( Collection<Recipe<?>> recipes ) public int unlockRecipes( Collection<Recipe<?>> recipes )
@ -211,10 +211,10 @@ public class FakePlayer extends ServerPlayerEntity
{ {
} }
// @Override // @Override
// public void setGameMode( GameMode gameMode ) // public void setGameMode( GameMode gameMode )
// { // {
// } // }
@Override @Override
public void sendMessage( Text message, MessageType type, UUID senderUuid ) public void sendMessage( Text message, MessageType type, UUID senderUuid )
@ -228,15 +228,15 @@ public class FakePlayer extends ServerPlayerEntity
return "[Fake Player]"; return "[Fake Player]";
} }
// @Override // @Override
// public void sendResourcePackUrl( String url, String hash ) // public void sendResourcePackUrl( String url, String hash )
// { // {
// } // }
// @Override // @Override
// public void onStoppedTracking( Entity entity ) // public void onStoppedTracking( Entity entity )
// { // {
// } // }
@Override @Override
public void setCameraEntity( Entity entity ) public void setCameraEntity( Entity entity )

View File

@ -21,10 +21,6 @@ import org.apache.commons.lang3.StringUtils;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@SuppressWarnings( {
"MethodCallSideOnly",
"LocalVariableDeclarationSideOnly"
} )
public class ClientTableFormatter implements TableFormatter public class ClientTableFormatter implements TableFormatter
{ {
public static final ClientTableFormatter INSTANCE = new ClientTableFormatter(); public static final ClientTableFormatter INSTANCE = new ClientTableFormatter();

View File

@ -1,3 +1,8 @@
/*
* This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2021. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com
*/
package dan200.computercraft.client.gui; package dan200.computercraft.client.gui;
import dan200.computercraft.ComputerCraft; import dan200.computercraft.ComputerCraft;
@ -100,8 +105,7 @@ public abstract class ComputerScreenBase<T extends ContainerComputerBase> extend
@Override @Override
public final boolean mouseDragged( double x, double y, int button, double deltaX, double deltaY ) public final boolean mouseDragged( double x, double y, int button, double deltaX, double deltaY )
{ {
return (getFocused() != null && getFocused().mouseDragged( x, y, button, deltaX, deltaY )) return getFocused() != null && getFocused().mouseDragged( x, y, button, deltaX, deltaY ) || super.mouseDragged( x, y, button, deltaX, deltaY );
|| super.mouseDragged( x, y, button, deltaX, deltaY );
} }
@Override @Override

View File

@ -5,13 +5,14 @@
*/ */
package dan200.computercraft.client.render; package dan200.computercraft.client.render;
import com.mojang.blaze3d.systems.RenderSystem;
import dan200.computercraft.ComputerCraft; import dan200.computercraft.ComputerCraft;
import dan200.computercraft.shared.computer.core.ComputerFamily; import dan200.computercraft.shared.computer.core.ComputerFamily;
import net.minecraft.client.render.*; import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.Tessellator;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.math.Matrix4f; import net.minecraft.util.math.Matrix4f;
import org.lwjgl.opengl.GL11;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
@ -81,10 +82,10 @@ public class ComputerBorderRenderer
} }
} }
public static void render(Identifier location, int x, int y, int z, int light, int width, int height ) public static void render( Identifier location, int x, int y, int z, int light, int width, int height )
{ {
VertexConsumerProvider.Immediate source = VertexConsumerProvider.immediate(Tessellator.getInstance().getBuffer()); VertexConsumerProvider.Immediate source = VertexConsumerProvider.immediate( Tessellator.getInstance().getBuffer() );
render( IDENTITY, source.getBuffer(RenderLayer.getText(location)), x, y, z, light, width, height, false, 1, 1, 1 ); render( IDENTITY, source.getBuffer( RenderLayer.getText( location ) ), x, y, z, light, width, height, false, 1, 1, 1 );
source.draw(); source.draw();
} }
@ -144,22 +145,22 @@ public class ComputerBorderRenderer
builder.vertex( transform, x, y + height, z ) builder.vertex( transform, x, y + height, z )
.color( r, g, b, 1.0f ) .color( r, g, b, 1.0f )
.texture( u * TEX_SCALE, (v + textureHeight) * TEX_SCALE ) .texture( u * TEX_SCALE, (v + textureHeight) * TEX_SCALE )
.light(light) .light( light )
.next(); .next();
builder.vertex( transform, x + width, y + height, z ) builder.vertex( transform, x + width, y + height, z )
.color( r, g, b, 1.0f ) .color( r, g, b, 1.0f )
.texture( (u + textureWidth) * TEX_SCALE, (v + textureHeight) * TEX_SCALE ) .texture( (u + textureWidth) * TEX_SCALE, (v + textureHeight) * TEX_SCALE )
.light(light) .light( light )
.next(); .next();
builder.vertex( transform, x + width, y, z ) builder.vertex( transform, x + width, y, z )
.color( r, g, b, 1.0f ) .color( r, g, b, 1.0f )
.texture( (u + textureWidth) * TEX_SCALE, v * TEX_SCALE ) .texture( (u + textureWidth) * TEX_SCALE, v * TEX_SCALE )
.light(light) .light( light )
.next(); .next();
builder.vertex( transform, x, y, z ) builder.vertex( transform, x, y, z )
.color( r, g, b, 1.0f ) .color( r, g, b, 1.0f )
.texture( u * TEX_SCALE, v * TEX_SCALE ) .texture( u * TEX_SCALE, v * TEX_SCALE )
.light(light) .light( light )
.next(); .next();
} }
} }

View File

@ -144,6 +144,7 @@ public abstract class ItemMapLikeRenderer
* @param transform The matrix transformation stack * @param transform The matrix transformation stack
* @param render The buffer to render to * @param render The buffer to render to
* @param stack The stack to render * @param stack The stack to render
* @param light TODO rebase
*/ */
protected abstract void renderItem( MatrixStack transform, VertexConsumerProvider render, ItemStack stack, int light ); protected abstract void renderItem( MatrixStack transform, VertexConsumerProvider render, ItemStack stack, int light );
} }

View File

@ -19,9 +19,8 @@ import net.minecraft.client.render.*;
import net.minecraft.client.util.math.MatrixStack; import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.math.Vec3f;
import net.minecraft.util.math.Matrix4f; import net.minecraft.util.math.Matrix4f;
import org.lwjgl.opengl.GL11; import net.minecraft.util.math.Vec3f;
import static dan200.computercraft.client.gui.FixedWidthFontRenderer.FONT_HEIGHT; import static dan200.computercraft.client.gui.FixedWidthFontRenderer.FONT_HEIGHT;
import static dan200.computercraft.client.gui.FixedWidthFontRenderer.FONT_WIDTH; import static dan200.computercraft.client.gui.FixedWidthFontRenderer.FONT_WIDTH;
@ -104,7 +103,7 @@ public final class ItemPocketRenderer extends ItemMapLikeRenderer
transform.pop(); transform.pop();
} }
private static void renderFrame( Matrix4f transform, VertexConsumerProvider render, ComputerFamily family, int colour, int light, int width, int height ) private static void renderFrame( Matrix4f transform, VertexConsumerProvider render, ComputerFamily family, int colour, int light, int width, int height )
{ {
RenderSystem.enableBlend(); RenderSystem.enableBlend();
MinecraftClient.getInstance() MinecraftClient.getInstance()

View File

@ -12,7 +12,6 @@ import net.fabricmc.api.Environment;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.BlockEntity;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.VertexConsumer; import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.util.math.MatrixStack; import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
@ -20,7 +19,6 @@ import net.minecraft.util.math.*;
import net.minecraft.world.World; import net.minecraft.world.World;
import java.util.EnumSet; import java.util.EnumSet;
import static net.minecraft.util.math.Direction.*; import static net.minecraft.util.math.Direction.*;
/** /**
@ -34,9 +32,7 @@ public final class MonitorHighlightRenderer
{ {
} }
public static boolean drawHighlight( public static boolean drawHighlight( MatrixStack matrixStack, VertexConsumer vertexConsumer, Entity entity, double d, double e, double f, BlockPos pos, BlockState blockState )
MatrixStack matrixStack, VertexConsumer vertexConsumer, Entity entity, double d, double e, double f, BlockPos pos, BlockState blockState
)
{ {
// Preserve normal behaviour when crouching. // Preserve normal behaviour when crouching.
if( entity.isInSneakingPose() ) if( entity.isInSneakingPose() )
@ -142,11 +138,11 @@ public final class MonitorHighlightRenderer
{ {
buffer.vertex( transform, x, y, z ) buffer.vertex( transform, x, y, z )
.color( 0, 0, 0, 0.4f ) .color( 0, 0, 0, 0.4f )
.normal(normal, direction.getOffsetX(), direction.getOffsetY(), direction.getOffsetZ()) .normal( normal, direction.getOffsetX(), direction.getOffsetY(), direction.getOffsetZ() )
.next(); .next();
buffer.vertex( transform, x + direction.getOffsetX(), y + direction.getOffsetY(), z + direction.getOffsetZ() ) buffer.vertex( transform, x + direction.getOffsetX(), y + direction.getOffsetY(), z + direction.getOffsetZ() )
.color( 0, 0, 0, 0.4f ) .color( 0, 0, 0, 0.4f )
.normal(normal, direction.getOffsetX(), direction.getOffsetY(), direction.getOffsetZ()) .normal( normal, direction.getOffsetX(), direction.getOffsetY(), direction.getOffsetZ() )
.next(); .next();
} }
} }

View File

@ -1,3 +1,8 @@
/*
* This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2021. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com
*/
package dan200.computercraft.client.render; package dan200.computercraft.client.render;
import dan200.computercraft.client.gui.FixedWidthFontRenderer; import dan200.computercraft.client.gui.FixedWidthFontRenderer;
@ -24,8 +29,9 @@ public class MonitorTextureBufferShader extends Shader
private final GlUniform width; private final GlUniform width;
private final GlUniform height; private final GlUniform height;
public MonitorTextureBufferShader(ResourceFactory factory, String name, VertexFormat format) throws IOException { public MonitorTextureBufferShader( ResourceFactory factory, String name, VertexFormat format ) throws IOException
super(factory, name, format); {
super( factory, name, format );
width = getUniformChecked( "Width" ); width = getUniformChecked( "Width" );
height = getUniformChecked( "Height" ); height = getUniformChecked( "Height" );

View File

@ -9,11 +9,9 @@ package dan200.computercraft.client.render;
import dan200.computercraft.client.gui.FixedWidthFontRenderer; import dan200.computercraft.client.gui.FixedWidthFontRenderer;
import dan200.computercraft.core.terminal.TextBuffer; import dan200.computercraft.core.terminal.TextBuffer;
import dan200.computercraft.shared.util.Palette; import dan200.computercraft.shared.util.Palette;
import net.minecraft.client.render.*; import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.VertexFormat.DrawMode; import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.Matrix4f; import net.minecraft.util.math.Matrix4f;
import org.lwjgl.opengl.GL11;
import static dan200.computercraft.client.gui.FixedWidthFontRenderer.FONT_HEIGHT; import static dan200.computercraft.client.gui.FixedWidthFontRenderer.FONT_HEIGHT;
import static dan200.computercraft.shared.media.items.ItemPrintout.LINES_PER_PAGE; import static dan200.computercraft.shared.media.items.ItemPrintout.LINES_PER_PAGE;
@ -95,7 +93,7 @@ public final class PrintoutRenderer
int leftPages = page; int leftPages = page;
int rightPages = pages - page - 1; int rightPages = pages - page - 1;
VertexConsumer buffer = renderer.getBuffer(RenderTypes.PRINTOUT_BACKGROUND); VertexConsumer buffer = renderer.getBuffer( RenderTypes.PRINTOUT_BACKGROUND );
if( isBook ) if( isBook )
{ {

View File

@ -1,3 +1,8 @@
/*
* This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2021. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com
*/
package dan200.computercraft.client.render; package dan200.computercraft.client.render;
import dan200.computercraft.client.gui.FixedWidthFontRenderer; import dan200.computercraft.client.gui.FixedWidthFontRenderer;
@ -7,7 +12,8 @@ import net.minecraft.util.Identifier;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
public class RenderTypes { public class RenderTypes
{
public static final int FULL_BRIGHT_LIGHTMAP = (0xF << 4) | (0xF << 20); public static final int FULL_BRIGHT_LIGHTMAP = (0xF << 4) | (0xF << 20);
@ -23,7 +29,7 @@ public class RenderTypes {
public static final RenderLayer TERMINAL_WITH_DEPTH = Types.TERMINAL_WITH_DEPTH; public static final RenderLayer TERMINAL_WITH_DEPTH = Types.TERMINAL_WITH_DEPTH;
public static final RenderLayer PRINTOUT_TEXT = Types.PRINTOUT_TEXT; public static final RenderLayer PRINTOUT_TEXT = Types.PRINTOUT_TEXT;
public static final RenderLayer PRINTOUT_BACKGROUND = RenderLayer.getText(new Identifier( "computercraft", "textures/gui/printout.png" )); public static final RenderLayer PRINTOUT_BACKGROUND = RenderLayer.getText( new Identifier( "computercraft", "textures/gui/printout.png" ) );
public static final RenderLayer POSITION_COLOR = Types.POSITION_COLOR; public static final RenderLayer POSITION_COLOR = Types.POSITION_COLOR;
@ -54,8 +60,8 @@ public class RenderTypes {
public static final RenderLayer MONITOR_TBO = RenderLayer.of( "monitor_tbo", VertexFormats.POSITION_TEXTURE, VertexFormat.DrawMode.TRIANGLE_STRIP, 128, false, false, // useDelegate, needsSorting public static final RenderLayer MONITOR_TBO = RenderLayer.of( "monitor_tbo", VertexFormats.POSITION_TEXTURE, VertexFormat.DrawMode.TRIANGLE_STRIP, 128, false, false, // useDelegate, needsSorting
RenderLayer.MultiPhaseParameters.builder() RenderLayer.MultiPhaseParameters.builder()
.texture(TERM_FONT_TEXTURE ) // blur, minimap .texture( TERM_FONT_TEXTURE ) // blur, minimap
.shader(new RenderPhase.Shader(RenderTypes::getMonitorTextureBufferShader)) .shader( new RenderPhase.Shader( RenderTypes::getMonitorTextureBufferShader ) )
.writeMaskState( RenderLayer.ALL_MASK ) .writeMaskState( RenderLayer.ALL_MASK )
.build( false ) ); .build( false ) );
@ -72,7 +78,7 @@ public class RenderTypes {
static final RenderLayer BLOCKER = RenderLayer.of( "terminal_blocker", FORMAT, GL_MODE, 256, false, false, // useDelegate, needsSorting static final RenderLayer BLOCKER = RenderLayer.of( "terminal_blocker", FORMAT, GL_MODE, 256, false, false, // useDelegate, needsSorting
RenderLayer.MultiPhaseParameters.builder() RenderLayer.MultiPhaseParameters.builder()
.texture( TERM_FONT_TEXTURE ) .texture( TERM_FONT_TEXTURE )
.shader(TERM_SHADER) .shader( TERM_SHADER )
.writeMaskState( DEPTH_MASK ) .writeMaskState( DEPTH_MASK )
.build( false ) ); .build( false ) );
@ -91,7 +97,7 @@ public class RenderTypes {
RenderLayer.MultiPhaseParameters.builder() RenderLayer.MultiPhaseParameters.builder()
.texture( TERM_FONT_TEXTURE ) .texture( TERM_FONT_TEXTURE )
.shader( RenderPhase.TEXT_SHADER ) .shader( RenderPhase.TEXT_SHADER )
.lightmap(RenderPhase.ENABLE_LIGHTMAP) .lightmap( RenderPhase.ENABLE_LIGHTMAP )
.build( false ) .build( false )
); );

View File

@ -20,24 +20,15 @@ import dan200.computercraft.shared.util.Colour;
import dan200.computercraft.shared.util.DirectionUtil; import dan200.computercraft.shared.util.DirectionUtil;
import net.minecraft.client.gl.VertexBuffer; import net.minecraft.client.gl.VertexBuffer;
import net.minecraft.client.render.*; import net.minecraft.client.render.*;
import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher;
import net.minecraft.client.render.block.entity.BlockEntityRenderer; import net.minecraft.client.render.block.entity.BlockEntityRenderer;
import net.minecraft.client.render.block.entity.BlockEntityRendererFactory; import net.minecraft.client.render.block.entity.BlockEntityRendererFactory;
import net.minecraft.client.util.GlAllocationUtils;
import net.minecraft.util.math.AffineTransformation;
import net.minecraft.client.util.math.MatrixStack; import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.math.Vec3f; import net.minecraft.util.math.*;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.Matrix4f;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL13;
import org.lwjgl.opengl.GL20; import org.lwjgl.opengl.GL20;
import org.lwjgl.opengl.GL31; import org.lwjgl.opengl.GL31;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import java.nio.Buffer;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import static dan200.computercraft.client.gui.FixedWidthFontRenderer.*; import static dan200.computercraft.client.gui.FixedWidthFontRenderer.*;
@ -55,7 +46,7 @@ public class TileEntityMonitorRenderer implements BlockEntityRenderer<TileMonito
public TileEntityMonitorRenderer( BlockEntityRendererFactory.Context context ) public TileEntityMonitorRenderer( BlockEntityRendererFactory.Context context )
{ {
// super( context ); // super( context );
} }
@Override @Override
public void render( @Nonnull TileMonitor monitor, float partialTicks, @Nonnull MatrixStack transform, @Nonnull VertexConsumerProvider renderer, public void render( @Nonnull TileMonitor monitor, float partialTicks, @Nonnull MatrixStack transform, @Nonnull VertexConsumerProvider renderer,
@ -120,7 +111,7 @@ public class TileEntityMonitorRenderer implements BlockEntityRenderer<TileMonito
// We don't draw the cursor with the VBO, as it's dynamic and so we'll end up refreshing far more than is // We don't draw the cursor with the VBO, as it's dynamic and so we'll end up refreshing far more than is
// reasonable. // reasonable.
FixedWidthFontRenderer.drawCursor( matrix, renderer.getBuffer(RenderTypes.TERMINAL_WITHOUT_DEPTH), 0, 0, terminal, !originTerminal.isColour() ); FixedWidthFontRenderer.drawCursor( matrix, renderer.getBuffer( RenderTypes.TERMINAL_WITHOUT_DEPTH ), 0, 0, terminal, !originTerminal.isColour() );
transform.pop(); transform.pop();
@ -147,7 +138,7 @@ public class TileEntityMonitorRenderer implements BlockEntityRenderer<TileMonito
transform.pop(); transform.pop();
} }
private static void renderTerminal(VertexConsumerProvider renderer, Matrix4f matrix, ClientMonitor monitor, float xMargin, float yMargin ) private static void renderTerminal( VertexConsumerProvider renderer, Matrix4f matrix, ClientMonitor monitor, float xMargin, float yMargin )
{ {
Terminal terminal = monitor.getTerminal(); Terminal terminal = monitor.getTerminal();
@ -237,7 +228,7 @@ public class TileEntityMonitorRenderer implements BlockEntityRenderer<TileMonito
renderer.getBuffer( RenderTypes.TERMINAL_WITHOUT_DEPTH ); renderer.getBuffer( RenderTypes.TERMINAL_WITHOUT_DEPTH );
RenderTypes.TERMINAL_WITHOUT_DEPTH.startDrawing(); RenderTypes.TERMINAL_WITHOUT_DEPTH.startDrawing();
vbo.setShader(matrix, RenderSystem.getProjectionMatrix(), RenderTypes.getTerminalShader()); vbo.setShader( matrix, RenderSystem.getProjectionMatrix(), RenderTypes.getTerminalShader() );
break; break;
} }
} }
@ -245,7 +236,7 @@ public class TileEntityMonitorRenderer implements BlockEntityRenderer<TileMonito
private static void tboVertex( VertexConsumer builder, Matrix4f matrix, float x, float y ) private static void tboVertex( VertexConsumer builder, Matrix4f matrix, float x, float y )
{ {
// We encode position in the UV, as that's not transformed by the matrix. // We encode position in the UV, as that's not transformed by the matrix.
builder.vertex( matrix, x, y, 0 ).texture(x, y).next(); builder.vertex( matrix, x, y, 0 ).texture( x, y ).next();
} }
@Override @Override

View File

@ -124,13 +124,13 @@ public class TurtleMultiModel implements BakedModel
return baseModel.getParticleSprite(); return baseModel.getParticleSprite();
} }
// @Nonnull // @Nonnull
// @Override // @Override
// @Deprecated // @Deprecated
// public Sprite getSprite() // public Sprite getSprite()
// { // {
// return baseModel.getSprite(); // return baseModel.getSprite();
// } // }
@Nonnull @Nonnull
@Override @Override

View File

@ -6,12 +6,9 @@
package dan200.computercraft.client.render; package dan200.computercraft.client.render;
import dan200.computercraft.shared.turtle.core.TurtlePlayer; import dan200.computercraft.shared.turtle.core.TurtlePlayer;
import net.fabricmc.fabric.api.client.rendereregistry.v1.EntityRendererRegistry;
import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.render.entity.EntityRenderer; import net.minecraft.client.render.entity.EntityRenderer;
import net.minecraft.client.render.entity.EntityRendererFactory; import net.minecraft.client.render.entity.EntityRendererFactory;
import net.minecraft.client.render.entity.EntityRendererFactory.Context;
import net.minecraft.client.util.math.MatrixStack; import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;

View File

@ -70,7 +70,7 @@ public class TurtleSmartItemModel implements BakedModel
{ {
@Nonnull @Nonnull
@Override @Override
public BakedModel apply( BakedModel originalModel, ItemStack stack, @Nullable ClientWorld world, @Nullable LivingEntity entity, int seed) public BakedModel apply( BakedModel originalModel, ItemStack stack, @Nullable ClientWorld world, @Nullable LivingEntity entity, int seed )
{ {
ItemTurtle turtle = (ItemTurtle) stack.getItem(); ItemTurtle turtle = (ItemTurtle) stack.getItem();
int colour = turtle.getColour( stack ); int colour = turtle.getColour( stack );
@ -149,13 +149,13 @@ public class TurtleSmartItemModel implements BakedModel
return familyModel.getParticleSprite(); return familyModel.getParticleSprite();
} }
// @Nonnull // @Nonnull
// @Override // @Override
// @Deprecated // @Deprecated
// public Sprite getSprite() // public Sprite getSprite()
// { // {
// return familyModel.getSprite(); // return familyModel.getSprite();
// } // }
@Nonnull @Nonnull
@Override @Override

View File

@ -201,7 +201,7 @@ public final class NetworkUtils
{ {
return "Timed out"; return "Timed out";
} }
else if( cause instanceof SSLHandshakeException || (cause instanceof DecoderException && cause.getCause() instanceof SSLHandshakeException) ) else if( cause instanceof SSLHandshakeException || cause instanceof DecoderException && cause.getCause() instanceof SSLHandshakeException )
{ {
return "Could not create a secure connection"; return "Could not create a secure connection";
} }

View File

@ -75,7 +75,7 @@ public final class AddressRule
if( this.port != null && this.port != port ) return false; if( this.port != null && this.port != port ) return false;
return predicate.matches( domain ) return predicate.matches( domain )
|| predicate.matches( address ) || predicate.matches( address )
|| (ipv4Address != null && predicate.matches( ipv4Address )); || ipv4Address != null && predicate.matches( ipv4Address );
} }
public static Options apply( Iterable<? extends AddressRule> rules, String domain, InetSocketAddress socketAddress ) public static Options apply( Iterable<? extends AddressRule> rules, String domain, InetSocketAddress socketAddress )

View File

@ -28,7 +28,6 @@ import io.netty.handler.codec.http.HttpObjectAggregator;
import io.netty.handler.codec.http.websocketx.WebSocketClientHandshaker; import io.netty.handler.codec.http.websocketx.WebSocketClientHandshaker;
import io.netty.handler.codec.http.websocketx.WebSocketClientHandshakerFactory; import io.netty.handler.codec.http.websocketx.WebSocketClientHandshakerFactory;
import io.netty.handler.codec.http.websocketx.WebSocketVersion; import io.netty.handler.codec.http.websocketx.WebSocketVersion;
import io.netty.handler.codec.http.websocketx.extensions.compression.WebSocketClientCompressionHandler;
import io.netty.handler.ssl.SslContext; import io.netty.handler.ssl.SslContext;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;

View File

@ -309,9 +309,9 @@ public final class Environment implements IAPIEnvironment
{ {
int index = side.ordinal(); int index = side.ordinal();
IPeripheral existing = peripherals[index]; IPeripheral existing = peripherals[index];
if( (existing == null && peripheral != null) || if( existing == null && peripheral != null ||
(existing != null && peripheral == null) || existing != null && peripheral == null ||
(existing != null && !existing.equals( peripheral )) ) existing != null && !existing.equals( peripheral ) )
{ {
peripherals[index] = peripheral; peripherals[index] = peripheral;
if( peripheralListener != null ) peripheralListener.onPeripheralChanged( side, peripheral ); if( peripheralListener != null ) peripheralListener.onPeripheralChanged( side, peripheral );

View File

@ -13,11 +13,12 @@ import dan200.computercraft.ComputerCraft;
import dan200.computercraft.api.filesystem.IMount; import dan200.computercraft.api.filesystem.IMount;
import dan200.computercraft.core.apis.handles.ArrayByteChannel; import dan200.computercraft.core.apis.handles.ArrayByteChannel;
import dan200.computercraft.shared.util.IoUtil; import dan200.computercraft.shared.util.IoUtil;
import net.minecraft.resource.*; import net.minecraft.resource.ReloadableResourceManager;
import net.minecraft.resource.ResourceReloader.Synchronizer; import net.minecraft.resource.Resource;
import net.minecraft.resource.ResourceManager;
import net.minecraft.resource.SynchronousResourceReloader;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.InvalidIdentifierException; import net.minecraft.util.InvalidIdentifierException;
import net.minecraft.util.profiler.Profiler;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@ -27,8 +28,6 @@ import java.io.InputStream;
import java.nio.channels.Channels; import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel; import java.nio.channels.ReadableByteChannel;
import java.util.*; import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
public final class ResourceMount implements IMount public final class ResourceMount implements IMount

View File

@ -1,17 +1,18 @@
/*
* This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2021. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com
*/
package dan200.computercraft.fabric.mixin; package dan200.computercraft.fabric.mixin;
import com.mojang.datafixers.util.Pair; import com.mojang.datafixers.util.Pair;
import dan200.computercraft.ComputerCraft;
import dan200.computercraft.client.gui.FixedWidthFontRenderer;
import dan200.computercraft.client.render.MonitorTextureBufferShader; import dan200.computercraft.client.render.MonitorTextureBufferShader;
import dan200.computercraft.client.render.RenderTypes; import dan200.computercraft.client.render.RenderTypes;
import net.minecraft.client.gl.Program; import net.minecraft.client.gl.Program;
import net.minecraft.client.render.GameRenderer; import net.minecraft.client.render.GameRenderer;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.Shader; import net.minecraft.client.render.Shader;
import net.minecraft.client.render.VertexFormats;
import net.minecraft.resource.ResourceManager; import net.minecraft.resource.ResourceManager;
import net.minecraft.util.Identifier;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
@ -22,20 +23,22 @@ import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.function.Consumer; import java.util.function.Consumer;
@Mixin(GameRenderer.class) @Mixin( GameRenderer.class )
public class GameRendererMixin { public class GameRendererMixin
@SuppressWarnings("UnresolvedMixinReference") {
@Inject(method = "loadShaders", at = @At(value = "INVOKE_ASSIGN", target = "Ljava/util/List;add(Ljava/lang/Object;)Z", ordinal = 53), locals = LocalCapture.CAPTURE_FAILSOFT) @SuppressWarnings( "UnresolvedMixinReference" )
private void loadShaders(ResourceManager manager, CallbackInfo info, List<Program> list, List<Pair<Shader, Consumer<Shader>>> list2) throws IOException { @Inject( method = "loadShaders", at = @At( value = "INVOKE_ASSIGN", target = "Ljava/util/List;add(Ljava/lang/Object;)Z", ordinal = 53 ), locals = LocalCapture.CAPTURE_FAILSOFT )
list2.add(Pair.of(new Shader( private void loadShaders( ResourceManager manager, CallbackInfo info, List<Program> list, List<Pair<Shader, Consumer<Shader>>> list2 ) throws IOException
{
list2.add( Pair.of( new Shader(
manager, manager,
"terminal", "terminal",
RenderTypes.TERMINAL_WITHOUT_DEPTH.getVertexFormat() RenderTypes.TERMINAL_WITHOUT_DEPTH.getVertexFormat()
), (shader) -> RenderTypes.terminalShader = shader)); ), shader -> RenderTypes.terminalShader = shader ) );
list2.add(Pair.of(new MonitorTextureBufferShader( list2.add( Pair.of( new MonitorTextureBufferShader(
manager, manager,
"monitor_tbo", "monitor_tbo",
RenderTypes.MONITOR_TBO.getVertexFormat() RenderTypes.MONITOR_TBO.getVertexFormat()
), (shader) -> RenderTypes.monitorTboShader = (MonitorTextureBufferShader) shader)); ), shader -> RenderTypes.monitorTboShader = (MonitorTextureBufferShader) shader ) );
} }
} }

View File

@ -1,3 +1,8 @@
/*
* This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2021. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com
*/
package dan200.computercraft.fabric.mixin; package dan200.computercraft.fabric.mixin;
import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Final;

View File

@ -18,7 +18,6 @@ import net.minecraft.item.ItemStack;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Slice;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin( ItemFrameEntityRenderer.class ) @Mixin( ItemFrameEntityRenderer.class )

View File

@ -7,7 +7,6 @@ package dan200.computercraft.fabric.mixin;
import dan200.computercraft.shared.common.TileGeneric; import dan200.computercraft.shared.common.TileGeneric;
import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.BlockEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Shadow;
@ -32,7 +31,7 @@ public class MixinWorld
@Inject( method = "addBlockEntity", at = @At( "HEAD" ) ) @Inject( method = "addBlockEntity", at = @At( "HEAD" ) )
public void addBlockEntity( @Nullable BlockEntity entity, CallbackInfo info ) public void addBlockEntity( @Nullable BlockEntity entity, CallbackInfo info )
{ {
if( entity != null && !entity.isRemoved() && entity.getWorld().isInBuildLimit(entity.getPos()) && iteratingTickingBlockEntities ) if( entity != null && !entity.isRemoved() && entity.getWorld().isInBuildLimit( entity.getPos() ) && iteratingTickingBlockEntities )
{ {
setWorld( entity, this ); setWorld( entity, this );
} }
@ -46,7 +45,7 @@ public class MixinWorld
} }
} }
// @Inject( method = "addBlockEntities", at = @At( "HEAD" ) ) // @Inject( method = "addBlockEntities", at = @At( "HEAD" ) )
public void addBlockEntities( Collection<BlockEntity> entities, CallbackInfo info ) public void addBlockEntities( Collection<BlockEntity> entities, CallbackInfo info )
{ {
if( iteratingTickingBlockEntities ) if( iteratingTickingBlockEntities )

View File

@ -1,18 +0,0 @@
//package dan200.computercraft.fabric.mixin;
//
//import org.spongepowered.asm.mixin.Mixin;
//import org.spongepowered.asm.mixin.gen.Accessor;
//import org.spongepowered.asm.mixin.gen.Invoker;
//
//import net.minecraft.client.render.RenderLayer;
//import net.minecraft.client.render.VertexFormat;
//
//@Mixin(RenderLayer.class)
//public interface RenderLayerAccessor {
//
// @Accessor
// static RenderLayer.MultiPhaseParameters callOf(String name, VertexFormat vertexFormat, VertexFormat.DrawMode drawMode, int expectedBufferSize, boolean hasCrumbling, boolean translucent, RenderLayer.MultiPhaseParameters phases) {
// throw new UnsupportedOperationException();
// }
//
//}

View File

@ -150,46 +150,46 @@ public final class ComputerCraftRegistry
public static final BlockEntityType<TileMonitor> MONITOR_NORMAL = ofBlock( ModBlocks.MONITOR_NORMAL, public static final BlockEntityType<TileMonitor> MONITOR_NORMAL = ofBlock( ModBlocks.MONITOR_NORMAL,
"monitor_normal", "monitor_normal",
(blockPos, blockState) -> new TileMonitor(ModTiles.MONITOR_NORMAL, false, blockPos, blockState) ); ( blockPos, blockState ) -> new TileMonitor( ModTiles.MONITOR_NORMAL, false, blockPos, blockState ) );
public static final BlockEntityType<TileMonitor> MONITOR_ADVANCED = ofBlock( ModBlocks.MONITOR_ADVANCED, public static final BlockEntityType<TileMonitor> MONITOR_ADVANCED = ofBlock( ModBlocks.MONITOR_ADVANCED,
"monitor_advanced", "monitor_advanced",
(blockPos, blockState) -> new TileMonitor(ModTiles.MONITOR_ADVANCED, true, blockPos, blockState) ); ( blockPos, blockState ) -> new TileMonitor( ModTiles.MONITOR_ADVANCED, true, blockPos, blockState ) );
public static final BlockEntityType<TileComputer> COMPUTER_NORMAL = ofBlock( ModBlocks.COMPUTER_NORMAL, public static final BlockEntityType<TileComputer> COMPUTER_NORMAL = ofBlock( ModBlocks.COMPUTER_NORMAL,
"computer_normal", "computer_normal",
(blockPos, blockState) -> new TileComputer(ComputerFamily.NORMAL, ModTiles.COMPUTER_NORMAL, blockPos, blockState) ); ( blockPos, blockState ) -> new TileComputer( ComputerFamily.NORMAL, ModTiles.COMPUTER_NORMAL, blockPos, blockState ) );
public static final BlockEntityType<TileComputer> COMPUTER_ADVANCED = ofBlock( ModBlocks.COMPUTER_ADVANCED, public static final BlockEntityType<TileComputer> COMPUTER_ADVANCED = ofBlock( ModBlocks.COMPUTER_ADVANCED,
"computer_advanced", "computer_advanced",
(blockPos, blockState) -> new TileComputer(ComputerFamily.ADVANCED, ModTiles.COMPUTER_ADVANCED, blockPos, blockState) ); ( blockPos, blockState ) -> new TileComputer( ComputerFamily.ADVANCED, ModTiles.COMPUTER_ADVANCED, blockPos, blockState ) );
public static final BlockEntityType<TileCommandComputer> COMPUTER_COMMAND = ofBlock( ModBlocks.COMPUTER_COMMAND, public static final BlockEntityType<TileCommandComputer> COMPUTER_COMMAND = ofBlock( ModBlocks.COMPUTER_COMMAND,
"computer_command", "computer_command",
(blockPos, blockState) -> new TileCommandComputer(ComputerFamily.COMMAND, ModTiles.COMPUTER_COMMAND, blockPos, blockState) ); ( blockPos, blockState ) -> new TileCommandComputer( ComputerFamily.COMMAND, ModTiles.COMPUTER_COMMAND, blockPos, blockState ) );
public static final BlockEntityType<TileTurtle> TURTLE_NORMAL = ofBlock( ModBlocks.TURTLE_NORMAL, public static final BlockEntityType<TileTurtle> TURTLE_NORMAL = ofBlock( ModBlocks.TURTLE_NORMAL,
"turtle_normal", "turtle_normal",
(blockPos, blockState) -> new TileTurtle(ModTiles.TURTLE_NORMAL, blockPos, blockState, ComputerFamily.NORMAL ) ); ( blockPos, blockState ) -> new TileTurtle( ModTiles.TURTLE_NORMAL, blockPos, blockState, ComputerFamily.NORMAL ) );
public static final BlockEntityType<TileTurtle> TURTLE_ADVANCED = ofBlock( ModBlocks.TURTLE_ADVANCED, public static final BlockEntityType<TileTurtle> TURTLE_ADVANCED = ofBlock( ModBlocks.TURTLE_ADVANCED,
"turtle_advanced", "turtle_advanced",
(blockPos, blockState) -> new TileTurtle(ModTiles.TURTLE_ADVANCED, blockPos, blockState, ComputerFamily.ADVANCED ) ); ( blockPos, blockState ) -> new TileTurtle( ModTiles.TURTLE_ADVANCED, blockPos, blockState, ComputerFamily.ADVANCED ) );
public static final BlockEntityType<TileSpeaker> SPEAKER = ofBlock( ModBlocks.SPEAKER, "speaker", public static final BlockEntityType<TileSpeaker> SPEAKER = ofBlock( ModBlocks.SPEAKER, "speaker",
(blockPos, blockState) -> new TileSpeaker(ModTiles.SPEAKER, blockPos, blockState ) ); ( blockPos, blockState ) -> new TileSpeaker( ModTiles.SPEAKER, blockPos, blockState ) );
public static final BlockEntityType<TileDiskDrive> DISK_DRIVE = ofBlock( ModBlocks.DISK_DRIVE, "disk_drive", public static final BlockEntityType<TileDiskDrive> DISK_DRIVE = ofBlock( ModBlocks.DISK_DRIVE, "disk_drive",
(blockPos, blockState) -> new TileDiskDrive(ModTiles.DISK_DRIVE, blockPos, blockState ) ); ( blockPos, blockState ) -> new TileDiskDrive( ModTiles.DISK_DRIVE, blockPos, blockState ) );
public static final BlockEntityType<TilePrinter> PRINTER = ofBlock( ModBlocks.PRINTER, "printer", public static final BlockEntityType<TilePrinter> PRINTER = ofBlock( ModBlocks.PRINTER, "printer",
(blockPos, blockState) -> new TilePrinter(ModTiles.PRINTER, blockPos, blockState ) ); ( blockPos, blockState ) -> new TilePrinter( ModTiles.PRINTER, blockPos, blockState ) );
public static final BlockEntityType<TileWiredModemFull> WIRED_MODEM_FULL = ofBlock( ModBlocks.WIRED_MODEM_FULL, public static final BlockEntityType<TileWiredModemFull> WIRED_MODEM_FULL = ofBlock( ModBlocks.WIRED_MODEM_FULL,
"wired_modem_full", "wired_modem_full",
(blockPos, blockState) -> new TileWiredModemFull(ModTiles.WIRED_MODEM_FULL, blockPos, blockState ) ); ( blockPos, blockState ) -> new TileWiredModemFull( ModTiles.WIRED_MODEM_FULL, blockPos, blockState ) );
public static final BlockEntityType<TileCable> CABLE = ofBlock( ModBlocks.CABLE, "cable", public static final BlockEntityType<TileCable> CABLE = ofBlock( ModBlocks.CABLE, "cable",
(blockPos, blockState) -> new TileCable(ModTiles.CABLE, blockPos, blockState ) ); ( blockPos, blockState ) -> new TileCable( ModTiles.CABLE, blockPos, blockState ) );
public static final BlockEntityType<TileWirelessModem> WIRELESS_MODEM_NORMAL = ofBlock( ModBlocks.WIRELESS_MODEM_NORMAL, public static final BlockEntityType<TileWirelessModem> WIRELESS_MODEM_NORMAL = ofBlock( ModBlocks.WIRELESS_MODEM_NORMAL,
"wireless_modem_normal", "wireless_modem_normal",
(blockPos, blockState) -> new TileWirelessModem(ModTiles.WIRELESS_MODEM_NORMAL, false, blockPos, blockState) ); ( blockPos, blockState ) -> new TileWirelessModem( ModTiles.WIRELESS_MODEM_NORMAL, false, blockPos, blockState ) );
public static final BlockEntityType<TileWirelessModem> WIRELESS_MODEM_ADVANCED = ofBlock( ModBlocks.WIRELESS_MODEM_ADVANCED, public static final BlockEntityType<TileWirelessModem> WIRELESS_MODEM_ADVANCED = ofBlock( ModBlocks.WIRELESS_MODEM_ADVANCED,
"wireless_modem_advanced", "wireless_modem_advanced",
(blockPos, blockState) -> new TileWirelessModem(ModTiles.WIRELESS_MODEM_ADVANCED, true, blockPos, blockState) ); ( blockPos, blockState ) -> new TileWirelessModem( ModTiles.WIRELESS_MODEM_ADVANCED, true, blockPos, blockState ) );
private static <T extends BlockEntity> BlockEntityType<T> ofBlock( Block block, String id, BiFunction<BlockPos, BlockState, T> factory ) private static <T extends BlockEntity> BlockEntityType<T> ofBlock( Block block, String id, BiFunction<BlockPos, BlockState, T> factory )
{ {
BlockEntityType<T> blockEntityType = FabricBlockEntityTypeBuilder.create(factory::apply, block).build(); BlockEntityType<T> blockEntityType = FabricBlockEntityTypeBuilder.create( factory::apply, block ).build();
return Registry.register( BLOCK_ENTITY_TYPE, return Registry.register( BLOCK_ENTITY_TYPE,
new Identifier( MOD_ID, id ), new Identifier( MOD_ID, id ),
blockEntityType blockEntityType
@ -257,7 +257,7 @@ public final class ComputerCraftRegistry
public static class ModContainers public static class ModContainers
{ {
public static final ScreenHandlerType<ContainerComputerBase> COMPUTER = ContainerData.toType(new Identifier( MOD_ID, "computer" ), ModContainers.COMPUTER, ComputerContainerData::new, ComputerMenuWithoutInventory::new ); public static final ScreenHandlerType<ContainerComputerBase> COMPUTER = ContainerData.toType( new Identifier( MOD_ID, "computer" ), ModContainers.COMPUTER, ComputerContainerData::new, ComputerMenuWithoutInventory::new );
public static final ScreenHandlerType<ContainerComputerBase> POCKET_COMPUTER = ContainerData.toType( new Identifier( MOD_ID, "pocket_computer" ), ModContainers.POCKET_COMPUTER, ComputerContainerData::new, ComputerMenuWithoutInventory::new ); public static final ScreenHandlerType<ContainerComputerBase> POCKET_COMPUTER = ContainerData.toType( new Identifier( MOD_ID, "pocket_computer" ), ModContainers.POCKET_COMPUTER, ComputerContainerData::new, ComputerMenuWithoutInventory::new );
public static final ScreenHandlerType<ContainerComputerBase> POCKET_COMPUTER_NO_TERM = ContainerData.toType( new Identifier( MOD_ID, "pocket_computer_no_term" ), ModContainers.POCKET_COMPUTER_NO_TERM, ComputerContainerData::new, ComputerMenuWithoutInventory::new ); public static final ScreenHandlerType<ContainerComputerBase> POCKET_COMPUTER_NO_TERM = ContainerData.toType( new Identifier( MOD_ID, "pocket_computer_no_term" ), ModContainers.POCKET_COMPUTER_NO_TERM, ComputerContainerData::new, ComputerMenuWithoutInventory::new );
public static final ScreenHandlerType<ContainerTurtle> TURTLE = ContainerData.toType( new Identifier( MOD_ID, "turtle" ), ComputerContainerData::new, ContainerTurtle::new ); public static final ScreenHandlerType<ContainerTurtle> TURTLE = ContainerData.toType( new Identifier( MOD_ID, "turtle" ), ComputerContainerData::new, ContainerTurtle::new );

View File

@ -25,7 +25,7 @@ public final class TurtlePermissions
public static boolean isBlockEnterable( World world, BlockPos pos, PlayerEntity player ) public static boolean isBlockEnterable( World world, BlockPos pos, PlayerEntity player )
{ {
MinecraftServer server = world.getServer(); MinecraftServer server = world.getServer();
return server == null || world.isClient || (world instanceof ServerWorld && !server.isSpawnProtected( (ServerWorld) world, pos, player )); return server == null || world.isClient || world instanceof ServerWorld && !server.isSpawnProtected( (ServerWorld) world, pos, player );
} }
@Subscribe @Subscribe

View File

@ -18,7 +18,6 @@ import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.BlockView;
import net.minecraft.world.World; import net.minecraft.world.World;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
@ -35,7 +34,8 @@ public abstract class BlockGeneric extends BlockWithEntity
this.type = type; this.type = type;
} }
public BlockEntityType<? extends TileGeneric> getType() { public BlockEntityType<? extends TileGeneric> getType()
{
return type; return type;
} }
@ -98,10 +98,11 @@ public abstract class BlockGeneric extends BlockWithEntity
@Nullable @Nullable
@Override @Override
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) public BlockEntity createBlockEntity( BlockPos pos, BlockState state )
{ {
if (this.type != null) { if ( this.type != null )
return type.instantiate(pos, state); {
return type.instantiate( pos, state );
} }
return null; return null;
} }

View File

@ -85,7 +85,7 @@ public class ClientTerminal implements ITerminal
colour = nbt.getBoolean( "colour" ); colour = nbt.getBoolean( "colour" );
if( nbt.contains( "terminal" ) ) if( nbt.contains( "terminal" ) )
{ {
NbtCompound terminal = nbt.getCompound( "terminal" ); NbtCompound terminal = nbt.getCompound( "terminal" );
resizeTerminal( terminal.getInt( "term_width" ), terminal.getInt( "term_height" ) ); resizeTerminal( terminal.getInt( "term_width" ), terminal.getInt( "term_height" ) );
this.terminal.readFromNBT( terminal ); this.terminal.readFromNBT( terminal );
} }

View File

@ -20,7 +20,7 @@ public interface IColouredItem
static int getColourBasic( ItemStack stack ) static int getColourBasic( ItemStack stack )
{ {
NbtCompound tag = stack.getNbt(); NbtCompound tag = stack.getNbt();
return tag != null && tag.contains( NBT_COLOUR ) ? tag.getInt( NBT_COLOUR ) : -1; return tag != null && tag.contains( NBT_COLOUR ) ? tag.getInt( NBT_COLOUR ) : -1;
} }
@ -35,7 +35,7 @@ public interface IColouredItem
{ {
if( colour == -1 ) if( colour == -1 )
{ {
NbtCompound tag = stack.getNbt(); NbtCompound tag = stack.getNbt();
if( tag != null ) if( tag != null )
{ {
tag.remove( NBT_COLOUR ); tag.remove( NBT_COLOUR );

View File

@ -90,7 +90,7 @@ public class ServerTerminal implements ITerminal
nbt.putBoolean( "colour", colour ); nbt.putBoolean( "colour", colour );
if( terminal != null ) if( terminal != null )
{ {
NbtCompound terminal = new NbtCompound(); NbtCompound terminal = new NbtCompound();
terminal.putInt( "term_width", this.terminal.getWidth() ); terminal.putInt( "term_width", this.terminal.getWidth() );
terminal.putInt( "term_height", this.terminal.getHeight() ); terminal.putInt( "term_height", this.terminal.getHeight() );
this.terminal.writeToNBT( terminal ); this.terminal.writeToNBT( terminal );

View File

@ -7,15 +7,12 @@
package dan200.computercraft.shared.computer.blocks; package dan200.computercraft.shared.computer.blocks;
import dan200.computercraft.shared.ComputerCraftRegistry; import dan200.computercraft.shared.ComputerCraftRegistry;
import dan200.computercraft.shared.common.TileGeneric;
import dan200.computercraft.shared.computer.core.ComputerFamily; import dan200.computercraft.shared.computer.core.ComputerFamily;
import dan200.computercraft.shared.computer.core.ComputerRegistry;
import dan200.computercraft.shared.computer.core.ComputerState; import dan200.computercraft.shared.computer.core.ComputerState;
import dan200.computercraft.shared.computer.items.ComputerItemFactory; import dan200.computercraft.shared.computer.items.ComputerItemFactory;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityTicker;
import net.minecraft.block.entity.BlockEntityType; import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.item.ItemPlacementContext; import net.minecraft.item.ItemPlacementContext;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -25,7 +22,6 @@ import net.minecraft.state.property.EnumProperty;
import net.minecraft.state.property.Properties; import net.minecraft.state.property.Properties;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
import net.minecraft.world.World;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@ -64,9 +60,10 @@ public class BlockComputer extends BlockComputerBase<TileComputer>
return tile instanceof TileComputer ? ComputerItemFactory.create( (TileComputer) tile ) : ItemStack.EMPTY; return tile instanceof TileComputer ? ComputerItemFactory.create( (TileComputer) tile ) : ItemStack.EMPTY;
} }
public BlockEntityType<? extends TileComputer> getTypeByFamily(ComputerFamily family) public BlockEntityType<? extends TileComputer> getTypeByFamily( ComputerFamily family )
{ {
return switch (family) { return switch ( family )
{
case COMMAND -> ComputerCraftRegistry.ModTiles.COMPUTER_COMMAND; case COMMAND -> ComputerCraftRegistry.ModTiles.COMPUTER_COMMAND;
case ADVANCED -> ComputerCraftRegistry.ModTiles.COMPUTER_ADVANCED; case ADVANCED -> ComputerCraftRegistry.ModTiles.COMPUTER_ADVANCED;
default -> ComputerCraftRegistry.ModTiles.COMPUTER_NORMAL; default -> ComputerCraftRegistry.ModTiles.COMPUTER_NORMAL;
@ -75,8 +72,8 @@ public class BlockComputer extends BlockComputerBase<TileComputer>
@Nullable @Nullable
@Override @Override
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) public BlockEntity createBlockEntity( BlockPos pos, BlockState state )
{ {
return new TileComputer(getFamily(), getTypeByFamily(getFamily()), pos, state); return new TileComputer( getFamily(), getTypeByFamily( getFamily() ), pos, state );
} }
} }

View File

@ -8,14 +8,11 @@ package dan200.computercraft.shared.computer.blocks;
import dan200.computercraft.ComputerCraft; import dan200.computercraft.ComputerCraft;
import dan200.computercraft.core.computer.ComputerSide; import dan200.computercraft.core.computer.ComputerSide;
import dan200.computercraft.shared.ComputerCraftRegistry;
import dan200.computercraft.shared.common.BlockGeneric; import dan200.computercraft.shared.common.BlockGeneric;
import dan200.computercraft.shared.common.IBundledRedstoneBlock; import dan200.computercraft.shared.common.IBundledRedstoneBlock;
import dan200.computercraft.shared.computer.core.ComputerFamily; import dan200.computercraft.shared.computer.core.ComputerFamily;
import dan200.computercraft.shared.computer.core.ServerComputer; import dan200.computercraft.shared.computer.core.ServerComputer;
import dan200.computercraft.shared.computer.items.IComputerItem; import dan200.computercraft.shared.computer.items.IComputerItem;
import dan200.computercraft.shared.turtle.blocks.BlockTurtle;
import dan200.computercraft.shared.turtle.blocks.TileTurtle;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityTicker; import net.minecraft.block.entity.BlockEntityTicker;
@ -218,9 +215,11 @@ public abstract class BlockComputerBase<T extends TileComputerBase> extends Bloc
@Nullable @Nullable
@Override @Override
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(World world, BlockState state, BlockEntityType<T> type) { public <T extends BlockEntity> BlockEntityTicker<T> getTicker( World world, BlockState state, BlockEntityType<T> type )
return world.isClient ? null : (world1, pos, state1, tile) -> { {
if (tile instanceof TileComputerBase computer) { return world.isClient ? null : ( world1, pos, state1, tile ) -> {
if ( tile instanceof TileComputerBase computer )
{
computer.serverTick(); computer.serverTick();
} }
}; };

View File

@ -279,7 +279,7 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT
} }
// If the computer isn't on and should be, then turn it on // If the computer isn't on and should be, then turn it on
if( startOn || (fresh && on) ) if( startOn || fresh && on )
{ {
computer.turnOn(); computer.turnOn();
startOn = false; startOn = false;

View File

@ -45,7 +45,7 @@ public interface IContainerComputer
* @param uploadId The unique ID of this upload. * @param uploadId The unique ID of this upload.
* @param files The files to upload. * @param files The files to upload.
*/ */
void startUpload(@Nonnull UUID uploadId, @Nonnull List<FileUpload> files ); void startUpload( @Nonnull UUID uploadId, @Nonnull List<FileUpload> files );
/** /**
* Append more data to partially uploaded files. * Append more data to partially uploaded files.
@ -61,7 +61,7 @@ public interface IContainerComputer
* @param uploader The player uploading files. * @param uploader The player uploading files.
* @param uploadId The unique ID of this upload. * @param uploadId The unique ID of this upload.
*/ */
void finishUpload(@Nonnull ServerPlayerEntity uploader, @Nonnull UUID uploadId ); void finishUpload( @Nonnull ServerPlayerEntity uploader, @Nonnull UUID uploadId );
/** /**
* Continue an upload. * Continue an upload.

View File

@ -22,7 +22,7 @@ import java.util.function.Predicate;
*/ */
public class ComputerMenuWithoutInventory extends ContainerComputerBase public class ComputerMenuWithoutInventory extends ContainerComputerBase
{ {
public ComputerMenuWithoutInventory(ScreenHandlerType<? extends ContainerComputerBase> type, int id, PlayerInventory player, Predicate<PlayerEntity> canUse, IComputer computer, ComputerFamily family ) public ComputerMenuWithoutInventory( ScreenHandlerType<? extends ContainerComputerBase> type, int id, PlayerInventory player, Predicate<PlayerEntity> canUse, IComputer computer, ComputerFamily family )
{ {
super( type, id, canUse, computer, family ); super( type, id, canUse, computer, family );
addSlots( player ); addSlots( player );

View File

@ -19,7 +19,6 @@ import dan200.computercraft.shared.network.client.UploadResultMessage;
import dan200.computercraft.shared.network.container.ComputerContainerData; import dan200.computercraft.shared.network.container.ComputerContainerData;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory; import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.screen.ScreenHandler; import net.minecraft.screen.ScreenHandler;
import net.minecraft.screen.ScreenHandlerType; import net.minecraft.screen.ScreenHandlerType;
import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.network.ServerPlayerEntity;
@ -113,7 +112,7 @@ public abstract class ContainerComputerBase extends ScreenHandler implements ICo
} }
@Override @Override
public void startUpload(@Nonnull UUID uuid, @Nonnull List<FileUpload> files ) public void startUpload( @Nonnull UUID uuid, @Nonnull List<FileUpload> files )
{ {
toUploadId = uuid; toUploadId = uuid;
toUpload = files; toUpload = files;
@ -132,7 +131,7 @@ public abstract class ContainerComputerBase extends ScreenHandler implements ICo
} }
@Override @Override
public void finishUpload(@Nonnull ServerPlayerEntity uploader, @Nonnull UUID uploadId ) public void finishUpload( @Nonnull ServerPlayerEntity uploader, @Nonnull UUID uploadId )
{ {
if( toUploadId == null || toUpload == null || toUpload.isEmpty() || !toUploadId.equals( uploadId ) ) if( toUploadId == null || toUpload == null || toUpload.isEmpty() || !toUploadId.equals( uploadId ) )
{ {

View File

@ -14,7 +14,6 @@ import dan200.computercraft.shared.computer.core.ServerComputer;
import dan200.computercraft.shared.network.container.ViewComputerContainerData; import dan200.computercraft.shared.network.container.ViewComputerContainerData;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory; import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.network.PacketByteBuf;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;

View File

@ -18,7 +18,7 @@ public interface IComputerItem
default int getComputerID( @Nonnull ItemStack stack ) default int getComputerID( @Nonnull ItemStack stack )
{ {
NbtCompound nbt = stack.getNbt(); NbtCompound nbt = stack.getNbt();
return nbt != null && nbt.contains( NBT_ID ) ? nbt.getInt( NBT_ID ) : -1; return nbt != null && nbt.contains( NBT_ID ) ? nbt.getInt( NBT_ID ) : -1;
} }

View File

@ -85,7 +85,7 @@ public class ItemDisk extends Item implements IMedia, IColouredItem
public static int getDiskID( @Nonnull ItemStack stack ) public static int getDiskID( @Nonnull ItemStack stack )
{ {
NbtCompound nbt = stack.getNbt(); NbtCompound nbt = stack.getNbt();
return nbt != null && nbt.contains( NBT_ID ) ? nbt.getInt( NBT_ID ) : -1; return nbt != null && nbt.contains( NBT_ID ) ? nbt.getInt( NBT_ID ) : -1;
} }

View File

@ -60,7 +60,7 @@ public class ItemPrintout extends Item
} }
if( text != null ) if( text != null )
{ {
NbtCompound tag = stack.getOrCreateNbt(); NbtCompound tag = stack.getOrCreateNbt();
tag.putInt( NBT_PAGES, text.length / LINES_PER_PAGE ); tag.putInt( NBT_PAGES, text.length / LINES_PER_PAGE );
for( int i = 0; i < text.length; i++ ) for( int i = 0; i < text.length; i++ )
{ {
@ -72,7 +72,7 @@ public class ItemPrintout extends Item
} }
if( colours != null ) if( colours != null )
{ {
NbtCompound tag = stack.getOrCreateNbt(); NbtCompound tag = stack.getOrCreateNbt();
for( int i = 0; i < colours.length; i++ ) for( int i = 0; i < colours.length; i++ )
{ {
if( colours[i] != null ) if( colours[i] != null )
@ -105,7 +105,7 @@ public class ItemPrintout extends Item
private static String[] getLines( @Nonnull ItemStack stack, String prefix ) private static String[] getLines( @Nonnull ItemStack stack, String prefix )
{ {
NbtCompound nbt = stack.getNbt(); NbtCompound nbt = stack.getNbt();
int numLines = getPageCount( stack ) * LINES_PER_PAGE; int numLines = getPageCount( stack ) * LINES_PER_PAGE;
String[] lines = new String[numLines]; String[] lines = new String[numLines];
for( int i = 0; i < lines.length; i++ ) for( int i = 0; i < lines.length; i++ )
@ -117,7 +117,7 @@ public class ItemPrintout extends Item
public static int getPageCount( @Nonnull ItemStack stack ) public static int getPageCount( @Nonnull ItemStack stack )
{ {
NbtCompound nbt = stack.getNbt(); NbtCompound nbt = stack.getNbt();
return nbt != null && nbt.contains( NBT_PAGES ) ? nbt.getInt( NBT_PAGES ) : 1; return nbt != null && nbt.contains( NBT_PAGES ) ? nbt.getInt( NBT_PAGES ) : 1;
} }
@ -152,7 +152,7 @@ public class ItemPrintout extends Item
public static String getTitle( @Nonnull ItemStack stack ) public static String getTitle( @Nonnull ItemStack stack )
{ {
NbtCompound nbt = stack.getNbt(); NbtCompound nbt = stack.getNbt();
return nbt != null && nbt.contains( NBT_TITLE ) ? nbt.getString( NBT_TITLE ) : null; return nbt != null && nbt.contains( NBT_TITLE ) ? nbt.getString( NBT_TITLE ) : null;
} }

View File

@ -62,7 +62,7 @@ public class ItemTreasureDisk extends Item implements IMedia
public static int getColour( @Nonnull ItemStack stack ) public static int getColour( @Nonnull ItemStack stack )
{ {
NbtCompound nbt = stack.getNbt(); NbtCompound nbt = stack.getNbt();
return nbt != null && nbt.contains( NBT_COLOUR ) ? nbt.getInt( NBT_COLOUR ) : Colour.BLUE.getHex(); return nbt != null && nbt.contains( NBT_COLOUR ) ? nbt.getInt( NBT_COLOUR ) : Colour.BLUE.getHex();
} }
@ -84,7 +84,7 @@ public class ItemTreasureDisk extends Item implements IMedia
@Nonnull @Nonnull
private static String getTitle( @Nonnull ItemStack stack ) private static String getTitle( @Nonnull ItemStack stack )
{ {
NbtCompound nbt = stack.getNbt(); NbtCompound nbt = stack.getNbt();
return nbt != null && nbt.contains( NBT_TITLE ) ? nbt.getString( NBT_TITLE ) : "'alongtimeago' by dan200"; return nbt != null && nbt.contains( NBT_TITLE ) ? nbt.getString( NBT_TITLE ) : "'alongtimeago' by dan200";
} }
@ -128,7 +128,7 @@ public class ItemTreasureDisk extends Item implements IMedia
@Nonnull @Nonnull
private static String getSubPath( @Nonnull ItemStack stack ) private static String getSubPath( @Nonnull ItemStack stack )
{ {
NbtCompound nbt = stack.getNbt(); NbtCompound nbt = stack.getNbt();
return nbt != null && nbt.contains( NBT_SUB_PATH ) ? nbt.getString( NBT_SUB_PATH ) : "dan200/alongtimeago"; return nbt != null && nbt.contains( NBT_SUB_PATH ) ? nbt.getString( NBT_SUB_PATH ) : "dan200/alongtimeago";
} }
} }

View File

@ -153,8 +153,10 @@ public final class NetworkHandler
public static void sendToAllTracking( NetworkMessage packet, WorldChunk chunk ) public static void sendToAllTracking( NetworkMessage packet, WorldChunk chunk )
{ {
// maybe bug with worlds // maybe bug with worlds
for(PlayerEntity player : chunk.getWorld().getPlayers()) { for( PlayerEntity player : chunk.getWorld().getPlayers() )
if (player.getChunkPos().equals(chunk.getPos())) { {
if ( player.getChunkPos().equals( chunk.getPos() ) )
{
((ServerPlayerEntity) player).networkHandler.sendPacket( new CustomPayloadS2CPacket( ID, encode( packet ) ) ); ((ServerPlayerEntity) player).networkHandler.sendPacket( new CustomPayloadS2CPacket( ID, encode( packet ) ) );
} }
} }

View File

@ -30,7 +30,7 @@ public class ChatTableClientMessage implements NetworkMessage
this.table = table; this.table = table;
} }
public ChatTableClientMessage(@Nonnull PacketByteBuf buf) public ChatTableClientMessage( @Nonnull PacketByteBuf buf )
{ {
int id = buf.readVarInt(); int id = buf.readVarInt();
int columns = buf.readVarInt(); int columns = buf.readVarInt();

View File

@ -12,7 +12,6 @@ import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.network.PacketContext; import net.fabricmc.fabric.api.network.PacketContext;
import net.minecraft.network.PacketByteBuf; import net.minecraft.network.PacketByteBuf;
import net.minecraft.sound.SoundEvent; import net.minecraft.sound.SoundEvent;
import net.minecraft.sound.SoundEvents;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
@ -68,7 +67,7 @@ public class SpeakerPlayClientMessage implements NetworkMessage
@Environment( EnvType.CLIENT ) @Environment( EnvType.CLIENT )
public void handle( PacketContext context ) public void handle( PacketContext context )
{ {
SoundEvent sound = new SoundEvent(this.sound); SoundEvent sound = new SoundEvent( this.sound );
SoundManager.playSound( source, pos, sound, volume, pitch ); SoundManager.playSound( source, pos, sound, volume, pitch );
} }
} }

View File

@ -43,7 +43,7 @@ public class SpeakerStopClientMessage implements NetworkMessage
} }
@Override @Override
@Environment(EnvType.CLIENT) @Environment( EnvType.CLIENT )
public void handle( PacketContext context ) public void handle( PacketContext context )
{ {
SoundManager.stopSound( source ); SoundManager.stopSound( source );

View File

@ -6,7 +6,6 @@
package dan200.computercraft.shared.network.container; package dan200.computercraft.shared.network.container;
import dan200.computercraft.shared.computer.inventory.ContainerComputerBase;
import net.fabricmc.fabric.api.screenhandler.v1.ScreenHandlerRegistry; import net.fabricmc.fabric.api.screenhandler.v1.ScreenHandlerRegistry;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory; import net.minecraft.entity.player.PlayerInventory;
@ -24,7 +23,7 @@ import java.util.function.Function;
*/ */
public interface ContainerData public interface ContainerData
{ {
static <C extends ScreenHandler, T extends ContainerData> ScreenHandlerType<C> toType(Identifier identifier, Function<PacketByteBuf, T> reader, static <C extends ScreenHandler, T extends ContainerData> ScreenHandlerType<C> toType( Identifier identifier, Function<PacketByteBuf, T> reader,
Factory<C, T> factory ) Factory<C, T> factory )
{ {
return ScreenHandlerRegistry.registerExtended( identifier, return ScreenHandlerRegistry.registerExtended( identifier,
@ -32,7 +31,7 @@ public interface ContainerData
playerInventory, playerInventory,
reader.apply( packetByteBuf ) ) ); reader.apply( packetByteBuf ) ) );
} }
static <C extends ScreenHandler, T extends ContainerData> ScreenHandlerType<C> toType(Identifier identifier, ScreenHandlerType<C> type, Function<PacketByteBuf, T> reader, static <C extends ScreenHandler, T extends ContainerData> ScreenHandlerType<C> toType( Identifier identifier, ScreenHandlerType<C> type, Function<PacketByteBuf, T> reader,
FixedFactory<C, T> factory ) FixedFactory<C, T> factory )
{ {
return ScreenHandlerRegistry.registerExtended( identifier, return ScreenHandlerRegistry.registerExtended( identifier,
@ -45,7 +44,7 @@ public interface ContainerData
default void open( PlayerEntity player, NamedScreenHandlerFactory owner ) default void open( PlayerEntity player, NamedScreenHandlerFactory owner )
{ {
if (player.world.isClient) return; if ( player.world.isClient ) return;
player.openHandledScreen( owner ); player.openHandledScreen( owner );
} }

View File

@ -6,11 +6,9 @@
package dan200.computercraft.shared.network.container; package dan200.computercraft.shared.network.container;
import dan200.computercraft.ComputerCraft;
import dan200.computercraft.core.terminal.Terminal; import dan200.computercraft.core.terminal.Terminal;
import dan200.computercraft.shared.computer.core.ServerComputer; import dan200.computercraft.shared.computer.core.ServerComputer;
import net.minecraft.network.PacketByteBuf; import net.minecraft.network.PacketByteBuf;
import net.minecraft.util.Identifier;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;

View File

@ -37,7 +37,7 @@ public class ComputerActionServerMessage extends ComputerServerMessage
} }
@Override @Override
protected void handle(PacketContext context, @Nonnull ServerComputer computer, @Nonnull IContainerComputer container ) protected void handle( PacketContext context, @Nonnull ServerComputer computer, @Nonnull IContainerComputer container )
{ {
switch( action ) switch( action )
{ {

View File

@ -8,7 +8,6 @@ package dan200.computercraft.shared.network.server;
import dan200.computercraft.shared.computer.core.IContainerComputer; import dan200.computercraft.shared.computer.core.IContainerComputer;
import dan200.computercraft.shared.computer.core.ServerComputer; import dan200.computercraft.shared.computer.core.ServerComputer;
import net.fabricmc.fabric.api.network.PacketContext; import net.fabricmc.fabric.api.network.PacketContext;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.network.PacketByteBuf; import net.minecraft.network.PacketByteBuf;
import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.network.ServerPlayerEntity;
@ -38,7 +37,7 @@ public class ContinueUploadMessage extends ComputerServerMessage
} }
@Override @Override
protected void handle(PacketContext context, @Nonnull ServerComputer computer, @Nonnull IContainerComputer container ) protected void handle( PacketContext context, @Nonnull ServerComputer computer, @Nonnull IContainerComputer container )
{ {
ServerPlayerEntity player = (ServerPlayerEntity) context.getPlayer(); ServerPlayerEntity player = (ServerPlayerEntity) context.getPlayer();
if( player != null ) container.confirmUpload( player, overwrite ); if( player != null ) container.confirmUpload( player, overwrite );

View File

@ -46,7 +46,7 @@ public class KeyEventServerMessage extends ComputerServerMessage
} }
@Override @Override
protected void handle(PacketContext context, @Nonnull ServerComputer computer, @Nonnull IContainerComputer container ) protected void handle( PacketContext context, @Nonnull ServerComputer computer, @Nonnull IContainerComputer container )
{ {
InputState input = container.getInput(); InputState input = container.getInput();
if( type == TYPE_UP ) if( type == TYPE_UP )

View File

@ -55,7 +55,7 @@ public class MouseEventServerMessage extends ComputerServerMessage
} }
@Override @Override
protected void handle(PacketContext context, @Nonnull ServerComputer computer, @Nonnull IContainerComputer container ) protected void handle( PacketContext context, @Nonnull ServerComputer computer, @Nonnull IContainerComputer container )
{ {
InputState input = container.getInput(); InputState input = container.getInput();
switch( type ) switch( type )

View File

@ -52,7 +52,7 @@ public class QueueEventServerMessage extends ComputerServerMessage
} }
@Override @Override
protected void handle(PacketContext context, @Nonnull ServerComputer computer, @Nonnull IContainerComputer container ) protected void handle( PacketContext context, @Nonnull ServerComputer computer, @Nonnull IContainerComputer container )
{ {
computer.queueEvent( event, args ); computer.queueEvent( event, args );
} }

View File

@ -13,7 +13,6 @@ import dan200.computercraft.shared.computer.upload.FileUpload;
import dan200.computercraft.shared.network.NetworkHandler; import dan200.computercraft.shared.network.NetworkHandler;
import io.netty.handler.codec.DecoderException; import io.netty.handler.codec.DecoderException;
import net.fabricmc.fabric.api.network.PacketContext; import net.fabricmc.fabric.api.network.PacketContext;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.network.PacketByteBuf; import net.minecraft.network.PacketByteBuf;
import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.network.ServerPlayerEntity;
@ -174,7 +173,7 @@ public class UploadFileMessage extends ComputerServerMessage
} }
@Override @Override
protected void handle(PacketContext context, @Nonnull ServerComputer computer, @Nonnull IContainerComputer container ) protected void handle( PacketContext context, @Nonnull ServerComputer computer, @Nonnull IContainerComputer container )
{ {
ServerPlayerEntity player = (ServerPlayerEntity) context.getPlayer(); ServerPlayerEntity player = (ServerPlayerEntity) context.getPlayer();
if( player != null ) if( player != null )

View File

@ -8,9 +8,6 @@ package dan200.computercraft.shared.peripheral.diskdrive;
import dan200.computercraft.shared.ComputerCraftRegistry; import dan200.computercraft.shared.ComputerCraftRegistry;
import dan200.computercraft.shared.common.BlockGeneric; import dan200.computercraft.shared.common.BlockGeneric;
import dan200.computercraft.shared.computer.blocks.TileComputer;
import dan200.computercraft.shared.peripheral.speaker.BlockSpeaker;
import dan200.computercraft.shared.peripheral.speaker.TileSpeaker;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.BlockEntity;
@ -57,8 +54,9 @@ public class BlockDiskDrive extends BlockGeneric
@Nullable @Nullable
@Override @Override
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(World world, BlockState state, BlockEntityType<T> type){ public <T extends BlockEntity> BlockEntityTicker<T> getTicker( World world, BlockState state, BlockEntityType<T> type )
return world.isClient ? null : BlockDiskDrive.checkType( type, ComputerCraftRegistry.ModTiles.DISK_DRIVE, TileDiskDrive::tick ); {
return world.isClient ? null : BlockDiskDrive.checkType( type, ComputerCraftRegistry.ModTiles.DISK_DRIVE, TileDiskDrive::tick );
} }
@Override @Override
@ -102,8 +100,8 @@ public class BlockDiskDrive extends BlockGeneric
@Nullable @Nullable
@Override @Override
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) public BlockEntity createBlockEntity( BlockPos pos, BlockState state )
{ {
return new TileDiskDrive(ComputerCraftRegistry.ModTiles.DISK_DRIVE, pos, state); return new TileDiskDrive( ComputerCraftRegistry.ModTiles.DISK_DRIVE, pos, state );
} }
} }

View File

@ -114,7 +114,7 @@ public final class TileDiskDrive extends TileGeneric implements DefaultInventory
customName = nbt.contains( NBT_NAME ) ? Text.Serializer.fromJson( nbt.getString( NBT_NAME ) ) : null; customName = nbt.contains( NBT_NAME ) ? Text.Serializer.fromJson( nbt.getString( NBT_NAME ) ) : null;
if( nbt.contains( NBT_ITEM ) ) if( nbt.contains( NBT_ITEM ) )
{ {
NbtCompound item = nbt.getCompound( NBT_ITEM ); NbtCompound item = nbt.getCompound( NBT_ITEM );
diskStack = ItemStack.fromNbt( item ); diskStack = ItemStack.fromNbt( item );
diskMount = null; diskMount = null;
} }
@ -132,7 +132,7 @@ public final class TileDiskDrive extends TileGeneric implements DefaultInventory
if( !diskStack.isEmpty() ) if( !diskStack.isEmpty() )
{ {
NbtCompound item = new NbtCompound(); NbtCompound item = new NbtCompound();
diskStack.writeNbt( item ); diskStack.writeNbt( item );
nbt.put( NBT_ITEM, item ); nbt.put( NBT_ITEM, item );
} }
@ -149,13 +149,13 @@ public final class TileDiskDrive extends TileGeneric implements DefaultInventory
super.markDirty(); super.markDirty();
} }
public static void tick( World world, BlockPos pos, BlockState state, TileDiskDrive tileDiskDrive) public static void tick( World world, BlockPos pos, BlockState state, TileDiskDrive tileDiskDrive )
{ {
// Ejection // Ejection
if( tileDiskDrive.ejectQueued ) if( tileDiskDrive.ejectQueued )
{ {
tileDiskDrive.ejectContents( false ); tileDiskDrive.ejectContents( false );
tileDiskDrive.ejectQueued = false; tileDiskDrive.ejectQueued = false;
} }
// Music // Music
@ -163,24 +163,24 @@ public final class TileDiskDrive extends TileGeneric implements DefaultInventory
{ {
if( !world.isClient && tileDiskDrive.recordPlaying != tileDiskDrive.recordQueued || tileDiskDrive.restartRecord ) if( !world.isClient && tileDiskDrive.recordPlaying != tileDiskDrive.recordQueued || tileDiskDrive.restartRecord )
{ {
tileDiskDrive.restartRecord = false; tileDiskDrive.restartRecord = false;
if( tileDiskDrive.recordQueued ) if( tileDiskDrive.recordQueued )
{ {
IMedia contents = tileDiskDrive.getDiskMedia(); IMedia contents = tileDiskDrive.getDiskMedia();
SoundEvent record = contents != null ? contents.getAudio( tileDiskDrive.diskStack ) : null; SoundEvent record = contents != null ? contents.getAudio( tileDiskDrive.diskStack ) : null;
if( record != null ) if( record != null )
{ {
tileDiskDrive.recordPlaying = true; tileDiskDrive.recordPlaying = true;
tileDiskDrive.playRecord(); tileDiskDrive.playRecord();
} }
else else
{ {
tileDiskDrive.recordQueued = false; tileDiskDrive.recordQueued = false;
} }
} }
else else
{ {
tileDiskDrive.stopRecord(); tileDiskDrive.stopRecord();
tileDiskDrive.recordPlaying = false; tileDiskDrive.recordPlaying = false;
} }
} }

View File

@ -72,7 +72,7 @@ public class ItemData
// requireNonNull is safe because we got the Identifiers out of the TagGroup to start with. Would be nicer // requireNonNull is safe because we got the Identifiers out of the TagGroup to start with. Would be nicer
// to stream the tags directly but TagGroup isn't a collection :( // to stream the tags directly but TagGroup isn't a collection :(
TagGroup<Item> itemTags = ServerTagManagerHolder.getTagManager().getOrCreateTagGroup(Registry.ITEM_KEY); TagGroup<Item> itemTags = ServerTagManagerHolder.getTagManager().getOrCreateTagGroup( Registry.ITEM_KEY );
data.put( "tags", DataHelpers.getTags( itemTags.getTagIds().stream() data.put( "tags", DataHelpers.getTags( itemTags.getTagIds().stream()
.filter( id -> Objects.requireNonNull( itemTags.getTag( id ) ).contains( stack.getItem() ) ) .filter( id -> Objects.requireNonNull( itemTags.getTag( id ) ).contains( stack.getItem() ) )
.collect( Collectors.toList() ) .collect( Collectors.toList() )
@ -81,7 +81,7 @@ public class ItemData
NbtCompound tag = stack.getNbt(); NbtCompound tag = stack.getNbt();
if( tag != null && tag.contains( "display", NBTUtil.TAG_COMPOUND ) ) if( tag != null && tag.contains( "display", NBTUtil.TAG_COMPOUND ) )
{ {
NbtCompound displayTag = tag.getCompound( "display" ); NbtCompound displayTag = tag.getCompound( "display" );
if( displayTag.contains( "Lore", NBTUtil.TAG_LIST ) ) if( displayTag.contains( "Lore", NBTUtil.TAG_LIST ) )
{ {
NbtList loreTag = displayTag.getList( "Lore", NBTUtil.TAG_STRING ); NbtList loreTag = displayTag.getList( "Lore", NBTUtil.TAG_STRING );

View File

@ -10,7 +10,6 @@ import com.google.common.collect.ImmutableMap;
import dan200.computercraft.api.ComputerCraftAPI; import dan200.computercraft.api.ComputerCraftAPI;
import dan200.computercraft.shared.ComputerCraftRegistry; import dan200.computercraft.shared.ComputerCraftRegistry;
import dan200.computercraft.shared.common.BlockGeneric; import dan200.computercraft.shared.common.BlockGeneric;
import dan200.computercraft.shared.peripheral.printer.TilePrinter;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.ShapeContext; import net.minecraft.block.ShapeContext;
@ -275,8 +274,8 @@ public class BlockCable extends BlockGeneric implements Waterloggable
@Nullable @Nullable
@Override @Override
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) public BlockEntity createBlockEntity( BlockPos pos, BlockState state )
{ {
return new TileCable(ComputerCraftRegistry.ModTiles.CABLE, pos, state); return new TileCable( ComputerCraftRegistry.ModTiles.CABLE, pos, state );
} }
} }

View File

@ -8,7 +8,6 @@ package dan200.computercraft.shared.peripheral.modem.wired;
import dan200.computercraft.shared.ComputerCraftRegistry; import dan200.computercraft.shared.ComputerCraftRegistry;
import dan200.computercraft.shared.common.BlockGeneric; import dan200.computercraft.shared.common.BlockGeneric;
import dan200.computercraft.shared.peripheral.speaker.TileSpeaker;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.BlockEntity;
@ -40,8 +39,8 @@ public class BlockWiredModemFull extends BlockGeneric
@Nullable @Nullable
@Override @Override
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) public BlockEntity createBlockEntity( BlockPos pos, BlockState state )
{ {
return new TileWiredModemFull(ComputerCraftRegistry.ModTiles.WIRED_MODEM_FULL, pos, state); return new TileWiredModemFull( ComputerCraftRegistry.ModTiles.WIRED_MODEM_FULL, pos, state );
} }
} }

View File

@ -388,7 +388,7 @@ public class TileCable extends TileGeneric implements IPeripheralTile
@Override @Override
public NbtCompound writeNbt( NbtCompound nbt ) public NbtCompound writeNbt( NbtCompound nbt )
{ {
super.writeNbt( nbt ); super.writeNbt( nbt );
nbt.putBoolean( NBT_PERIPHERAL_ENABLED, peripheralAccessAllowed ); nbt.putBoolean( NBT_PERIPHERAL_ENABLED, peripheralAccessAllowed );
peripheral.write( nbt, "" ); peripheral.write( nbt, "" );
return nbt; return nbt;
@ -409,10 +409,10 @@ public class TileCable extends TileGeneric implements IPeripheralTile
} }
@Override @Override
public void setCachedState(BlockState state) public void setCachedState( BlockState state )
{ {
super.setCachedState(state); super.setCachedState( state );
if(state != null) return; if( state != null ) return;
hasModemDirection = false; hasModemDirection = false;
if( !world.isClient ) if( !world.isClient )
{ {

View File

@ -329,7 +329,7 @@ public class TileWiredModemFull extends TileGeneric implements IPeripheralTile
@Override @Override
public NbtCompound writeNbt( NbtCompound nbt ) public NbtCompound writeNbt( NbtCompound nbt )
{ {
super.writeNbt( nbt ); super.writeNbt( nbt );
nbt.putBoolean( NBT_PERIPHERAL_ENABLED, peripheralAccessAllowed ); nbt.putBoolean( NBT_PERIPHERAL_ENABLED, peripheralAccessAllowed );
for( int i = 0; i < peripherals.length; i++ ) for( int i = 0; i < peripherals.length; i++ )
{ {

View File

@ -8,10 +8,8 @@ package dan200.computercraft.shared.peripheral.modem.wireless;
import dan200.computercraft.shared.ComputerCraftRegistry; import dan200.computercraft.shared.ComputerCraftRegistry;
import dan200.computercraft.shared.common.BlockGeneric; import dan200.computercraft.shared.common.BlockGeneric;
import dan200.computercraft.shared.computer.blocks.TileComputer;
import dan200.computercraft.shared.computer.core.ComputerFamily; import dan200.computercraft.shared.computer.core.ComputerFamily;
import dan200.computercraft.shared.peripheral.modem.ModemShapes; import dan200.computercraft.shared.peripheral.modem.ModemShapes;
import dan200.computercraft.shared.peripheral.modem.wired.TileWiredModemFull;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.ShapeContext; import net.minecraft.block.ShapeContext;
@ -43,7 +41,7 @@ public class BlockWirelessModem extends BlockGeneric implements Waterloggable
private final ComputerFamily family; private final ComputerFamily family;
public BlockWirelessModem(Settings settings, BlockEntityType<? extends TileWirelessModem> type, ComputerFamily family) public BlockWirelessModem( Settings settings, BlockEntityType<? extends TileWirelessModem> type, ComputerFamily family )
{ {
super( settings, type ); super( settings, type );
this.family = family; this.family = family;
@ -104,9 +102,10 @@ public class BlockWirelessModem extends BlockGeneric implements Waterloggable
builder.add( FACING, ON, WATERLOGGED ); builder.add( FACING, ON, WATERLOGGED );
} }
public BlockEntityType<? extends TileWirelessModem> getTypeByFamily(ComputerFamily family) public BlockEntityType<? extends TileWirelessModem> getTypeByFamily( ComputerFamily family )
{ {
return switch (family) { return switch ( family )
{
case ADVANCED -> ComputerCraftRegistry.ModTiles.WIRELESS_MODEM_ADVANCED; case ADVANCED -> ComputerCraftRegistry.ModTiles.WIRELESS_MODEM_ADVANCED;
default -> ComputerCraftRegistry.ModTiles.WIRELESS_MODEM_NORMAL; default -> ComputerCraftRegistry.ModTiles.WIRELESS_MODEM_NORMAL;
}; };
@ -114,8 +113,8 @@ public class BlockWirelessModem extends BlockGeneric implements Waterloggable
@Nullable @Nullable
@Override @Override
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) public BlockEntity createBlockEntity( BlockPos pos, BlockState state )
{ {
return new TileWirelessModem(getTypeByFamily(family), family == ComputerFamily.ADVANCED, pos, state); return new TileWirelessModem( getTypeByFamily( family ), family == ComputerFamily.ADVANCED, pos, state );
} }
} }

View File

@ -8,7 +8,6 @@ package dan200.computercraft.shared.peripheral.modem.wireless;
import dan200.computercraft.api.peripheral.IPeripheral; import dan200.computercraft.api.peripheral.IPeripheral;
import dan200.computercraft.api.peripheral.IPeripheralTile; import dan200.computercraft.api.peripheral.IPeripheralTile;
import dan200.computercraft.shared.ComputerCraftRegistry.ModTiles;
import dan200.computercraft.shared.common.TileGeneric; import dan200.computercraft.shared.common.TileGeneric;
import dan200.computercraft.shared.peripheral.modem.ModemPeripheral; import dan200.computercraft.shared.peripheral.modem.ModemPeripheral;
import dan200.computercraft.shared.peripheral.modem.ModemState; import dan200.computercraft.shared.peripheral.modem.ModemState;
@ -45,10 +44,10 @@ public class TileWirelessModem extends TileGeneric implements IPeripheralTile
} }
@Override @Override
public void setCachedState(BlockState state) public void setCachedState( BlockState state )
{ {
super.setCachedState(state); super.setCachedState( state );
if(state != null) return; if( state != null ) return;
hasModemDirection = false; hasModemDirection = false;
world.getBlockTickScheduler() world.getBlockTickScheduler()
.schedule( getPos(), .schedule( getPos(),

View File

@ -9,7 +9,6 @@ package dan200.computercraft.shared.peripheral.monitor;
import dan200.computercraft.api.turtle.FakePlayer; import dan200.computercraft.api.turtle.FakePlayer;
import dan200.computercraft.shared.ComputerCraftRegistry; import dan200.computercraft.shared.ComputerCraftRegistry;
import dan200.computercraft.shared.common.BlockGeneric; import dan200.computercraft.shared.common.BlockGeneric;
import dan200.computercraft.shared.computer.blocks.TileComputer;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.BlockEntity;
@ -104,8 +103,8 @@ public class BlockMonitor extends BlockGeneric
@Nullable @Nullable
@Override @Override
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) public BlockEntity createBlockEntity( BlockPos pos, BlockState state )
{ {
return new TileMonitor(advanced ? ComputerCraftRegistry.ModTiles.MONITOR_ADVANCED : ComputerCraftRegistry.ModTiles.MONITOR_NORMAL, advanced, pos, state); return new TileMonitor( advanced ? ComputerCraftRegistry.ModTiles.MONITOR_ADVANCED : ComputerCraftRegistry.ModTiles.MONITOR_NORMAL, advanced, pos, state );
} }
} }

View File

@ -8,7 +8,6 @@ package dan200.computercraft.shared.peripheral.monitor;
import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.systems.RenderSystem;
import dan200.computercraft.client.gui.FixedWidthFontRenderer;
import dan200.computercraft.shared.common.ClientTerminal; import dan200.computercraft.shared.common.ClientTerminal;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;

View File

@ -259,7 +259,7 @@ public class TileMonitor extends TileGeneric implements IPeripheralTile
{ {
if( pos.equals( getPos() ) ) if( pos.equals( getPos() ) )
{ {
return MonitorState.present(this); return MonitorState.present( this );
} }
World world = getWorld(); World world = getWorld();
@ -309,7 +309,7 @@ public class TileMonitor extends TileGeneric implements IPeripheralTile
@Override @Override
public NbtCompound writeNbt( NbtCompound tag ) public NbtCompound writeNbt( NbtCompound tag )
{ {
super.writeNbt( tag ); super.writeNbt( tag );
tag.putInt( NBT_X, xIndex ); tag.putInt( NBT_X, xIndex );
tag.putInt( NBT_Y, yIndex ); tag.putInt( NBT_Y, yIndex );
tag.putInt( NBT_WIDTH, width ); tag.putInt( NBT_WIDTH, width );
@ -317,11 +317,11 @@ public class TileMonitor extends TileGeneric implements IPeripheralTile
return tag; return tag;
} }
// @Override //TODO: make BlockEntityRenderer work with this, i guess. // @Override //TODO: make BlockEntityRenderer work with this, i guess.
// public double getRenderDistance() // public double getRenderDistance()
// { // {
// return ComputerCraft.monitorDistanceSq; // return ComputerCraft.monitorDistanceSq;
// } // }
// Sizing and placement stuff // Sizing and placement stuff

View File

@ -8,7 +8,6 @@ package dan200.computercraft.shared.peripheral.printer;
import dan200.computercraft.shared.ComputerCraftRegistry; import dan200.computercraft.shared.ComputerCraftRegistry;
import dan200.computercraft.shared.common.BlockGeneric; import dan200.computercraft.shared.common.BlockGeneric;
import dan200.computercraft.shared.computer.blocks.TileComputer;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.BlockEntity;
@ -92,8 +91,8 @@ public class BlockPrinter extends BlockGeneric
@Nullable @Nullable
@Override @Override
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) public BlockEntity createBlockEntity( BlockPos pos, BlockState state )
{ {
return new TilePrinter(ComputerCraftRegistry.ModTiles.PRINTER, pos, state); return new TilePrinter( ComputerCraftRegistry.ModTiles.PRINTER, pos, state );
} }
} }

View File

@ -8,7 +8,6 @@ package dan200.computercraft.shared.peripheral.speaker;
import dan200.computercraft.shared.ComputerCraftRegistry; import dan200.computercraft.shared.ComputerCraftRegistry;
import dan200.computercraft.shared.common.BlockGeneric; import dan200.computercraft.shared.common.BlockGeneric;
import dan200.computercraft.shared.turtle.blocks.TileTurtle;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.BlockEntity;
@ -52,15 +51,16 @@ public class BlockSpeaker extends BlockGeneric
@Nullable @Nullable
@Override @Override
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) public BlockEntity createBlockEntity( BlockPos pos, BlockState state )
{ {
return new TileSpeaker(ComputerCraftRegistry.ModTiles.SPEAKER, pos, state); return new TileSpeaker( ComputerCraftRegistry.ModTiles.SPEAKER, pos, state );
} }
@Nullable @Nullable
@Override @Override
public <T extends BlockEntity> BlockEntityTicker<T> getTicker( World world, BlockState state, BlockEntityType<T> type){ public <T extends BlockEntity> BlockEntityTicker<T> getTicker( World world, BlockState state, BlockEntityType<T> type )
return world.isClient ? null : BlockSpeaker.checkType( type, ComputerCraftRegistry.ModTiles.SPEAKER, TileSpeaker::tick ); {
return world.isClient ? null : BlockSpeaker.checkType( type, ComputerCraftRegistry.ModTiles.SPEAKER, TileSpeaker::tick );
} }
} }

View File

@ -147,7 +147,9 @@ public abstract class SpeakerPeripheral implements IPeripheral
null, pos.x, pos.y, pos.z, range, world.getRegistryKey(), null, pos.x, pos.y, pos.z, range, world.getRegistryKey(),
new PlaySoundIdS2CPacket( name, SoundCategory.RECORDS, pos, actualVolume, pitch ) new PlaySoundIdS2CPacket( name, SoundCategory.RECORDS, pos, actualVolume, pitch )
); );
} else { }
else
{
NetworkHandler.sendToAllAround( NetworkHandler.sendToAllAround(
new SpeakerPlayClientMessage( getSource(), pos, name, actualVolume, pitch ), new SpeakerPlayClientMessage( getSource(), pos, name, actualVolume, pitch ),
world, pos, range world, pos, range

View File

@ -9,7 +9,6 @@ package dan200.computercraft.shared.peripheral.speaker;
import dan200.computercraft.api.peripheral.IPeripheral; import dan200.computercraft.api.peripheral.IPeripheral;
import dan200.computercraft.api.peripheral.IPeripheralTile; import dan200.computercraft.api.peripheral.IPeripheralTile;
import dan200.computercraft.shared.common.TileGeneric; import dan200.computercraft.shared.common.TileGeneric;
import dan200.computercraft.shared.computer.blocks.TileComputerBase;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntityType; import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;

View File

@ -87,14 +87,14 @@ public class PocketServerComputer extends ServerComputer implements IPocketAcces
@Override @Override
public int getLight() public int getLight()
{ {
NbtCompound tag = getUserData(); NbtCompound tag = getUserData();
return tag.contains( NBT_LIGHT, NBTUtil.TAG_ANY_NUMERIC ) ? tag.getInt( NBT_LIGHT ) : -1; return tag.contains( NBT_LIGHT, NBTUtil.TAG_ANY_NUMERIC ) ? tag.getInt( NBT_LIGHT ) : -1;
} }
@Override @Override
public void setLight( int colour ) public void setLight( int colour )
{ {
NbtCompound tag = getUserData(); NbtCompound tag = getUserData();
if( colour >= 0 && colour <= 0xFFFFFF ) if( colour >= 0 && colour <= 0xFFFFFF )
{ {
if( !tag.contains( NBT_LIGHT, NBTUtil.TAG_ANY_NUMERIC ) || tag.getInt( NBT_LIGHT ) != colour ) if( !tag.contains( NBT_LIGHT, NBTUtil.TAG_ANY_NUMERIC ) || tag.getInt( NBT_LIGHT ) != colour )

View File

@ -6,7 +6,6 @@
package dan200.computercraft.shared.pocket.inventory; package dan200.computercraft.shared.pocket.inventory;
import dan200.computercraft.shared.ComputerCraftRegistry; import dan200.computercraft.shared.ComputerCraftRegistry;
import dan200.computercraft.shared.computer.core.ComputerFamily;
import dan200.computercraft.shared.computer.core.ServerComputer; import dan200.computercraft.shared.computer.core.ServerComputer;
import dan200.computercraft.shared.computer.inventory.ComputerMenuWithoutInventory; import dan200.computercraft.shared.computer.inventory.ComputerMenuWithoutInventory;
import dan200.computercraft.shared.pocket.items.ItemPocketComputer; import dan200.computercraft.shared.pocket.items.ItemPocketComputer;
@ -32,7 +31,7 @@ public class PocketComputerMenuProvider implements NamedScreenHandlerFactory, Ex
private final Hand hand; private final Hand hand;
private final boolean isTypingOnly; private final boolean isTypingOnly;
public PocketComputerMenuProvider(ServerComputer computer, ItemStack stack, ItemPocketComputer item, Hand hand, boolean isTypingOnly ) public PocketComputerMenuProvider( ServerComputer computer, ItemStack stack, ItemPocketComputer item, Hand hand, boolean isTypingOnly )
{ {
this.computer = computer; this.computer = computer;
name = stack.getName(); name = stack.getName();
@ -51,7 +50,7 @@ public class PocketComputerMenuProvider implements NamedScreenHandlerFactory, Ex
@Nullable @Nullable
@Override @Override
public ScreenHandler createMenu(int id, @Nonnull PlayerInventory inventory, @Nonnull PlayerEntity entity ) public ScreenHandler createMenu( int id, @Nonnull PlayerInventory inventory, @Nonnull PlayerEntity entity )
{ {
return new ComputerMenuWithoutInventory( return new ComputerMenuWithoutInventory(
isTypingOnly ? ComputerCraftRegistry.ModContainers.POCKET_COMPUTER_NO_TERM : ComputerCraftRegistry.ModContainers.POCKET_COMPUTER, id, inventory, isTypingOnly ? ComputerCraftRegistry.ModContainers.POCKET_COMPUTER_NO_TERM : ComputerCraftRegistry.ModContainers.POCKET_COMPUTER, id, inventory,
@ -64,8 +63,9 @@ public class PocketComputerMenuProvider implements NamedScreenHandlerFactory, Ex
} }
@Override @Override
public void writeScreenOpeningData(ServerPlayerEntity player, PacketByteBuf packetByteBuf) { public void writeScreenOpeningData( ServerPlayerEntity player, PacketByteBuf packetByteBuf )
packetByteBuf.writeInt(computer.getInstanceID()); {
packetByteBuf.writeEnumConstant(computer.getFamily()); packetByteBuf.writeInt( computer.getInstanceID() );
packetByteBuf.writeEnumConstant( computer.getFamily() );
} }
} }

View File

@ -92,7 +92,7 @@ public class ItemPocketComputer extends Item implements IComputerItem, IMedia, I
ClientComputer computer = getClientComputer( stack ); ClientComputer computer = getClientComputer( stack );
if( computer != null && computer.isOn() ) if( computer != null && computer.isOn() )
{ {
NbtCompound computerNBT = computer.getUserData(); NbtCompound computerNBT = computer.getUserData();
if( computerNBT != null && computerNBT.contains( NBT_LIGHT ) ) if( computerNBT != null && computerNBT.contains( NBT_LIGHT ) )
{ {
return computerNBT.getInt( NBT_LIGHT ); return computerNBT.getInt( NBT_LIGHT );
@ -103,7 +103,7 @@ public class ItemPocketComputer extends Item implements IComputerItem, IMedia, I
public static void setUpgrade( @Nonnull ItemStack stack, IPocketUpgrade upgrade ) public static void setUpgrade( @Nonnull ItemStack stack, IPocketUpgrade upgrade )
{ {
NbtCompound compound = stack.getOrCreateNbt(); NbtCompound compound = stack.getOrCreateNbt();
if( upgrade == null ) if( upgrade == null )
{ {
@ -164,7 +164,6 @@ public class ItemPocketComputer extends Item implements IComputerItem, IMedia, I
if( !stop && computer != null ) if( !stop && computer != null )
{ {
// computer.sendTerminalState( player );
boolean isTypingOnly = hand == Hand.OFF_HAND; boolean isTypingOnly = hand == Hand.OFF_HAND;
new ComputerContainerData( computer ).open( player, new PocketComputerMenuProvider( computer, stack, this, hand, isTypingOnly ) ); new ComputerContainerData( computer ).open( player, new PocketComputerMenuProvider( computer, stack, this, hand, isTypingOnly ) );
} }
@ -342,7 +341,7 @@ public class ItemPocketComputer extends Item implements IComputerItem, IMedia, I
public static IPocketUpgrade getUpgrade( @Nonnull ItemStack stack ) public static IPocketUpgrade getUpgrade( @Nonnull ItemStack stack )
{ {
NbtCompound compound = stack.getNbt(); NbtCompound compound = stack.getNbt();
return compound != null && compound.contains( NBT_UPGRADE ) ? PocketUpgrades.get( compound.getString( NBT_UPGRADE ) ) : null; return compound != null && compound.contains( NBT_UPGRADE ) ? PocketUpgrades.get( compound.getString( NBT_UPGRADE ) ) : null;
} }
@ -403,13 +402,13 @@ public class ItemPocketComputer extends Item implements IComputerItem, IMedia, I
private static int getInstanceID( @Nonnull ItemStack stack ) private static int getInstanceID( @Nonnull ItemStack stack )
{ {
NbtCompound nbt = stack.getNbt(); NbtCompound nbt = stack.getNbt();
return nbt != null && nbt.contains( NBT_INSTANCE ) ? nbt.getInt( NBT_INSTANCE ) : -1; return nbt != null && nbt.contains( NBT_INSTANCE ) ? nbt.getInt( NBT_INSTANCE ) : -1;
} }
private static int getSessionID( @Nonnull ItemStack stack ) private static int getSessionID( @Nonnull ItemStack stack )
{ {
NbtCompound nbt = stack.getNbt(); NbtCompound nbt = stack.getNbt();
return nbt != null && nbt.contains( NBT_SESSION ) ? nbt.getInt( NBT_SESSION ) : -1; return nbt != null && nbt.contains( NBT_SESSION ) ? nbt.getInt( NBT_SESSION ) : -1;
} }

View File

@ -7,7 +7,6 @@
package dan200.computercraft.shared.pocket.peripherals; package dan200.computercraft.shared.pocket.peripherals;
import dan200.computercraft.api.peripheral.IPeripheral; import dan200.computercraft.api.peripheral.IPeripheral;
import dan200.computercraft.shared.peripheral.speaker.SpeakerPeripheral;
import dan200.computercraft.shared.peripheral.speaker.UpgradeSpeakerPeripheral; import dan200.computercraft.shared.peripheral.speaker.UpgradeSpeakerPeripheral;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World; import net.minecraft.world.World;

View File

@ -9,11 +9,8 @@ package dan200.computercraft.shared.turtle.blocks;
import dan200.computercraft.api.turtle.TurtleSide; import dan200.computercraft.api.turtle.TurtleSide;
import dan200.computercraft.shared.ComputerCraftRegistry; import dan200.computercraft.shared.ComputerCraftRegistry;
import dan200.computercraft.shared.computer.blocks.BlockComputerBase; import dan200.computercraft.shared.computer.blocks.BlockComputerBase;
import dan200.computercraft.shared.computer.blocks.TileComputer;
import dan200.computercraft.shared.computer.blocks.TileComputerBase; import dan200.computercraft.shared.computer.blocks.TileComputerBase;
import dan200.computercraft.shared.computer.core.ComputerFamily; import dan200.computercraft.shared.computer.core.ComputerFamily;
import dan200.computercraft.shared.peripheral.diskdrive.BlockDiskDrive;
import dan200.computercraft.shared.peripheral.diskdrive.TileDiskDrive;
import dan200.computercraft.shared.turtle.core.TurtleBrain; import dan200.computercraft.shared.turtle.core.TurtleBrain;
import dan200.computercraft.shared.turtle.items.ITurtleItem; import dan200.computercraft.shared.turtle.items.ITurtleItem;
import dan200.computercraft.shared.turtle.items.TurtleItemFactory; import dan200.computercraft.shared.turtle.items.TurtleItemFactory;
@ -181,9 +178,10 @@ public class BlockTurtle extends BlockComputerBase<TileTurtle> implements Waterl
} }
} }
public BlockEntityType<? extends TileTurtle> getTypeByFamily(ComputerFamily family) public BlockEntityType<? extends TileTurtle> getTypeByFamily( ComputerFamily family )
{ {
if (family == ComputerFamily.ADVANCED) { if ( family == ComputerFamily.ADVANCED )
{
return ComputerCraftRegistry.ModTiles.TURTLE_ADVANCED; return ComputerCraftRegistry.ModTiles.TURTLE_ADVANCED;
} }
return ComputerCraftRegistry.ModTiles.TURTLE_NORMAL; return ComputerCraftRegistry.ModTiles.TURTLE_NORMAL;
@ -191,14 +189,15 @@ public class BlockTurtle extends BlockComputerBase<TileTurtle> implements Waterl
@Nullable @Nullable
@Override @Override
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) public BlockEntity createBlockEntity( BlockPos pos, BlockState state )
{ {
return new TileTurtle(getTypeByFamily(getFamily()), pos, state, getFamily()); return new TileTurtle( getTypeByFamily( getFamily() ), pos, state, getFamily() );
} }
@Nullable @Nullable
@Override @Override
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(World world, BlockState state, BlockEntityType<T> type){ public <T extends BlockEntity> BlockEntityTicker<T> getTicker( World world, BlockState state, BlockEntityType<T> type )
return world.isClient ? BlockTurtle.checkType( type, getTypeByFamily(getFamily()), ( world1, pos, state1, computer ) -> computer.clientTick() ) : super.getTicker(world, state, type); {
return world.isClient ? BlockTurtle.checkType( type, getTypeByFamily( getFamily() ), ( world1, pos, state1, computer ) -> computer.clientTick() ) : super.getTicker( world, state, type );
} }
} }

View File

@ -12,21 +12,17 @@ import dan200.computercraft.api.turtle.ITurtleAccess;
import dan200.computercraft.api.turtle.ITurtleUpgrade; import dan200.computercraft.api.turtle.ITurtleUpgrade;
import dan200.computercraft.api.turtle.TurtleSide; import dan200.computercraft.api.turtle.TurtleSide;
import dan200.computercraft.core.computer.ComputerSide; import dan200.computercraft.core.computer.ComputerSide;
import dan200.computercraft.fabric.mixin.MixinBlockEntity;
import dan200.computercraft.shared.ComputerCraftRegistry;
import dan200.computercraft.shared.common.TileGeneric; import dan200.computercraft.shared.common.TileGeneric;
import dan200.computercraft.shared.computer.blocks.ComputerProxy; import dan200.computercraft.shared.computer.blocks.ComputerProxy;
import dan200.computercraft.shared.computer.blocks.TileComputerBase; import dan200.computercraft.shared.computer.blocks.TileComputerBase;
import dan200.computercraft.shared.computer.core.ComputerFamily; import dan200.computercraft.shared.computer.core.ComputerFamily;
import dan200.computercraft.shared.computer.core.ComputerState; import dan200.computercraft.shared.computer.core.ComputerState;
import dan200.computercraft.shared.computer.core.ServerComputer; import dan200.computercraft.shared.computer.core.ServerComputer;
import dan200.computercraft.shared.peripheral.diskdrive.TileDiskDrive;
import dan200.computercraft.shared.turtle.apis.TurtleAPI; import dan200.computercraft.shared.turtle.apis.TurtleAPI;
import dan200.computercraft.shared.turtle.core.TurtleBrain; import dan200.computercraft.shared.turtle.core.TurtleBrain;
import dan200.computercraft.shared.turtle.inventory.ContainerTurtle; import dan200.computercraft.shared.turtle.inventory.ContainerTurtle;
import dan200.computercraft.shared.util.*; import dan200.computercraft.shared.util.*;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityType; import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory; import net.minecraft.entity.player.PlayerInventory;
@ -45,7 +41,6 @@ import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@ -67,7 +62,7 @@ public class TileTurtle extends TileComputerBase
public TileTurtle( BlockEntityType<? extends TileGeneric> type, BlockPos pos, BlockState state, ComputerFamily family ) public TileTurtle( BlockEntityType<? extends TileGeneric> type, BlockPos pos, BlockState state, ComputerFamily family )
{ {
super(type, family, pos, state ); super( type, family, pos, state );
} }
@Override @Override
@ -279,7 +274,7 @@ public class TileTurtle extends TileComputerBase
public void serverTick( ) public void serverTick( )
{ {
super.serverTick(); super.serverTick();
brain.update(); brain.update();
if( inventoryChanged ) if( inventoryChanged )
{ {
ServerComputer computer = getServerComputer(); ServerComputer computer = getServerComputer();
@ -303,7 +298,7 @@ public class TileTurtle extends TileComputerBase
@Override @Override
protected void updateBlockState( ComputerState newState ) protected void updateBlockState( ComputerState newState )
{} { }
@Nonnull @Nonnull
@Override @Override

View File

@ -193,14 +193,14 @@ public class TurtlePlaceCommand implements ITurtleCommand
if( direction.getAxis() != Direction.Axis.Y ) if( direction.getAxis() != Direction.Axis.Y )
{ {
turtlePlayer.setYaw(direction.asRotation()); turtlePlayer.setYaw( direction.asRotation() );
turtlePlayer.setPitch(0.0f); turtlePlayer.setPitch( 0.0f );
} }
else else
{ {
turtlePlayer.setYaw(turtle.getDirection() turtlePlayer.setYaw( turtle.getDirection()
.asRotation()); .asRotation() );
turtlePlayer.setPitch(DirectionUtil.toPitchAngle( direction )); turtlePlayer.setPitch( DirectionUtil.toPitchAngle( direction ) );
} }
turtlePlayer.setPos( posX, posY, posZ ); turtlePlayer.setPos( posX, posY, posZ );

View File

@ -26,7 +26,6 @@ import net.minecraft.item.ItemStack;
import net.minecraft.screen.NamedScreenHandlerFactory; import net.minecraft.screen.NamedScreenHandlerFactory;
import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld; import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
@ -84,9 +83,9 @@ public final class TurtlePlayer extends FakePlayer
BlockPos position = turtle.getPosition(); BlockPos position = turtle.getPosition();
setPos( position.getX() + 0.5, position.getY() + 0.5, position.getZ() + 0.5 ); setPos( position.getX() + 0.5, position.getY() + 0.5, position.getZ() + 0.5 );
setYaw(turtle.getDirection() setYaw( turtle.getDirection()
.asRotation()); .asRotation() );
setPitch(0.0f); setPitch( 0.0f );
getInventory().clear(); getInventory().clear();
} }
@ -211,7 +210,7 @@ public final class TurtlePlayer extends FakePlayer
public void closeHandledScreen() public void closeHandledScreen()
{ {
} }
@Override @Override
protected void onStatusEffectRemoved( @Nonnull StatusEffectInstance effect ) protected void onStatusEffectRemoved( @Nonnull StatusEffectInstance effect )
{ {

View File

@ -24,11 +24,6 @@ import net.minecraft.network.PacketByteBuf;
import net.minecraft.screen.ArrayPropertyDelegate; import net.minecraft.screen.ArrayPropertyDelegate;
import net.minecraft.screen.PropertyDelegate; import net.minecraft.screen.PropertyDelegate;
import net.minecraft.screen.slot.Slot; import net.minecraft.screen.slot.Slot;
import net.minecraft.screen.slot.SlotActionType;
import net.minecraft.util.crash.CrashException;
import net.minecraft.util.crash.CrashReport;
import net.minecraft.util.crash.CrashReportSection;
import net.minecraft.util.registry.Registry;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import java.util.function.Predicate; import java.util.function.Predicate;

View File

@ -12,7 +12,6 @@ import dan200.computercraft.api.turtle.ITurtleAccess;
import dan200.computercraft.api.turtle.TurtleSide; import dan200.computercraft.api.turtle.TurtleSide;
import dan200.computercraft.api.turtle.TurtleUpgradeType; import dan200.computercraft.api.turtle.TurtleUpgradeType;
import dan200.computercraft.shared.ComputerCraftRegistry; import dan200.computercraft.shared.ComputerCraftRegistry;
import dan200.computercraft.shared.peripheral.speaker.SpeakerPeripheral;
import dan200.computercraft.shared.peripheral.speaker.UpgradeSpeakerPeripheral; import dan200.computercraft.shared.peripheral.speaker.UpgradeSpeakerPeripheral;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;

View File

@ -242,10 +242,10 @@ public class FakeNetHandler extends ServerPlayNetworkHandler
{ {
} }
// @Override // @Override
// public void onConfirmScreenAction( ConfirmScreenActionC2SPacket packet ) // public void onConfirmScreenAction( ConfirmScreenActionC2SPacket packet )
// { // {
// } // }
@Override @Override
public void onSignUpdate( @Nonnull UpdateSignC2SPacket packet ) public void onSignUpdate( @Nonnull UpdateSignC2SPacket packet )

View File

@ -14,7 +14,7 @@ import javax.annotation.Nonnull;
public class InvisibleSlot extends Slot public class InvisibleSlot extends Slot
{ {
public InvisibleSlot(Inventory container, int slot ) public InvisibleSlot( Inventory container, int slot )
{ {
super( container, slot, 0, 0 ); super( container, slot, 0, 0 );
} }

View File

@ -65,8 +65,8 @@ public final class NBTUtil
int i = 0; int i = 0;
for( Map.Entry<?, ?> entry : m.entrySet() ) for( Map.Entry<?, ?> entry : m.entrySet() )
{ {
NbtElement key = toNBTTag( entry.getKey() ); NbtElement key = toNBTTag( entry.getKey() );
NbtElement value = toNBTTag( entry.getKey() ); NbtElement value = toNBTTag( entry.getKey() );
if( key != null && value != null ) if( key != null && value != null )
{ {
nbt.put( "k" + i, key ); nbt.put( "k" + i, key );
@ -155,7 +155,7 @@ public final class NBTUtil
return tag.asString(); return tag.asString();
case TAG_COMPOUND: // Compound case TAG_COMPOUND: // Compound
{ {
NbtCompound compound = (NbtCompound) tag; NbtCompound compound = (NbtCompound) tag;
Map<String, Object> map = new HashMap<>( compound.getSize() ); Map<String, Object> map = new HashMap<>( compound.getSize() );
for( String key : compound.getKeys() ) for( String key : compound.getKeys() )
{ {

View File

@ -1,12 +1,12 @@
/*
* This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2021. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com
*/
package dan200.computercraft.shared.util; package dan200.computercraft.shared.util;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
/**
* Equivalent to {@link Supplier}, except with nonnull contract.
*
* @see Supplier
*/
@FunctionalInterface @FunctionalInterface
public interface NonNullSupplier<T> public interface NonNullSupplier<T>
{ {