1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-08-28 08:12: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 'maven-publish'
id "checkstyle"
id "com.github.hierynomus.license" version "0.15.0"
id "com.github.hierynomus.license" version "0.16.1"
}
java {
@ -37,7 +37,7 @@ configurations {
}
dependencies {
checkstyle "com.puppycrawl.tools:checkstyle:8.25"
checkstyle 'com.puppycrawl.tools:checkstyle:8.45.1'
minecraft "com.mojang:minecraft:${mc_version}"
mappings "net.fabricmc:yarn:${mc_version}+build.${mappings_version}:v2"

View File

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

View File

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

View File

@ -21,10 +21,6 @@ import org.apache.commons.lang3.StringUtils;
import javax.annotation.Nullable;
@SuppressWarnings( {
"MethodCallSideOnly",
"LocalVariableDeclarationSideOnly"
} )
public class ClientTableFormatter implements TableFormatter
{
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;
import dan200.computercraft.ComputerCraft;
@ -100,8 +105,7 @@ public abstract class ComputerScreenBase<T extends ContainerComputerBase> extend
@Override
public final boolean mouseDragged( double x, double y, int button, double deltaX, double deltaY )
{
return (getFocused() != null && getFocused().mouseDragged( x, y, button, deltaX, deltaY ))
|| super.mouseDragged( x, y, button, deltaX, deltaY );
return getFocused() != null && getFocused().mouseDragged( x, y, button, deltaX, deltaY ) || super.mouseDragged( x, y, button, deltaX, deltaY );
}
@Override

View File

@ -5,13 +5,14 @@
*/
package dan200.computercraft.client.render;
import com.mojang.blaze3d.systems.RenderSystem;
import dan200.computercraft.ComputerCraft;
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.math.Matrix4f;
import org.lwjgl.opengl.GL11;
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());
render( IDENTITY, source.getBuffer(RenderLayer.getText(location)), x, y, z, light, width, height, false, 1, 1, 1 );
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 );
source.draw();
}
@ -144,22 +145,22 @@ public class ComputerBorderRenderer
builder.vertex( transform, x, y + height, z )
.color( r, g, b, 1.0f )
.texture( u * TEX_SCALE, (v + textureHeight) * TEX_SCALE )
.light(light)
.light( light )
.next();
builder.vertex( transform, x + width, y + height, z )
.color( r, g, b, 1.0f )
.texture( (u + textureWidth) * TEX_SCALE, (v + textureHeight) * TEX_SCALE )
.light(light)
.light( light )
.next();
builder.vertex( transform, x + width, y, z )
.color( r, g, b, 1.0f )
.texture( (u + textureWidth) * TEX_SCALE, v * TEX_SCALE )
.light(light)
.light( light )
.next();
builder.vertex( transform, x, y, z )
.color( r, g, b, 1.0f )
.texture( u * TEX_SCALE, v * TEX_SCALE )
.light(light)
.light( light )
.next();
}
}

View File

@ -144,6 +144,7 @@ public abstract class ItemMapLikeRenderer
* @param transform The matrix transformation stack
* @param render The buffer to render to
* @param stack The stack to render
* @param light TODO rebase
*/
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.item.ItemStack;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.Vec3f;
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_WIDTH;
@ -104,7 +103,7 @@ public final class ItemPocketRenderer extends ItemMapLikeRenderer
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();
MinecraftClient.getInstance()

View File

@ -12,7 +12,6 @@ import net.fabricmc.api.Environment;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.Entity;
@ -20,7 +19,6 @@ import net.minecraft.util.math.*;
import net.minecraft.world.World;
import java.util.EnumSet;
import static net.minecraft.util.math.Direction.*;
/**
@ -34,9 +32,7 @@ public final class MonitorHighlightRenderer
{
}
public static boolean drawHighlight(
MatrixStack matrixStack, VertexConsumer vertexConsumer, Entity entity, double d, double e, double f, BlockPos pos, BlockState blockState
)
public static boolean drawHighlight( MatrixStack matrixStack, VertexConsumer vertexConsumer, Entity entity, double d, double e, double f, BlockPos pos, BlockState blockState )
{
// Preserve normal behaviour when crouching.
if( entity.isInSneakingPose() )
@ -142,11 +138,11 @@ public final class MonitorHighlightRenderer
{
buffer.vertex( transform, x, y, z )
.color( 0, 0, 0, 0.4f )
.normal(normal, direction.getOffsetX(), direction.getOffsetY(), direction.getOffsetZ())
.normal( normal, direction.getOffsetX(), direction.getOffsetY(), direction.getOffsetZ() )
.next();
buffer.vertex( transform, x + direction.getOffsetX(), y + direction.getOffsetY(), z + direction.getOffsetZ() )
.color( 0, 0, 0, 0.4f )
.normal(normal, direction.getOffsetX(), direction.getOffsetY(), direction.getOffsetZ())
.normal( normal, direction.getOffsetX(), direction.getOffsetY(), direction.getOffsetZ() )
.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;
import dan200.computercraft.client.gui.FixedWidthFontRenderer;
@ -24,8 +29,9 @@ public class MonitorTextureBufferShader extends Shader
private final GlUniform width;
private final GlUniform height;
public MonitorTextureBufferShader(ResourceFactory factory, String name, VertexFormat format) throws IOException {
super(factory, name, format);
public MonitorTextureBufferShader( ResourceFactory factory, String name, VertexFormat format ) throws IOException
{
super( factory, name, format );
width = getUniformChecked( "Width" );
height = getUniformChecked( "Height" );

View File

@ -9,11 +9,9 @@ package dan200.computercraft.client.render;
import dan200.computercraft.client.gui.FixedWidthFontRenderer;
import dan200.computercraft.core.terminal.TextBuffer;
import dan200.computercraft.shared.util.Palette;
import net.minecraft.client.render.*;
import net.minecraft.client.render.VertexFormat.DrawMode;
import net.minecraft.util.Identifier;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.util.math.Matrix4f;
import org.lwjgl.opengl.GL11;
import static dan200.computercraft.client.gui.FixedWidthFontRenderer.FONT_HEIGHT;
import static dan200.computercraft.shared.media.items.ItemPrintout.LINES_PER_PAGE;
@ -95,7 +93,7 @@ public final class PrintoutRenderer
int leftPages = page;
int rightPages = pages - page - 1;
VertexConsumer buffer = renderer.getBuffer(RenderTypes.PRINTOUT_BACKGROUND);
VertexConsumer buffer = renderer.getBuffer( RenderTypes.PRINTOUT_BACKGROUND );
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;
import dan200.computercraft.client.gui.FixedWidthFontRenderer;
@ -7,7 +12,8 @@ import net.minecraft.util.Identifier;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class RenderTypes {
public class RenderTypes
{
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 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;
@ -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
RenderLayer.MultiPhaseParameters.builder()
.texture(TERM_FONT_TEXTURE ) // blur, minimap
.shader(new RenderPhase.Shader(RenderTypes::getMonitorTextureBufferShader))
.texture( TERM_FONT_TEXTURE ) // blur, minimap
.shader( new RenderPhase.Shader( RenderTypes::getMonitorTextureBufferShader ) )
.writeMaskState( RenderLayer.ALL_MASK )
.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
RenderLayer.MultiPhaseParameters.builder()
.texture( TERM_FONT_TEXTURE )
.shader(TERM_SHADER)
.shader( TERM_SHADER )
.writeMaskState( DEPTH_MASK )
.build( false ) );
@ -91,7 +97,7 @@ public class RenderTypes {
RenderLayer.MultiPhaseParameters.builder()
.texture( TERM_FONT_TEXTURE )
.shader( RenderPhase.TEXT_SHADER )
.lightmap(RenderPhase.ENABLE_LIGHTMAP)
.lightmap( RenderPhase.ENABLE_LIGHTMAP )
.build( false )
);

View File

@ -20,24 +20,15 @@ import dan200.computercraft.shared.util.Colour;
import dan200.computercraft.shared.util.DirectionUtil;
import net.minecraft.client.gl.VertexBuffer;
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.BlockEntityRendererFactory;
import net.minecraft.client.util.GlAllocationUtils;
import net.minecraft.util.math.AffineTransformation;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.math.Vec3f;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.Matrix4f;
import net.minecraft.util.math.*;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL13;
import org.lwjgl.opengl.GL20;
import org.lwjgl.opengl.GL31;
import javax.annotation.Nonnull;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import static dan200.computercraft.client.gui.FixedWidthFontRenderer.*;
@ -55,7 +46,7 @@ public class TileEntityMonitorRenderer implements BlockEntityRenderer<TileMonito
public TileEntityMonitorRenderer( BlockEntityRendererFactory.Context context )
{
// super( context );
// super( context );
}
@Override
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
// 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();
@ -147,7 +138,7 @@ public class TileEntityMonitorRenderer implements BlockEntityRenderer<TileMonito
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();
@ -237,7 +228,7 @@ public class TileEntityMonitorRenderer implements BlockEntityRenderer<TileMonito
renderer.getBuffer( RenderTypes.TERMINAL_WITHOUT_DEPTH );
RenderTypes.TERMINAL_WITHOUT_DEPTH.startDrawing();
vbo.setShader(matrix, RenderSystem.getProjectionMatrix(), RenderTypes.getTerminalShader());
vbo.setShader( matrix, RenderSystem.getProjectionMatrix(), RenderTypes.getTerminalShader() );
break;
}
}
@ -245,7 +236,7 @@ public class TileEntityMonitorRenderer implements BlockEntityRenderer<TileMonito
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.
builder.vertex( matrix, x, y, 0 ).texture(x, y).next();
builder.vertex( matrix, x, y, 0 ).texture( x, y ).next();
}
@Override

View File

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

View File

@ -6,12 +6,9 @@
package dan200.computercraft.client.render;
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.entity.EntityRenderDispatcher;
import net.minecraft.client.render.entity.EntityRenderer;
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.util.Identifier;

View File

@ -70,7 +70,7 @@ public class TurtleSmartItemModel implements BakedModel
{
@Nonnull
@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();
int colour = turtle.getColour( stack );
@ -149,13 +149,13 @@ public class TurtleSmartItemModel implements BakedModel
return familyModel.getParticleSprite();
}
// @Nonnull
// @Override
// @Deprecated
// public Sprite getSprite()
// {
// return familyModel.getSprite();
// }
// @Nonnull
// @Override
// @Deprecated
// public Sprite getSprite()
// {
// return familyModel.getSprite();
// }
@Nonnull
@Override

View File

@ -201,7 +201,7 @@ public final class NetworkUtils
{
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";
}

View File

@ -75,7 +75,7 @@ public final class AddressRule
if( this.port != null && this.port != port ) return false;
return predicate.matches( domain )
|| 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 )

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.WebSocketClientHandshakerFactory;
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 java.lang.ref.WeakReference;

View File

@ -309,9 +309,9 @@ public final class Environment implements IAPIEnvironment
{
int index = side.ordinal();
IPeripheral existing = peripherals[index];
if( (existing == null && peripheral != null) ||
(existing != null && peripheral == null) ||
(existing != null && !existing.equals( peripheral )) )
if( existing == null && peripheral != null ||
existing != null && peripheral == null ||
existing != null && !existing.equals( peripheral ) )
{
peripherals[index] = 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.core.apis.handles.ArrayByteChannel;
import dan200.computercraft.shared.util.IoUtil;
import net.minecraft.resource.*;
import net.minecraft.resource.ResourceReloader.Synchronizer;
import net.minecraft.resource.ReloadableResourceManager;
import net.minecraft.resource.Resource;
import net.minecraft.resource.ResourceManager;
import net.minecraft.resource.SynchronousResourceReloader;
import net.minecraft.util.Identifier;
import net.minecraft.util.InvalidIdentifierException;
import net.minecraft.util.profiler.Profiler;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@ -27,8 +28,6 @@ import java.io.InputStream;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit;
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;
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.RenderTypes;
import net.minecraft.client.gl.Program;
import net.minecraft.client.render.GameRenderer;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.Shader;
import net.minecraft.client.render.VertexFormats;
import net.minecraft.resource.ResourceManager;
import net.minecraft.util.Identifier;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
@ -22,20 +23,22 @@ import java.io.IOException;
import java.util.List;
import java.util.function.Consumer;
@Mixin(GameRenderer.class)
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)
private void loadShaders(ResourceManager manager, CallbackInfo info, List<Program> list, List<Pair<Shader, Consumer<Shader>>> list2) throws IOException {
list2.add(Pair.of(new Shader(
@Mixin( GameRenderer.class )
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 )
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,
"terminal",
RenderTypes.TERMINAL_WITHOUT_DEPTH.getVertexFormat()
), (shader) -> RenderTypes.terminalShader = shader));
list2.add(Pair.of(new MonitorTextureBufferShader(
), shader -> RenderTypes.terminalShader = shader ) );
list2.add( Pair.of( new MonitorTextureBufferShader(
manager,
"monitor_tbo",
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;
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.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Slice;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin( ItemFrameEntityRenderer.class )

View File

@ -7,7 +7,6 @@ package dan200.computercraft.fabric.mixin;
import dan200.computercraft.shared.common.TileGeneric;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@ -32,7 +31,7 @@ public class MixinWorld
@Inject( method = "addBlockEntity", at = @At( "HEAD" ) )
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 );
}
@ -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 )
{
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,
"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,
"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,
"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,
"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,
"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,
"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,
"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",
(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",
(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",
(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,
"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",
(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,
"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,
"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 )
{
BlockEntityType<T> blockEntityType = FabricBlockEntityTypeBuilder.create(factory::apply, block).build();
BlockEntityType<T> blockEntityType = FabricBlockEntityTypeBuilder.create( factory::apply, block ).build();
return Registry.register( BLOCK_ENTITY_TYPE,
new Identifier( MOD_ID, id ),
blockEntityType
@ -257,7 +257,7 @@ public final class ComputerCraftRegistry
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_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 );

View File

@ -25,7 +25,7 @@ public final class TurtlePermissions
public static boolean isBlockEnterable( World world, BlockPos pos, PlayerEntity player )
{
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

View File

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

View File

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

View File

@ -20,7 +20,7 @@ public interface IColouredItem
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;
}
@ -35,7 +35,7 @@ public interface IColouredItem
{
if( colour == -1 )
{
NbtCompound tag = stack.getNbt();
NbtCompound tag = stack.getNbt();
if( tag != null )
{
tag.remove( NBT_COLOUR );

View File

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

View File

@ -7,15 +7,12 @@
package dan200.computercraft.shared.computer.blocks;
import dan200.computercraft.shared.ComputerCraftRegistry;
import dan200.computercraft.shared.common.TileGeneric;
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.items.ComputerItemFactory;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityTicker;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.item.ItemStack;
@ -25,7 +22,6 @@ import net.minecraft.state.property.EnumProperty;
import net.minecraft.state.property.Properties;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.World;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@ -64,9 +60,10 @@ public class BlockComputer extends BlockComputerBase<TileComputer>
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 ADVANCED -> ComputerCraftRegistry.ModTiles.COMPUTER_ADVANCED;
default -> ComputerCraftRegistry.ModTiles.COMPUTER_NORMAL;
@ -75,8 +72,8 @@ public class BlockComputer extends BlockComputerBase<TileComputer>
@Nullable
@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.core.computer.ComputerSide;
import dan200.computercraft.shared.ComputerCraftRegistry;
import dan200.computercraft.shared.common.BlockGeneric;
import dan200.computercraft.shared.common.IBundledRedstoneBlock;
import dan200.computercraft.shared.computer.core.ComputerFamily;
import dan200.computercraft.shared.computer.core.ServerComputer;
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.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityTicker;
@ -218,9 +215,11 @@ public abstract class BlockComputerBase<T extends TileComputerBase> extends Bloc
@Nullable
@Override
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) {
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 )
{
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( startOn || (fresh && on) )
if( startOn || fresh && on )
{
computer.turnOn();
startOn = false;

View File

@ -45,7 +45,7 @@ public interface IContainerComputer
* @param uploadId The unique ID of this 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.
@ -61,7 +61,7 @@ public interface IContainerComputer
* @param uploader The player uploading files.
* @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.

View File

@ -22,7 +22,7 @@ import java.util.function.Predicate;
*/
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 );
addSlots( player );

View File

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

View File

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

View File

@ -18,7 +18,7 @@ public interface IComputerItem
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;
}

View File

@ -85,7 +85,7 @@ public class ItemDisk extends Item implements IMedia, IColouredItem
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;
}

View File

@ -60,7 +60,7 @@ public class ItemPrintout extends Item
}
if( text != null )
{
NbtCompound tag = stack.getOrCreateNbt();
NbtCompound tag = stack.getOrCreateNbt();
tag.putInt( NBT_PAGES, text.length / LINES_PER_PAGE );
for( int i = 0; i < text.length; i++ )
{
@ -72,7 +72,7 @@ public class ItemPrintout extends Item
}
if( colours != null )
{
NbtCompound tag = stack.getOrCreateNbt();
NbtCompound tag = stack.getOrCreateNbt();
for( int i = 0; i < colours.length; i++ )
{
if( colours[i] != null )
@ -105,7 +105,7 @@ public class ItemPrintout extends Item
private static String[] getLines( @Nonnull ItemStack stack, String prefix )
{
NbtCompound nbt = stack.getNbt();
NbtCompound nbt = stack.getNbt();
int numLines = getPageCount( stack ) * LINES_PER_PAGE;
String[] lines = new String[numLines];
for( int i = 0; i < lines.length; i++ )
@ -117,7 +117,7 @@ public class ItemPrintout extends Item
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;
}
@ -152,7 +152,7 @@ public class ItemPrintout extends Item
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;
}

View File

@ -62,7 +62,7 @@ public class ItemTreasureDisk extends Item implements IMedia
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();
}
@ -84,7 +84,7 @@ public class ItemTreasureDisk extends Item implements IMedia
@Nonnull
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";
}
@ -128,7 +128,7 @@ public class ItemTreasureDisk extends Item implements IMedia
@Nonnull
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";
}
}

View File

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

View File

@ -30,7 +30,7 @@ public class ChatTableClientMessage implements NetworkMessage
this.table = table;
}
public ChatTableClientMessage(@Nonnull PacketByteBuf buf)
public ChatTableClientMessage( @Nonnull PacketByteBuf buf )
{
int id = 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.minecraft.network.PacketByteBuf;
import net.minecraft.sound.SoundEvent;
import net.minecraft.sound.SoundEvents;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.Vec3d;
@ -68,7 +67,7 @@ public class SpeakerPlayClientMessage implements NetworkMessage
@Environment( EnvType.CLIENT )
public void handle( PacketContext context )
{
SoundEvent sound = new SoundEvent(this.sound);
SoundEvent sound = new SoundEvent( this.sound );
SoundManager.playSound( source, pos, sound, volume, pitch );
}
}

View File

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

View File

@ -6,7 +6,6 @@
package dan200.computercraft.shared.network.container;
import dan200.computercraft.shared.computer.inventory.ContainerComputerBase;
import net.fabricmc.fabric.api.screenhandler.v1.ScreenHandlerRegistry;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
@ -24,7 +23,7 @@ import java.util.function.Function;
*/
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 )
{
return ScreenHandlerRegistry.registerExtended( identifier,
@ -32,7 +31,7 @@ public interface ContainerData
playerInventory,
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 )
{
return ScreenHandlerRegistry.registerExtended( identifier,
@ -45,7 +44,7 @@ public interface ContainerData
default void open( PlayerEntity player, NamedScreenHandlerFactory owner )
{
if (player.world.isClient) return;
if ( player.world.isClient ) return;
player.openHandledScreen( owner );
}

View File

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

View File

@ -37,7 +37,7 @@ public class ComputerActionServerMessage extends ComputerServerMessage
}
@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 )
{

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.ServerComputer;
import net.fabricmc.fabric.api.network.PacketContext;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.server.network.ServerPlayerEntity;
@ -38,7 +37,7 @@ public class ContinueUploadMessage extends ComputerServerMessage
}
@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();
if( player != null ) container.confirmUpload( player, overwrite );

View File

@ -46,7 +46,7 @@ public class KeyEventServerMessage extends ComputerServerMessage
}
@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();
if( type == TYPE_UP )

View File

@ -55,7 +55,7 @@ public class MouseEventServerMessage extends ComputerServerMessage
}
@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();
switch( type )

View File

@ -52,7 +52,7 @@ public class QueueEventServerMessage extends ComputerServerMessage
}
@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 );
}

View File

@ -13,7 +13,6 @@ import dan200.computercraft.shared.computer.upload.FileUpload;
import dan200.computercraft.shared.network.NetworkHandler;
import io.netty.handler.codec.DecoderException;
import net.fabricmc.fabric.api.network.PacketContext;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.server.network.ServerPlayerEntity;
@ -174,7 +173,7 @@ public class UploadFileMessage extends ComputerServerMessage
}
@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();
if( player != null )

View File

@ -8,9 +8,6 @@ package dan200.computercraft.shared.peripheral.diskdrive;
import dan200.computercraft.shared.ComputerCraftRegistry;
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.BlockState;
import net.minecraft.block.entity.BlockEntity;
@ -57,8 +54,9 @@ public class BlockDiskDrive extends BlockGeneric
@Nullable
@Override
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 );
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 );
}
@Override
@ -102,8 +100,8 @@ public class BlockDiskDrive extends BlockGeneric
@Nullable
@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;
if( nbt.contains( NBT_ITEM ) )
{
NbtCompound item = nbt.getCompound( NBT_ITEM );
NbtCompound item = nbt.getCompound( NBT_ITEM );
diskStack = ItemStack.fromNbt( item );
diskMount = null;
}
@ -132,7 +132,7 @@ public final class TileDiskDrive extends TileGeneric implements DefaultInventory
if( !diskStack.isEmpty() )
{
NbtCompound item = new NbtCompound();
NbtCompound item = new NbtCompound();
diskStack.writeNbt( item );
nbt.put( NBT_ITEM, item );
}
@ -149,13 +149,13 @@ public final class TileDiskDrive extends TileGeneric implements DefaultInventory
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
if( tileDiskDrive.ejectQueued )
{
tileDiskDrive.ejectContents( false );
tileDiskDrive.ejectQueued = false;
tileDiskDrive.ejectContents( false );
tileDiskDrive.ejectQueued = false;
}
// Music
@ -163,24 +163,24 @@ public final class TileDiskDrive extends TileGeneric implements DefaultInventory
{
if( !world.isClient && tileDiskDrive.recordPlaying != tileDiskDrive.recordQueued || tileDiskDrive.restartRecord )
{
tileDiskDrive.restartRecord = false;
tileDiskDrive.restartRecord = false;
if( tileDiskDrive.recordQueued )
{
IMedia contents = tileDiskDrive.getDiskMedia();
SoundEvent record = contents != null ? contents.getAudio( tileDiskDrive.diskStack ) : null;
if( record != null )
{
tileDiskDrive.recordPlaying = true;
tileDiskDrive.playRecord();
tileDiskDrive.recordPlaying = true;
tileDiskDrive.playRecord();
}
else
{
tileDiskDrive.recordQueued = false;
tileDiskDrive.recordQueued = false;
}
}
else
{
tileDiskDrive.stopRecord();
tileDiskDrive.stopRecord();
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
// 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()
.filter( id -> Objects.requireNonNull( itemTags.getTag( id ) ).contains( stack.getItem() ) )
.collect( Collectors.toList() )
@ -81,7 +81,7 @@ public class ItemData
NbtCompound tag = stack.getNbt();
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 ) )
{
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.shared.ComputerCraftRegistry;
import dan200.computercraft.shared.common.BlockGeneric;
import dan200.computercraft.shared.peripheral.printer.TilePrinter;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.ShapeContext;
@ -275,8 +274,8 @@ public class BlockCable extends BlockGeneric implements Waterloggable
@Nullable
@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.common.BlockGeneric;
import dan200.computercraft.shared.peripheral.speaker.TileSpeaker;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
@ -40,8 +39,8 @@ public class BlockWiredModemFull extends BlockGeneric
@Nullable
@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
public NbtCompound writeNbt( NbtCompound nbt )
{
super.writeNbt( nbt );
super.writeNbt( nbt );
nbt.putBoolean( NBT_PERIPHERAL_ENABLED, peripheralAccessAllowed );
peripheral.write( nbt, "" );
return nbt;
@ -409,10 +409,10 @@ public class TileCable extends TileGeneric implements IPeripheralTile
}
@Override
public void setCachedState(BlockState state)
public void setCachedState( BlockState state )
{
super.setCachedState(state);
if(state != null) return;
super.setCachedState( state );
if( state != null ) return;
hasModemDirection = false;
if( !world.isClient )
{

View File

@ -329,7 +329,7 @@ public class TileWiredModemFull extends TileGeneric implements IPeripheralTile
@Override
public NbtCompound writeNbt( NbtCompound nbt )
{
super.writeNbt( nbt );
super.writeNbt( nbt );
nbt.putBoolean( NBT_PERIPHERAL_ENABLED, peripheralAccessAllowed );
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.common.BlockGeneric;
import dan200.computercraft.shared.computer.blocks.TileComputer;
import dan200.computercraft.shared.computer.core.ComputerFamily;
import dan200.computercraft.shared.peripheral.modem.ModemShapes;
import dan200.computercraft.shared.peripheral.modem.wired.TileWiredModemFull;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.ShapeContext;
@ -43,7 +41,7 @@ public class BlockWirelessModem extends BlockGeneric implements Waterloggable
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 );
this.family = family;
@ -104,9 +102,10 @@ public class BlockWirelessModem extends BlockGeneric implements Waterloggable
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;
default -> ComputerCraftRegistry.ModTiles.WIRELESS_MODEM_NORMAL;
};
@ -114,8 +113,8 @@ public class BlockWirelessModem extends BlockGeneric implements Waterloggable
@Nullable
@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.IPeripheralTile;
import dan200.computercraft.shared.ComputerCraftRegistry.ModTiles;
import dan200.computercraft.shared.common.TileGeneric;
import dan200.computercraft.shared.peripheral.modem.ModemPeripheral;
import dan200.computercraft.shared.peripheral.modem.ModemState;
@ -45,10 +44,10 @@ public class TileWirelessModem extends TileGeneric implements IPeripheralTile
}
@Override
public void setCachedState(BlockState state)
public void setCachedState( BlockState state )
{
super.setCachedState(state);
if(state != null) return;
super.setCachedState( state );
if( state != null ) return;
hasModemDirection = false;
world.getBlockTickScheduler()
.schedule( getPos(),

View File

@ -9,7 +9,6 @@ package dan200.computercraft.shared.peripheral.monitor;
import dan200.computercraft.api.turtle.FakePlayer;
import dan200.computercraft.shared.ComputerCraftRegistry;
import dan200.computercraft.shared.common.BlockGeneric;
import dan200.computercraft.shared.computer.blocks.TileComputer;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
@ -104,8 +103,8 @@ public class BlockMonitor extends BlockGeneric
@Nullable
@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.systems.RenderSystem;
import dan200.computercraft.client.gui.FixedWidthFontRenderer;
import dan200.computercraft.shared.common.ClientTerminal;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;

View File

@ -259,7 +259,7 @@ public class TileMonitor extends TileGeneric implements IPeripheralTile
{
if( pos.equals( getPos() ) )
{
return MonitorState.present(this);
return MonitorState.present( this );
}
World world = getWorld();
@ -309,7 +309,7 @@ public class TileMonitor extends TileGeneric implements IPeripheralTile
@Override
public NbtCompound writeNbt( NbtCompound tag )
{
super.writeNbt( tag );
super.writeNbt( tag );
tag.putInt( NBT_X, xIndex );
tag.putInt( NBT_Y, yIndex );
tag.putInt( NBT_WIDTH, width );
@ -317,11 +317,11 @@ public class TileMonitor extends TileGeneric implements IPeripheralTile
return tag;
}
// @Override //TODO: make BlockEntityRenderer work with this, i guess.
// public double getRenderDistance()
// {
// return ComputerCraft.monitorDistanceSq;
// }
// @Override //TODO: make BlockEntityRenderer work with this, i guess.
// public double getRenderDistance()
// {
// return ComputerCraft.monitorDistanceSq;
// }
// 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.common.BlockGeneric;
import dan200.computercraft.shared.computer.blocks.TileComputer;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
@ -92,8 +91,8 @@ public class BlockPrinter extends BlockGeneric
@Nullable
@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.common.BlockGeneric;
import dan200.computercraft.shared.turtle.blocks.TileTurtle;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
@ -52,15 +51,16 @@ public class BlockSpeaker extends BlockGeneric
@Nullable
@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
@Override
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 );
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 );
}
}

View File

@ -147,7 +147,9 @@ public abstract class SpeakerPeripheral implements IPeripheral
null, pos.x, pos.y, pos.z, range, world.getRegistryKey(),
new PlaySoundIdS2CPacket( name, SoundCategory.RECORDS, pos, actualVolume, pitch )
);
} else {
}
else
{
NetworkHandler.sendToAllAround(
new SpeakerPlayClientMessage( getSource(), pos, name, actualVolume, pitch ),
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.IPeripheralTile;
import dan200.computercraft.shared.common.TileGeneric;
import dan200.computercraft.shared.computer.blocks.TileComputerBase;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.util.math.BlockPos;

View File

@ -87,14 +87,14 @@ public class PocketServerComputer extends ServerComputer implements IPocketAcces
@Override
public int getLight()
{
NbtCompound tag = getUserData();
NbtCompound tag = getUserData();
return tag.contains( NBT_LIGHT, NBTUtil.TAG_ANY_NUMERIC ) ? tag.getInt( NBT_LIGHT ) : -1;
}
@Override
public void setLight( int colour )
{
NbtCompound tag = getUserData();
NbtCompound tag = getUserData();
if( colour >= 0 && colour <= 0xFFFFFF )
{
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;
import dan200.computercraft.shared.ComputerCraftRegistry;
import dan200.computercraft.shared.computer.core.ComputerFamily;
import dan200.computercraft.shared.computer.core.ServerComputer;
import dan200.computercraft.shared.computer.inventory.ComputerMenuWithoutInventory;
import dan200.computercraft.shared.pocket.items.ItemPocketComputer;
@ -32,7 +31,7 @@ public class PocketComputerMenuProvider implements NamedScreenHandlerFactory, Ex
private final Hand hand;
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;
name = stack.getName();
@ -51,7 +50,7 @@ public class PocketComputerMenuProvider implements NamedScreenHandlerFactory, Ex
@Nullable
@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(
isTypingOnly ? ComputerCraftRegistry.ModContainers.POCKET_COMPUTER_NO_TERM : ComputerCraftRegistry.ModContainers.POCKET_COMPUTER, id, inventory,
@ -64,8 +63,9 @@ public class PocketComputerMenuProvider implements NamedScreenHandlerFactory, Ex
}
@Override
public void writeScreenOpeningData(ServerPlayerEntity player, PacketByteBuf packetByteBuf) {
packetByteBuf.writeInt(computer.getInstanceID());
packetByteBuf.writeEnumConstant(computer.getFamily());
public void writeScreenOpeningData( ServerPlayerEntity player, PacketByteBuf packetByteBuf )
{
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 );
if( computer != null && computer.isOn() )
{
NbtCompound computerNBT = computer.getUserData();
NbtCompound computerNBT = computer.getUserData();
if( computerNBT != null && computerNBT.contains( 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 )
{
NbtCompound compound = stack.getOrCreateNbt();
NbtCompound compound = stack.getOrCreateNbt();
if( upgrade == null )
{
@ -164,7 +164,6 @@ public class ItemPocketComputer extends Item implements IComputerItem, IMedia, I
if( !stop && computer != null )
{
// computer.sendTerminalState( player );
boolean isTypingOnly = hand == Hand.OFF_HAND;
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 )
{
NbtCompound compound = stack.getNbt();
NbtCompound compound = stack.getNbt();
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 )
{
NbtCompound nbt = stack.getNbt();
NbtCompound nbt = stack.getNbt();
return nbt != null && nbt.contains( NBT_INSTANCE ) ? nbt.getInt( NBT_INSTANCE ) : -1;
}
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;
}

View File

@ -7,7 +7,6 @@
package dan200.computercraft.shared.pocket.peripherals;
import dan200.computercraft.api.peripheral.IPeripheral;
import dan200.computercraft.shared.peripheral.speaker.SpeakerPeripheral;
import dan200.computercraft.shared.peripheral.speaker.UpgradeSpeakerPeripheral;
import net.minecraft.util.math.Vec3d;
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.shared.ComputerCraftRegistry;
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.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.items.ITurtleItem;
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_NORMAL;
@ -191,14 +189,15 @@ public class BlockTurtle extends BlockComputerBase<TileTurtle> implements Waterl
@Nullable
@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
@Override
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);
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 );
}
}

View File

@ -12,21 +12,17 @@ import dan200.computercraft.api.turtle.ITurtleAccess;
import dan200.computercraft.api.turtle.ITurtleUpgrade;
import dan200.computercraft.api.turtle.TurtleSide;
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.computer.blocks.ComputerProxy;
import dan200.computercraft.shared.computer.blocks.TileComputerBase;
import dan200.computercraft.shared.computer.core.ComputerFamily;
import dan200.computercraft.shared.computer.core.ComputerState;
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.core.TurtleBrain;
import dan200.computercraft.shared.turtle.inventory.ContainerTurtle;
import dan200.computercraft.shared.util.*;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.entity.player.PlayerEntity;
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.Direction;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import javax.annotation.Nonnull;
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 )
{
super(type, family, pos, state );
super( type, family, pos, state );
}
@Override
@ -279,7 +274,7 @@ public class TileTurtle extends TileComputerBase
public void serverTick( )
{
super.serverTick();
brain.update();
brain.update();
if( inventoryChanged )
{
ServerComputer computer = getServerComputer();
@ -303,7 +298,7 @@ public class TileTurtle extends TileComputerBase
@Override
protected void updateBlockState( ComputerState newState )
{}
{ }
@Nonnull
@Override

View File

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

View File

@ -26,7 +26,6 @@ import net.minecraft.item.ItemStack;
import net.minecraft.screen.NamedScreenHandlerFactory;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.Vec3d;
@ -84,9 +83,9 @@ public final class TurtlePlayer extends FakePlayer
BlockPos position = turtle.getPosition();
setPos( position.getX() + 0.5, position.getY() + 0.5, position.getZ() + 0.5 );
setYaw(turtle.getDirection()
.asRotation());
setPitch(0.0f);
setYaw( turtle.getDirection()
.asRotation() );
setPitch( 0.0f );
getInventory().clear();
}
@ -211,7 +210,7 @@ public final class TurtlePlayer extends FakePlayer
public void closeHandledScreen()
{
}
@Override
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.PropertyDelegate;
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 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.TurtleUpgradeType;
import dan200.computercraft.shared.ComputerCraftRegistry;
import dan200.computercraft.shared.peripheral.speaker.SpeakerPeripheral;
import dan200.computercraft.shared.peripheral.speaker.UpgradeSpeakerPeripheral;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;

View File

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

View File

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

View File

@ -65,8 +65,8 @@ public final class NBTUtil
int i = 0;
for( Map.Entry<?, ?> entry : m.entrySet() )
{
NbtElement key = toNBTTag( entry.getKey() );
NbtElement value = toNBTTag( entry.getKey() );
NbtElement key = toNBTTag( entry.getKey() );
NbtElement value = toNBTTag( entry.getKey() );
if( key != null && value != null )
{
nbt.put( "k" + i, key );
@ -155,7 +155,7 @@ public final class NBTUtil
return tag.asString();
case TAG_COMPOUND: // Compound
{
NbtCompound compound = (NbtCompound) tag;
NbtCompound compound = (NbtCompound) tag;
Map<String, Object> map = new HashMap<>( compound.getSize() );
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;
import javax.annotation.Nonnull;
/**
* Equivalent to {@link Supplier}, except with nonnull contract.
*
* @see Supplier
*/
@FunctionalInterface
public interface NonNullSupplier<T>
{