diff --git a/.github/workflows/main-ci.yml b/.github/workflows/main-ci.yml
index 3c5793c2d..b69180785 100644
--- a/.github/workflows/main-ci.yml
+++ b/.github/workflows/main-ci.yml
@@ -12,10 +12,10 @@ jobs:
- name: Checkout submodules
run: git submodule update --init --recursive
- - name: Set up Java 8
+ - name: Set up Java 16
uses: actions/setup-java@v1
with:
- java-version: 8
+ java-version: 16
- name: Cache gradle dependencies
uses: actions/cache@v2
diff --git a/README.md b/README.md
index 51fab9f4c..06963e758 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
[](https://github.com/Merith-TK/cc-restitched/actions "Current build status")
-[](https://www.curseforge.com/minecraft/mc-mods/cc-restitched-updated "Download CC: Restitched on CurseForge")
+[](https://www.curseforge.com/minecraft/mc-mods/cc-restitched "Download CC: Restitched on CurseForge")
[](https://gitpod.io/#https://github.com/Merith-TK/cc-restitched)
# CC: R Version VS CC: T Version
diff --git a/build.gradle b/build.gradle
index 4b9b75b38..bc56ba813 100644
--- a/build.gradle
+++ b/build.gradle
@@ -7,7 +7,7 @@ plugins {
java {
toolchain {
- languageVersion = JavaLanguageVersion.of(8)
+ languageVersion = JavaLanguageVersion.of(16)
vendor = JvmVendorSpec.ADOPTOPENJDK
}
}
@@ -55,8 +55,8 @@ dependencies {
include 'com.electronwill.night-config:toml:3.6.3'
include "me.shedaniel.cloth:cloth-config-fabric:${cloth_config_version}"
- modRuntime "me.shedaniel:RoughlyEnoughItems-api:5.12.248"
- modRuntime "me.shedaniel:RoughlyEnoughItems:5.12.248"
+ modRuntime "me.shedaniel:RoughlyEnoughItems-api:6.0.254-alpha"
+ modRuntime "me.shedaniel:RoughlyEnoughItems:6.0.254-alpha"
}
processResources {
diff --git a/gradle.properties b/gradle.properties
index ec627620b..4032101a1 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -5,13 +5,13 @@ org.gradle.jvmargs=-Xmx1G
mod_version=1.96.1-rc1
# Minecraft properties
-mc_version=1.16.5
+mc_version=1.17
mappings_version=9
# Dependencies
-cloth_config_version=4.11.26
-fabric_loader_version=0.11.3
-fabric_api_version=0.32.0+1.16
+cloth_config_version=5.0.34
+fabric_loader_version=0.11.6
+fabric_api_version=0.36.0+1.16
jankson_version=1.2.0
-modmenu_version=1.16.9
-cloth_api_version=1.4.5
+modmenu_version=2.0.2
+cloth_api_version=2.0.54
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 7665b0fa9..ffed3a254 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/gradlew.bat b/gradlew.bat
index 107acd32c..ac1b06f93 100644
--- a/gradlew.bat
+++ b/gradlew.bat
@@ -1,89 +1,89 @@
-@rem
-@rem Copyright 2015 the original author or authors.
-@rem
-@rem Licensed under the Apache License, Version 2.0 (the "License");
-@rem you may not use this file except in compliance with the License.
-@rem You may obtain a copy of the License at
-@rem
-@rem https://www.apache.org/licenses/LICENSE-2.0
-@rem
-@rem Unless required by applicable law or agreed to in writing, software
-@rem distributed under the License is distributed on an "AS IS" BASIS,
-@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-@rem See the License for the specific language governing permissions and
-@rem limitations under the License.
-@rem
-
-@if "%DEBUG%" == "" @echo off
-@rem ##########################################################################
-@rem
-@rem Gradle startup script for Windows
-@rem
-@rem ##########################################################################
-
-@rem Set local scope for the variables with windows NT shell
-if "%OS%"=="Windows_NT" setlocal
-
-set DIRNAME=%~dp0
-if "%DIRNAME%" == "" set DIRNAME=.
-set APP_BASE_NAME=%~n0
-set APP_HOME=%DIRNAME%
-
-@rem Resolve any "." and ".." in APP_HOME to make it shorter.
-for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
-
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
-
-@rem Find java.exe
-if defined JAVA_HOME goto findJavaFromJavaHome
-
-set JAVA_EXE=java.exe
-%JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto execute
-
-echo.
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:findJavaFromJavaHome
-set JAVA_HOME=%JAVA_HOME:"=%
-set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-
-if exist "%JAVA_EXE%" goto execute
-
-echo.
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:execute
-@rem Setup the command line
-
-set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
-
-
-@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
-
-:end
-@rem End local scope for the variables with windows NT shell
-if "%ERRORLEVEL%"=="0" goto mainEnd
-
-:fail
-rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
-rem the _cmd.exe /c_ return code!
-if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
-exit /b 1
-
-:mainEnd
-if "%OS%"=="Windows_NT" endlocal
-
-:omega
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto execute
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto execute
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/src/main/java/dan200/computercraft/api/IUpgradeBase.java b/src/main/java/dan200/computercraft/api/IUpgradeBase.java
index 06675b7ed..9f19eece5 100644
--- a/src/main/java/dan200/computercraft/api/IUpgradeBase.java
+++ b/src/main/java/dan200/computercraft/api/IUpgradeBase.java
@@ -8,7 +8,7 @@ package dan200.computercraft.api;
import dan200.computercraft.api.pocket.IPocketUpgrade;
import dan200.computercraft.api.turtle.ITurtleUpgrade;
import net.minecraft.item.ItemStack;
-import net.minecraft.nbt.CompoundTag;
+import net.minecraft.nbt.NbtCompound;
import net.minecraft.util.Identifier;
import javax.annotation.Nonnull;
@@ -76,8 +76,8 @@ public interface IUpgradeBase
// A more expanded form of ItemStack.areShareTagsEqual, but allowing an empty tag to be equal to a
// null one.
- CompoundTag shareTag = stack.getTag();
- CompoundTag craftingShareTag = crafting.getTag();
+ NbtCompound shareTag = stack.getTag();
+ NbtCompound craftingShareTag = crafting.getTag();
if( shareTag == craftingShareTag ) return true;
if( shareTag == null ) return craftingShareTag.isEmpty();
if( craftingShareTag == null ) return shareTag.isEmpty();
diff --git a/src/main/java/dan200/computercraft/api/client/TransformedModel.java b/src/main/java/dan200/computercraft/api/client/TransformedModel.java
index 1d1cc5828..9edbbcdc5 100644
--- a/src/main/java/dan200/computercraft/api/client/TransformedModel.java
+++ b/src/main/java/dan200/computercraft/api/client/TransformedModel.java
@@ -13,7 +13,7 @@ import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.render.model.BakedModelManager;
import net.minecraft.client.util.ModelIdentifier;
-import net.minecraft.client.util.math.AffineTransformation;
+import net.minecraft.util.math.AffineTransformation;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.item.ItemStack;
diff --git a/src/main/java/dan200/computercraft/api/pocket/IPocketAccess.java b/src/main/java/dan200/computercraft/api/pocket/IPocketAccess.java
index fe82eb5ab..0638f6c5c 100644
--- a/src/main/java/dan200/computercraft/api/pocket/IPocketAccess.java
+++ b/src/main/java/dan200/computercraft/api/pocket/IPocketAccess.java
@@ -8,7 +8,7 @@ package dan200.computercraft.api.pocket;
import dan200.computercraft.api.peripheral.IPeripheral;
import net.minecraft.entity.Entity;
-import net.minecraft.nbt.CompoundTag;
+import net.minecraft.nbt.NbtCompound;
import net.minecraft.util.Identifier;
import javax.annotation.Nonnull;
@@ -73,7 +73,7 @@ public interface IPocketAccess
* @see #updateUpgradeNBTData()
*/
@Nonnull
- CompoundTag getUpgradeNBTData();
+ NbtCompound getUpgradeNBTData();
/**
* Mark the upgrade-specific NBT as dirty.
diff --git a/src/main/java/dan200/computercraft/api/turtle/FakePlayer.java b/src/main/java/dan200/computercraft/api/turtle/FakePlayer.java
index a67f10e34..3472e8adb 100644
--- a/src/main/java/dan200/computercraft/api/turtle/FakePlayer.java
+++ b/src/main/java/dan200/computercraft/api/turtle/FakePlayer.java
@@ -53,7 +53,7 @@ public class FakePlayer extends ServerPlayerEntity
{
public FakePlayer( ServerWorld world, GameProfile gameProfile )
{
- super( world.getServer(), world, gameProfile, new ServerPlayerInteractionManager( world ) );
+ super( world.getServer(), world, gameProfile );
networkHandler = new FakeNetHandler( this );
}
@@ -128,7 +128,7 @@ public class FakePlayer extends ServerPlayerEntity
}
@Override
- public void openEditBookScreen( ItemStack stack, Hand hand )
+ public void useBook( ItemStack stack, Hand hand )
{
}
@@ -137,30 +137,30 @@ public class FakePlayer extends ServerPlayerEntity
{
}
- @Override
- public void onSlotUpdate( ScreenHandler container, int slot, ItemStack stack )
- {
- }
-
- @Override
- public void onHandlerRegistered( ScreenHandler container, DefaultedList 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 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> recipes )
@@ -191,17 +191,17 @@ public class FakePlayer extends ServerPlayerEntity
}
@Override
- public void method_14222( EntityAnchorArgumentType.EntityAnchor self, Entity entity, EntityAnchorArgumentType.EntityAnchor target )
+ public void lookAtEntity( EntityAnchorArgumentType.EntityAnchor self, Entity entity, EntityAnchorArgumentType.EntityAnchor target )
{
}
@Override
- protected void onStatusEffectApplied( StatusEffectInstance statusEffectInstance )
+ protected void onStatusEffectApplied( StatusEffectInstance statusEffectInstance, @Nullable Entity source )
{
}
@Override
- protected void onStatusEffectUpgraded( StatusEffectInstance statusEffectInstance, boolean particles )
+ protected void onStatusEffectUpgraded( StatusEffectInstance statusEffectInstance, boolean particles, @Nullable Entity source )
{
}
@@ -215,10 +215,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 )
@@ -232,15 +232,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 )
diff --git a/src/main/java/dan200/computercraft/api/turtle/ITurtleAccess.java b/src/main/java/dan200/computercraft/api/turtle/ITurtleAccess.java
index 6213a079b..c50b83eb3 100644
--- a/src/main/java/dan200/computercraft/api/turtle/ITurtleAccess.java
+++ b/src/main/java/dan200/computercraft/api/turtle/ITurtleAccess.java
@@ -12,7 +12,7 @@ import dan200.computercraft.api.lua.MethodResult;
import dan200.computercraft.api.peripheral.IPeripheral;
import dan200.computercraft.shared.util.ItemStorage;
import net.minecraft.inventory.Inventory;
-import net.minecraft.nbt.CompoundTag;
+import net.minecraft.nbt.NbtCompound;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.Vec3d;
@@ -255,7 +255,7 @@ public interface ITurtleAccess
* @see #updateUpgradeNBTData(TurtleSide)
*/
@Nonnull
- CompoundTag getUpgradeNBTData( @Nullable TurtleSide side );
+ NbtCompound getUpgradeNBTData( @Nullable TurtleSide side );
/**
* Mark the upgrade-specific data as dirty on a specific side. This is required for the data to be synced to the client and persisted.
diff --git a/src/main/java/dan200/computercraft/client/gui/FixedWidthFontRenderer.java b/src/main/java/dan200/computercraft/client/gui/FixedWidthFontRenderer.java
index 36868c428..b41964088 100644
--- a/src/main/java/dan200/computercraft/client/gui/FixedWidthFontRenderer.java
+++ b/src/main/java/dan200/computercraft/client/gui/FixedWidthFontRenderer.java
@@ -14,7 +14,7 @@ import dan200.computercraft.shared.util.Colour;
import dan200.computercraft.shared.util.Palette;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.*;
-import net.minecraft.client.util.math.AffineTransformation;
+import net.minecraft.util.math.AffineTransformation;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.Matrix4f;
import org.lwjgl.opengl.GL11;
@@ -23,7 +23,7 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public final class FixedWidthFontRenderer
-{
+{ //FIXME Make this work like a gui, via BufferBuilder's
public static final int FONT_HEIGHT = 9;
public static final int FONT_WIDTH = 6;
public static final float WIDTH = 256.0f;
@@ -394,21 +394,21 @@ public final class FixedWidthFontRenderer
private static final VertexFormat FORMAT = VertexFormats.POSITION_COLOR_TEXTURE;
static final RenderLayer MAIN = RenderLayer.of( "terminal_font", FORMAT, GL_MODE, 1024, false, false, // useDelegate, needsSorting
- RenderLayer.MultiPhaseParameters.builder()
+ RenderLayer.MultiPhaseParameters.Builder()
.texture( new RenderPhase.Texture( FONT,
false,
false ) ) // blur, minimap
- .alpha( ONE_TENTH_ALPHA )
+ .transparency( TRANSLUCENT_TRANSPARENCY )
.lightmap( DISABLE_LIGHTMAP )
.writeMaskState( COLOR_MASK )
.build( false ) );
static final RenderLayer BLOCKER = RenderLayer.of( "terminal_blocker", FORMAT, GL_MODE, 256, false, false, // useDelegate, needsSorting
- RenderLayer.MultiPhaseParameters.builder()
+ RenderLayer.MultiPhaseParameters.Builder()
.texture( new RenderPhase.Texture( FONT,
false,
false ) ) // blur, minimap
- .alpha( ONE_TENTH_ALPHA )
+ .transparency( TRANSLUCENT_TRANSPARENCY )
.writeMaskState( ALL_MASK )
.lightmap( DISABLE_LIGHTMAP )
.build( false ) );
diff --git a/src/main/java/dan200/computercraft/client/gui/GuiComputer.java b/src/main/java/dan200/computercraft/client/gui/GuiComputer.java
index a4f40a783..c78197271 100644
--- a/src/main/java/dan200/computercraft/client/gui/GuiComputer.java
+++ b/src/main/java/dan200/computercraft/client/gui/GuiComputer.java
@@ -28,6 +28,8 @@ import javax.annotation.Nonnull;
import static dan200.computercraft.client.render.ComputerBorderRenderer.BORDER;
import static dan200.computercraft.client.render.ComputerBorderRenderer.MARGIN;
+import java.util.List;
+
public class GuiComputer extends HandledScreen
{
protected final ComputerFamily family;
@@ -78,7 +80,7 @@ public class GuiComputer extends HandledScreen<
terminal = new WidgetTerminal( client, () -> computer, termWidth, termHeight, MARGIN, MARGIN, MARGIN, MARGIN );
terminalWrapper = new WidgetWrapper( terminal, MARGIN + border + x, MARGIN + border + y, termPxWidth, termPxHeight );
- children.add( terminalWrapper );
+ ((List)children()).add( terminalWrapper ); //FIXME: This is bad.
setFocused( terminalWrapper );
}
@@ -109,7 +111,7 @@ public class GuiComputer extends HandledScreen<
terminal.draw( terminalWrapper.getX(), terminalWrapper.getY() );
// Draw a border around the terminal
- RenderSystem.color4f( 1, 1, 1, 1 );
+ RenderSystem.clearColor( 1, 1, 1, 1 );
client.getTextureManager()
.bindTexture( ComputerBorderRenderer.getTexture( family ) );
ComputerBorderRenderer.render( terminalWrapper.getX() - MARGIN, terminalWrapper.getY() - MARGIN,
@@ -144,7 +146,7 @@ public class GuiComputer extends HandledScreen<
public void removed()
{
super.removed();
- children.remove( terminal );
+ children().remove( terminal );
terminal = null;
client.keyboard.setRepeatEvents( false );
}
diff --git a/src/main/java/dan200/computercraft/client/gui/GuiDiskDrive.java b/src/main/java/dan200/computercraft/client/gui/GuiDiskDrive.java
index 773ac2c00..d1d647e82 100644
--- a/src/main/java/dan200/computercraft/client/gui/GuiDiskDrive.java
+++ b/src/main/java/dan200/computercraft/client/gui/GuiDiskDrive.java
@@ -36,7 +36,7 @@ public class GuiDiskDrive extends HandledScreen
@Override
protected void drawBackground( @Nonnull MatrixStack transform, float partialTicks, int mouseX, int mouseY )
{
- RenderSystem.color4f( 1.0F, 1.0F, 1.0F, 1.0F );
+ RenderSystem.clearColor( 1.0F, 1.0F, 1.0F, 1.0F );
client.getTextureManager()
.bindTexture( BACKGROUND );
drawTexture( transform, x, y, 0, 0, backgroundWidth, backgroundHeight );
diff --git a/src/main/java/dan200/computercraft/client/gui/GuiPrinter.java b/src/main/java/dan200/computercraft/client/gui/GuiPrinter.java
index f0e29a49b..b4c2eb69b 100644
--- a/src/main/java/dan200/computercraft/client/gui/GuiPrinter.java
+++ b/src/main/java/dan200/computercraft/client/gui/GuiPrinter.java
@@ -44,7 +44,7 @@ public class GuiPrinter extends HandledScreen
@Override
protected void drawBackground( @Nonnull MatrixStack transform, float partialTicks, int mouseX, int mouseY )
{
- RenderSystem.color4f( 1.0F, 1.0F, 1.0F, 1.0F );
+ RenderSystem.clearColor( 1.0F, 1.0F, 1.0F, 1.0F );
client.getTextureManager()
.bindTexture( BACKGROUND );
drawTexture( transform, x, y, 0, 0, backgroundWidth, backgroundHeight );
diff --git a/src/main/java/dan200/computercraft/client/gui/GuiPrintout.java b/src/main/java/dan200/computercraft/client/gui/GuiPrintout.java
index 261948e19..2e49fe96f 100644
--- a/src/main/java/dan200/computercraft/client/gui/GuiPrintout.java
+++ b/src/main/java/dan200/computercraft/client/gui/GuiPrintout.java
@@ -108,7 +108,7 @@ public class GuiPrintout extends HandledScreen
protected void drawBackground( @Nonnull MatrixStack transform, float partialTicks, int mouseX, int mouseY )
{
// Draw the printout
- RenderSystem.color4f( 1.0f, 1.0f, 1.0f, 1.0f );
+ RenderSystem.clearColor( 1.0f, 1.0f, 1.0f, 1.0f );
RenderSystem.enableDepthTest();
VertexConsumerProvider.Immediate renderer = MinecraftClient.getInstance()
diff --git a/src/main/java/dan200/computercraft/client/gui/GuiTurtle.java b/src/main/java/dan200/computercraft/client/gui/GuiTurtle.java
index af78829ad..afdab5ae0 100644
--- a/src/main/java/dan200/computercraft/client/gui/GuiTurtle.java
+++ b/src/main/java/dan200/computercraft/client/gui/GuiTurtle.java
@@ -44,7 +44,7 @@ public class GuiTurtle extends GuiComputer
terminal.draw( terminalWrapper.getX(), terminalWrapper.getY() );
// Draw border/inventory
- RenderSystem.color4f( 1.0F, 1.0F, 1.0F, 1.0F );
+ RenderSystem.clearColor( 1.0F, 1.0F, 1.0F, 1.0F );
client.getTextureManager()
.bindTexture( texture );
drawTexture( transform, x, y, 0, 0, backgroundWidth, backgroundHeight );
diff --git a/src/main/java/dan200/computercraft/client/render/ComputerBorderRenderer.java b/src/main/java/dan200/computercraft/client/render/ComputerBorderRenderer.java
index 65166b05d..eddb729dd 100644
--- a/src/main/java/dan200/computercraft/client/render/ComputerBorderRenderer.java
+++ b/src/main/java/dan200/computercraft/client/render/ComputerBorderRenderer.java
@@ -11,6 +11,7 @@ import dan200.computercraft.shared.computer.core.ComputerFamily;
import net.minecraft.client.render.BufferBuilder;
import net.minecraft.client.render.Tessellator;
import net.minecraft.client.render.VertexConsumer;
+import net.minecraft.client.render.VertexFormat;
import net.minecraft.client.render.VertexFormats;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.Matrix4f;
@@ -84,11 +85,11 @@ public class ComputerBorderRenderer
{
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder buffer = tessellator.getBuffer();
- buffer.begin( GL11.GL_QUADS, VertexFormats.POSITION_COLOR_TEXTURE );
+ buffer.begin( VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR_TEXTURE );
render( IDENTITY, buffer, x, y, z, width, height );
- RenderSystem.enableAlphaTest();
+ RenderSystem.enableDepthTest(); //TODO: enableAlphaTest(). FIXME
tessellator.draw();
}
diff --git a/src/main/java/dan200/computercraft/client/render/ItemMapLikeRenderer.java b/src/main/java/dan200/computercraft/client/render/ItemMapLikeRenderer.java
index ed7608367..6ecd99254 100644
--- a/src/main/java/dan200/computercraft/client/render/ItemMapLikeRenderer.java
+++ b/src/main/java/dan200/computercraft/client/render/ItemMapLikeRenderer.java
@@ -13,12 +13,12 @@ import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.item.HeldItemRenderer;
import net.minecraft.client.util.math.MatrixStack;
-import net.minecraft.client.util.math.Vector3f;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Arm;
import net.minecraft.util.Hand;
import net.minecraft.util.math.MathHelper;
+import net.minecraft.util.math.Vec3f;
@Environment( EnvType.CLIENT )
public abstract class ItemMapLikeRenderer
@@ -75,18 +75,18 @@ public abstract class ItemMapLikeRenderer
HeldItemRendererAccess access = (HeldItemRendererAccess) renderer;
float pitchAngle = access.callGetMapAngle( pitch );
transform.translate( 0, 0.04F + equipProgress * -1.2f + pitchAngle * -0.5f, -0.72f );
- transform.multiply( Vector3f.POSITIVE_X.getDegreesQuaternion( pitchAngle * -85.0f ) );
+ transform.multiply( Vec3f.POSITIVE_X.getDegreesQuaternion( pitchAngle * -85.0f ) );
if( !minecraft.player.isInvisible() )
{
transform.push();
- transform.multiply( Vector3f.POSITIVE_Y.getDegreesQuaternion( 90.0F ) );
+ transform.multiply( Vec3f.POSITIVE_Y.getDegreesQuaternion( 90.0F ) );
access.callRenderArm( transform, render, combinedLight, Arm.RIGHT );
access.callRenderArm( transform, render, combinedLight, Arm.LEFT );
transform.pop();
}
float rX = MathHelper.sin( swingRt * (float) Math.PI );
- transform.multiply( Vector3f.POSITIVE_X.getDegreesQuaternion( rX * 20.0F ) );
+ transform.multiply( Vec3f.POSITIVE_X.getDegreesQuaternion( rX * 20.0F ) );
transform.scale( 2.0F, 2.0F, 2.0F );
renderItem( transform, render, stack );
@@ -114,7 +114,7 @@ public abstract class ItemMapLikeRenderer
if( !minecraft.player.isInvisible() )
{
transform.push();
- transform.multiply( Vector3f.POSITIVE_Z.getDegreesQuaternion( offset * 10f ) );
+ transform.multiply( Vec3f.POSITIVE_Z.getDegreesQuaternion( offset * 10f ) );
((HeldItemRendererAccess) minecraft.getHeldItemRenderer())
.callRenderArmHoldingItem( transform, render, combinedLight, equipProgress, swingProgress, side );
transform.pop();
@@ -130,8 +130,8 @@ public abstract class ItemMapLikeRenderer
float f4 = 0.4f * MathHelper.sin( f1 * ((float) Math.PI * 2f) );
float f5 = -0.3f * MathHelper.sin( swingProgress * (float) Math.PI );
transform.translate( offset * f3, f4 - 0.3f * f2, f5 );
- transform.multiply( Vector3f.POSITIVE_X.getDegreesQuaternion( f2 * -45f ) );
- transform.multiply( Vector3f.POSITIVE_Y.getDegreesQuaternion( offset * f2 * -30f ) );
+ transform.multiply( Vec3f.POSITIVE_X.getDegreesQuaternion( f2 * -45f ) );
+ transform.multiply( Vec3f.POSITIVE_Y.getDegreesQuaternion( offset * f2 * -30f ) );
renderItem( transform, render, stack );
diff --git a/src/main/java/dan200/computercraft/client/render/ItemPocketRenderer.java b/src/main/java/dan200/computercraft/client/render/ItemPocketRenderer.java
index e073820cb..2bf5d3571 100644
--- a/src/main/java/dan200/computercraft/client/render/ItemPocketRenderer.java
+++ b/src/main/java/dan200/computercraft/client/render/ItemPocketRenderer.java
@@ -18,10 +18,11 @@ import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.BufferBuilder;
import net.minecraft.client.render.Tessellator;
import net.minecraft.client.render.VertexConsumerProvider;
+import net.minecraft.client.render.VertexFormat;
import net.minecraft.client.render.VertexFormats;
import net.minecraft.client.util.math.MatrixStack;
-import net.minecraft.client.util.math.Vector3f;
import net.minecraft.item.ItemStack;
+import net.minecraft.util.math.Vec3f;
import net.minecraft.util.math.Matrix4f;
import org.lwjgl.opengl.GL11;
@@ -64,8 +65,8 @@ public final class ItemPocketRenderer extends ItemMapLikeRenderer
// Setup various transformations. Note that these are partially adapted from the corresponding method
// in ItemRenderer
transform.push();
- transform.multiply( Vector3f.POSITIVE_Y.getDegreesQuaternion( 180f ) );
- transform.multiply( Vector3f.POSITIVE_Z.getDegreesQuaternion( 180f ) );
+ transform.multiply( Vec3f.POSITIVE_Y.getDegreesQuaternion( 180f ) );
+ transform.multiply( Vec3f.POSITIVE_Z.getDegreesQuaternion( 180f ) );
transform.scale( 0.5f, 0.5f, 0.5f );
float scale = 0.75f / Math.max( width + BORDER * 2, height + BORDER * 2 + LIGHT_HEIGHT );
@@ -114,7 +115,7 @@ public final class ItemPocketRenderer extends ItemMapLikeRenderer
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder buffer = tessellator.getBuffer();
- buffer.begin( GL11.GL_QUADS, VertexFormats.POSITION_COLOR_TEXTURE );
+ buffer.begin( VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR_TEXTURE );
ComputerBorderRenderer.render( transform, buffer, 0, 0, 0, width, height, true, r, g, b );
@@ -131,7 +132,7 @@ public final class ItemPocketRenderer extends ItemMapLikeRenderer
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder buffer = tessellator.getBuffer();
- buffer.begin( GL11.GL_QUADS, VertexFormats.POSITION_COLOR );
+ buffer.begin( VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR );
buffer.vertex( transform, width - LIGHT_HEIGHT * 2, height + LIGHT_HEIGHT + BORDER / 2.0f, 0 )
.color( r, g, b, 1.0f )
.next();
diff --git a/src/main/java/dan200/computercraft/client/render/ItemPrintoutRenderer.java b/src/main/java/dan200/computercraft/client/render/ItemPrintoutRenderer.java
index 5878c61d3..cfab4d1c4 100644
--- a/src/main/java/dan200/computercraft/client/render/ItemPrintoutRenderer.java
+++ b/src/main/java/dan200/computercraft/client/render/ItemPrintoutRenderer.java
@@ -9,7 +9,7 @@ package dan200.computercraft.client.render;
import dan200.computercraft.shared.media.items.ItemPrintout;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.util.math.MatrixStack;
-import net.minecraft.client.util.math.Vector3f;
+import net.minecraft.util.math.Vec3f;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.Matrix4f;
@@ -33,7 +33,7 @@ public final class ItemPrintoutRenderer extends ItemMapLikeRenderer
@Override
protected void renderItem( MatrixStack transform, VertexConsumerProvider render, ItemStack stack )
{
- transform.multiply( Vector3f.POSITIVE_X.getDegreesQuaternion( 180f ) );
+ transform.multiply( Vec3f.POSITIVE_X.getDegreesQuaternion( 180f ) );
transform.scale( 0.42f, 0.42f, -0.42f );
transform.translate( -0.5f, -0.48f, 0.0f );
@@ -85,7 +85,7 @@ public final class ItemPrintoutRenderer extends ItemMapLikeRenderer
// Move a little bit forward to ensure we're not clipping with the frame
matrixStack.translate( 0.0f, 0.0f, -0.001f );
- matrixStack.multiply( Vector3f.POSITIVE_Z.getDegreesQuaternion( 180f ) );
+ matrixStack.multiply( Vec3f.POSITIVE_Z.getDegreesQuaternion( 180f ) );
matrixStack.scale( 0.95f, 0.95f, -0.95f );
matrixStack.translate( -0.5f, -0.5f, 0.0f );
diff --git a/src/main/java/dan200/computercraft/client/render/ModelTransformer.java b/src/main/java/dan200/computercraft/client/render/ModelTransformer.java
index 234969e7f..1ae9c35a1 100644
--- a/src/main/java/dan200/computercraft/client/render/ModelTransformer.java
+++ b/src/main/java/dan200/computercraft/client/render/ModelTransformer.java
@@ -12,7 +12,7 @@ import net.minecraft.client.render.VertexFormat;
import net.minecraft.client.render.VertexFormatElement;
import net.minecraft.client.render.VertexFormats;
import net.minecraft.client.render.model.BakedQuad;
-import net.minecraft.client.util.math.Vector4f;
+import net.minecraft.util.math.Vector4f;
import net.minecraft.util.math.Matrix4f;
import java.util.List;
@@ -66,7 +66,7 @@ public final class ModelTransformer
for( VertexFormatElement element : format.getElements() ) // For each vertex element
{
int start = offsetBytes / Integer.BYTES;
- if( element.getType() == VertexFormatElement.Type.POSITION && element.getFormat() == VertexFormatElement.Format.FLOAT ) // When we find a position element
+ if( element.getType() == VertexFormatElement.Type.POSITION && element.getDataType() == VertexFormatElement.DataType.FLOAT ) // When we find a position element
{
Vector4f pos = new Vector4f( Float.intBitsToFloat( vertexData[start] ),
Float.intBitsToFloat( vertexData[start + 1] ),
@@ -81,7 +81,7 @@ public final class ModelTransformer
vertexData[start + 1] = Float.floatToRawIntBits( pos.getY() );
vertexData[start + 2] = Float.floatToRawIntBits( pos.getZ() );
}
- offsetBytes += element.getSize();
+ offsetBytes += element.getLength();
}
}
return copy;
diff --git a/src/main/java/dan200/computercraft/client/render/MonitorTextureBufferShader.java b/src/main/java/dan200/computercraft/client/render/MonitorTextureBufferShader.java
index 2fc785d17..98f336ba1 100644
--- a/src/main/java/dan200/computercraft/client/render/MonitorTextureBufferShader.java
+++ b/src/main/java/dan200/computercraft/client/render/MonitorTextureBufferShader.java
@@ -7,11 +7,11 @@ package dan200.computercraft.client.render;
import com.google.common.base.Strings;
import com.mojang.blaze3d.platform.GlStateManager;
+import com.mojang.blaze3d.platform.TextureUtil;
import com.mojang.blaze3d.systems.RenderSystem;
import dan200.computercraft.ComputerCraft;
import dan200.computercraft.client.gui.FixedWidthFontRenderer;
import dan200.computercraft.shared.util.Palette;
-import net.minecraft.client.texture.TextureUtil;
import net.minecraft.util.math.Matrix4f;
import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.GL13;
@@ -19,6 +19,7 @@ import org.lwjgl.opengl.GL20;
import java.io.InputStream;
import java.nio.FloatBuffer;
+import java.util.List;
class MonitorTextureBufferShader
{
@@ -42,7 +43,7 @@ class MonitorTextureBufferShader
static void setupUniform( Matrix4f transform, int width, int height, Palette palette, boolean greyscale )
{
MATRIX_BUFFER.rewind();
- transform.writeToBuffer( MATRIX_BUFFER );
+ transform.write( MATRIX_BUFFER, true ); //FIXME: Row major or Column major? guessing row major, since that is like C.
MATRIX_BUFFER.rewind();
RenderSystem.glUniformMatrix4( uniformMv, false, MATRIX_BUFFER );
@@ -77,7 +78,7 @@ class MonitorTextureBufferShader
{
if( ok )
{
- GlStateManager.useProgram( program );
+ GlStateManager.glLinkProgram( program );
}
return ok;
}
@@ -101,14 +102,15 @@ class MonitorTextureBufferShader
int vertexShader = loadShader( GL20.GL_VERTEX_SHADER, "assets/computercraft/shaders/monitor.vert" );
int fragmentShader = loadShader( GL20.GL_FRAGMENT_SHADER, "assets/computercraft/shaders/monitor.frag" );
- program = GlStateManager.createProgram();
- GlStateManager.attachShader( program, vertexShader );
- GlStateManager.attachShader( program, fragmentShader );
+ program = GlStateManager.glCreateProgram();
+ GlStateManager.glAttachShader( program, vertexShader );
+ GlStateManager.glAttachShader( program, fragmentShader );
GL20.glBindAttribLocation( program, 0, "v_pos" );
- GlStateManager.linkProgram( program );
- boolean ok = GlStateManager.getProgram( program, GL20.GL_LINK_STATUS ) != 0;
- String log = GlStateManager.getProgramInfoLog( program, Short.MAX_VALUE )
+ GlStateManager.glLinkProgram( program );
+
+ boolean ok = GlStateManager.glGetProgrami( program, GL20.GL_LINK_STATUS ) != 0;
+ String log = GlStateManager.glGetProgramInfoLog( program, Short.MAX_VALUE )
.trim();
if( !Strings.isNullOrEmpty( log ) )
{
@@ -117,8 +119,8 @@ class MonitorTextureBufferShader
GL20.glDetachShader( program, vertexShader );
GL20.glDetachShader( program, fragmentShader );
- GlStateManager.deleteShader( vertexShader );
- GlStateManager.deleteShader( fragmentShader );
+ GlStateManager.glDeleteShader( vertexShader );
+ GlStateManager.glDeleteShader( fragmentShader );
if( !ok )
{
@@ -150,15 +152,15 @@ class MonitorTextureBufferShader
{
throw new IllegalArgumentException( "Cannot find " + path );
}
- String contents = TextureUtil.readAllToString( stream );
+ List contents = TextureUtil.readResourceAsString(stream).lines().toList();
- int shader = GlStateManager.createShader( kind );
+ int shader = GlStateManager.glCreateShader( kind );
- GlStateManager.shaderSource( shader, contents );
- GlStateManager.compileShader( shader );
+ GlStateManager.glShaderSource( shader, contents );
+ GlStateManager.glCompileShader( shader );
- boolean ok = GlStateManager.getShader( shader, GL20.GL_COMPILE_STATUS ) != 0;
- String log = GlStateManager.getShaderInfoLog( shader, Short.MAX_VALUE )
+ boolean ok = GlStateManager.glGetShaderi( shader, GL20.GL_COMPILE_STATUS ) != 0;
+ String log = GlStateManager.glGetShaderInfoLog( shader, Short.MAX_VALUE )
.trim();
if( !Strings.isNullOrEmpty( log ) )
{
@@ -174,7 +176,7 @@ class MonitorTextureBufferShader
private static int getUniformLocation( int program, String name )
{
- int uniform = GlStateManager.getUniformLocation( program, name );
+ int uniform = GlStateManager._glGetUniformLocation( program, name );
if( uniform == -1 )
{
throw new IllegalStateException( "Cannot find uniform " + name );
diff --git a/src/main/java/dan200/computercraft/client/render/PrintoutRenderer.java b/src/main/java/dan200/computercraft/client/render/PrintoutRenderer.java
index 489506aae..5f48bbe7e 100644
--- a/src/main/java/dan200/computercraft/client/render/PrintoutRenderer.java
+++ b/src/main/java/dan200/computercraft/client/render/PrintoutRenderer.java
@@ -10,6 +10,7 @@ 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.util.math.Matrix4f;
import org.lwjgl.opengl.GL11;
@@ -18,7 +19,7 @@ import static dan200.computercraft.client.gui.FixedWidthFontRenderer.FONT_HEIGHT
import static dan200.computercraft.shared.media.items.ItemPrintout.LINES_PER_PAGE;
public final class PrintoutRenderer
-{
+{ //FIXME Use BufferBuilders
/**
* Width of a page.
*/
@@ -186,24 +187,22 @@ public final class PrintoutRenderer
.next();
}
- private static final class Type extends RenderPhase
+ private static final class Type extends RenderLayer
{
static final RenderLayer TYPE = RenderLayer.of( "printout_background",
VertexFormats.POSITION_TEXTURE,
- GL11.GL_QUADS,
+ VertexFormat.DrawMode.QUADS,
1024,
- false,
- false,
// useDelegate, needsSorting
RenderLayer.MultiPhaseParameters.builder()
.texture( new RenderPhase.Texture( BG, false, false ) ) // blur, minimap
- .alpha( ONE_TENTH_ALPHA )
+ .transparency( TRANSLUCENT_TRANSPARENCY )
.lightmap( DISABLE_LIGHTMAP )
- .build( false ) );
+ .build( false ));
- private Type( String name, Runnable setup, Runnable destroy )
+ private Type( String name, VertexFormat vertexFormat, VertexFormat.DrawMode drawMode, int expectedBufferSize, boolean hasCrumbling, boolean translucent, RenderLayer.MultiPhaseParameters phases, Runnable setup, Runnable destroy )
{
- super( name, setup, destroy );
+ super( name, vertexFormat, drawMode, expectedBufferSize, hasCrumbling, hasCrumbling, setup, destroy );
}
}
}
diff --git a/src/main/java/dan200/computercraft/client/render/TileEntityMonitorRenderer.java b/src/main/java/dan200/computercraft/client/render/TileEntityMonitorRenderer.java
index 5c0c1a879..4ff0cefb7 100644
--- a/src/main/java/dan200/computercraft/client/render/TileEntityMonitorRenderer.java
+++ b/src/main/java/dan200/computercraft/client/render/TileEntityMonitorRenderer.java
@@ -21,9 +21,9 @@ 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.util.GlAllocationUtils;
-import net.minecraft.client.util.math.AffineTransformation;
+import net.minecraft.util.math.AffineTransformation;
import net.minecraft.client.util.math.MatrixStack;
-import net.minecraft.client.util.math.Vector3f;
+import net.minecraft.util.math.Vec3f;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.Matrix4f;
@@ -37,8 +37,8 @@ import java.nio.ByteBuffer;
import static dan200.computercraft.client.gui.FixedWidthFontRenderer.*;
-public class TileEntityMonitorRenderer extends BlockEntityRenderer
-{
+public class TileEntityMonitorRenderer implements BlockEntityRenderer
+{ //FIXME get rid of GL Calls. Buffered things or whatever, more research needed.
/**
* {@link TileMonitor#RENDER_MARGIN}, but a tiny bit of additional padding to ensure that there is no space between the monitor frame and contents.
*/
@@ -89,8 +89,8 @@ public class TileEntityMonitorRenderer extends BlockEntityRenderer
originPos.getY() - monitorPos.getY() + 0.5,
originPos.getZ() - monitorPos.getZ() + 0.5 );
- transform.multiply( Vector3f.NEGATIVE_Y.getDegreesQuaternion( yaw ) );
- transform.multiply( Vector3f.POSITIVE_X.getDegreesQuaternion( pitch ) );
+ transform.multiply( Vec3f.NEGATIVE_Y.getDegreesQuaternion( yaw ) );
+ transform.multiply( Vec3f.POSITIVE_X.getDegreesQuaternion( pitch ) );
transform.translate( -0.5 + TileMonitor.RENDER_BORDER + TileMonitor.RENDER_MARGIN,
origin.getHeight() - 0.5 - (TileMonitor.RENDER_BORDER + TileMonitor.RENDER_MARGIN) + 0,
0.50 );
diff --git a/src/main/java/dan200/computercraft/client/render/TileEntityTurtleRenderer.java b/src/main/java/dan200/computercraft/client/render/TileEntityTurtleRenderer.java
index 5d6eceea6..da39a3028 100644
--- a/src/main/java/dan200/computercraft/client/render/TileEntityTurtleRenderer.java
+++ b/src/main/java/dan200/computercraft/client/render/TileEntityTurtleRenderer.java
@@ -26,7 +26,7 @@ import net.minecraft.client.render.model.BakedModelManager;
import net.minecraft.client.render.model.BakedQuad;
import net.minecraft.client.util.ModelIdentifier;
import net.minecraft.client.util.math.MatrixStack;
-import net.minecraft.client.util.math.Vector3f;
+import net.minecraft.util.math.Vec3f;
import net.minecraft.util.Identifier;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.hit.HitResult;
@@ -38,8 +38,8 @@ import javax.annotation.Nonnull;
import java.util.List;
import java.util.Random;
-public class TileEntityTurtleRenderer extends BlockEntityRenderer
-{
+public class TileEntityTurtleRenderer implements BlockEntityRenderer
+{ //FIXME: more rendering puzzles.
private static final ModelIdentifier NORMAL_TURTLE_MODEL = new ModelIdentifier( "computercraft:turtle_normal", "inventory" );
private static final ModelIdentifier ADVANCED_TURTLE_MODEL = new ModelIdentifier( "computercraft:turtle_advanced", "inventory" );
private static final ModelIdentifier COLOUR_TURTLE_MODEL = new ModelIdentifier( "computercraft:turtle_colour", "inventory" );
@@ -147,7 +147,7 @@ public class TileEntityTurtleRenderer extends BlockEntityRenderer
transform.translate( offset.x, offset.y, offset.z );
transform.translate( 0.5f, 0.5f, 0.5f );
- transform.multiply( Vector3f.POSITIVE_Y.getDegreesQuaternion( 180.0f - yaw ) );
+ transform.multiply( Vec3f.POSITIVE_Y.getDegreesQuaternion( 180.0f - yaw ) );
if( label != null && (label.equals( "Dinnerbone" ) || label.equals( "Grumm" )) )
{
// Flip the model
@@ -189,7 +189,7 @@ public class TileEntityTurtleRenderer extends BlockEntityRenderer
float toolAngle = turtle.getToolRenderAngle( side, f );
transform.translate( 0.0f, 0.5f, 0.5f );
- transform.multiply( Vector3f.NEGATIVE_X.getDegreesQuaternion( toolAngle ) );
+ transform.multiply( Vec3f.NEGATIVE_X.getDegreesQuaternion( toolAngle ) );
transform.translate( 0.0f, -0.5f, -0.5f );
TransformedModel model = upgrade.getModel( turtle.getAccess(), side );
diff --git a/src/main/java/dan200/computercraft/client/render/TurtleMultiModel.java b/src/main/java/dan200/computercraft/client/render/TurtleMultiModel.java
index e58ac12f4..f6803af3e 100644
--- a/src/main/java/dan200/computercraft/client/render/TurtleMultiModel.java
+++ b/src/main/java/dan200/computercraft/client/render/TurtleMultiModel.java
@@ -15,7 +15,7 @@ import net.minecraft.client.render.model.BakedQuad;
import net.minecraft.client.render.model.json.ModelOverrideList;
import net.minecraft.client.render.model.json.ModelTransformation;
import net.minecraft.client.texture.Sprite;
-import net.minecraft.client.util.math.AffineTransformation;
+import net.minecraft.util.math.AffineTransformation;
import net.minecraft.util.math.Direction;
import javax.annotation.Nonnull;
diff --git a/src/main/java/dan200/computercraft/client/render/TurtlePlayerRenderer.java b/src/main/java/dan200/computercraft/client/render/TurtlePlayerRenderer.java
index 636cc4b4d..00bc29572 100644
--- a/src/main/java/dan200/computercraft/client/render/TurtlePlayerRenderer.java
+++ b/src/main/java/dan200/computercraft/client/render/TurtlePlayerRenderer.java
@@ -10,19 +10,20 @@ 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.Context;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.Identifier;
import javax.annotation.Nonnull;
public class TurtlePlayerRenderer extends EntityRenderer
-{
- public TurtlePlayerRenderer( EntityRenderDispatcher renderManager )
+{ //FIXME Make sure this isn't an issue. Context was EntityRenderDispatcher.
+ public TurtlePlayerRenderer( Context renderManager )
{
super( renderManager );
}
- public TurtlePlayerRenderer( EntityRenderDispatcher entityRenderDispatcher, EntityRendererRegistry.Context context )
+ public TurtlePlayerRenderer( Context entityRenderDispatcher, EntityRendererRegistry.Context context )
{
super( entityRenderDispatcher );
}
diff --git a/src/main/java/dan200/computercraft/client/render/TurtleSmartItemModel.java b/src/main/java/dan200/computercraft/client/render/TurtleSmartItemModel.java
index 85e559106..9da28fa33 100644
--- a/src/main/java/dan200/computercraft/client/render/TurtleSmartItemModel.java
+++ b/src/main/java/dan200/computercraft/client/render/TurtleSmartItemModel.java
@@ -24,7 +24,7 @@ import net.minecraft.client.render.model.json.ModelOverrideList;
import net.minecraft.client.render.model.json.ModelTransformation;
import net.minecraft.client.texture.Sprite;
import net.minecraft.client.util.ModelIdentifier;
-import net.minecraft.client.util.math.AffineTransformation;
+import net.minecraft.util.math.AffineTransformation;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.entity.LivingEntity;
@@ -70,8 +70,7 @@ public class TurtleSmartItemModel implements BakedModel
{
@Nonnull
@Override
- public BakedModel apply( @Nonnull BakedModel originalModel, @Nonnull ItemStack stack, @Nullable ClientWorld world,
- @Nullable LivingEntity entity )
+ 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 );
diff --git a/src/main/java/dan200/computercraft/core/filesystem/ResourceMount.java b/src/main/java/dan200/computercraft/core/filesystem/ResourceMount.java
index 2a5ad299f..7cd475854 100644
--- a/src/main/java/dan200/computercraft/core/filesystem/ResourceMount.java
+++ b/src/main/java/dan200/computercraft/core/filesystem/ResourceMount.java
@@ -16,7 +16,8 @@ import dan200.computercraft.shared.util.IoUtil;
import net.minecraft.resource.ReloadableResourceManager;
import net.minecraft.resource.Resource;
import net.minecraft.resource.ResourceManager;
-import net.minecraft.resource.ResourceReloadListener;
+import net.minecraft.resource.ResourceReloader;
+import net.minecraft.resource.ResourceReloader.Synchronizer;
import net.minecraft.util.Identifier;
import net.minecraft.util.InvalidIdentifierException;
import net.minecraft.util.profiler.Profiler;
@@ -299,7 +300,7 @@ public final class ResourceMount implements IMount
* While people should really be keeping a permanent reference to this, some people construct it every
* method call, so let's make this as small as possible.
*/
- static class Listener implements ResourceReloadListener
+ static class Listener implements ResourceReloader
{
private static final Listener INSTANCE = new Listener();
@@ -324,7 +325,7 @@ public final class ResourceMount implements IMount
synchronized void add( ReloadableResourceManager manager, ResourceMount mount )
{
- if( managers.add( manager ) ) manager.registerListener( this );
+ if( managers.add( manager ) ) manager.registerReloader( this );
mounts.add( mount );
}
}
diff --git a/src/main/java/dan200/computercraft/core/terminal/Terminal.java b/src/main/java/dan200/computercraft/core/terminal/Terminal.java
index 9b8894757..8215e4d19 100644
--- a/src/main/java/dan200/computercraft/core/terminal/Terminal.java
+++ b/src/main/java/dan200/computercraft/core/terminal/Terminal.java
@@ -7,7 +7,7 @@ package dan200.computercraft.core.terminal;
import dan200.computercraft.shared.util.Colour;
import dan200.computercraft.shared.util.Palette;
-import net.minecraft.nbt.CompoundTag;
+import net.minecraft.nbt.NbtCompound;
import net.minecraft.network.PacketByteBuf;
import javax.annotation.Nonnull;
@@ -366,7 +366,7 @@ public class Terminal
setChanged();
}
- public synchronized CompoundTag writeToNBT( CompoundTag nbt )
+ public synchronized NbtCompound writeToNBT( NbtCompound nbt )
{
nbt.putInt( "term_cursorX", cursorX );
nbt.putInt( "term_cursorY", cursorY );
@@ -384,7 +384,7 @@ public class Terminal
return nbt;
}
- public synchronized void readFromNBT( CompoundTag nbt )
+ public synchronized void readFromNBT( NbtCompound nbt )
{
cursorX = nbt.getInt( "term_cursorX" );
cursorY = nbt.getInt( "term_cursorY" );
diff --git a/src/main/java/dan200/computercraft/fabric/mixin/AffineTransformationAccess.java b/src/main/java/dan200/computercraft/fabric/mixin/AffineTransformationAccess.java
index 8ddc8dbdc..1a1e93b8f 100644
--- a/src/main/java/dan200/computercraft/fabric/mixin/AffineTransformationAccess.java
+++ b/src/main/java/dan200/computercraft/fabric/mixin/AffineTransformationAccess.java
@@ -5,8 +5,8 @@
*/
package dan200.computercraft.fabric.mixin;
-import net.minecraft.client.util.math.AffineTransformation;
-import net.minecraft.client.util.math.Vector3f;
+import net.minecraft.util.math.AffineTransformation;
+import net.minecraft.util.math.Vec3f;
import net.minecraft.util.math.Quaternion;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
@@ -15,10 +15,10 @@ import org.spongepowered.asm.mixin.gen.Accessor;
public interface AffineTransformationAccess
{
@Accessor
- Vector3f getTranslation();
+ Vec3f getTranslation();
@Accessor
- Vector3f getScale();
+ Vec3f getScale();
@Accessor
Quaternion getRotation1();
diff --git a/src/main/java/dan200/computercraft/fabric/mixin/MixinWorld.java b/src/main/java/dan200/computercraft/fabric/mixin/MixinWorld.java
index 4d8c34bf0..75bc831cf 100644
--- a/src/main/java/dan200/computercraft/fabric/mixin/MixinWorld.java
+++ b/src/main/java/dan200/computercraft/fabric/mixin/MixinWorld.java
@@ -32,7 +32,7 @@ public class MixinWorld
@Inject( method = "setBlockEntity", at = @At( "HEAD" ) )
public void setBlockEntity( BlockPos pos, @Nullable BlockEntity entity, CallbackInfo info )
{
- if( !World.isOutOfBuildLimitVertically( pos ) && entity != null && !entity.isRemoved() && iteratingTickingBlockEntities )
+ if( entity != null && !entity.isRemoved() && entity.getWorld().isInBuildLimit(pos) && iteratingTickingBlockEntities )
{
setWorld( entity, this );
}
@@ -42,7 +42,7 @@ public class MixinWorld
{
if( entity.getWorld() != world && entity instanceof TileGeneric )
{
- entity.setLocation( (World) world, entity.getPos() );
+// entity.setLocation( (World) world, entity.getPos() ); //TODO why?
}
}
diff --git a/src/main/java/dan200/computercraft/shared/BundledRedstone.java b/src/main/java/dan200/computercraft/shared/BundledRedstone.java
index 8c8be9b79..471858693 100644
--- a/src/main/java/dan200/computercraft/shared/BundledRedstone.java
+++ b/src/main/java/dan200/computercraft/shared/BundledRedstone.java
@@ -32,7 +32,7 @@ public final class BundledRedstone
public static int getDefaultOutput( @Nonnull World world, @Nonnull BlockPos pos, @Nonnull Direction side )
{
- return World.isInBuildLimit( pos ) ? DefaultBundledRedstoneProvider.getDefaultBundledRedstoneOutput( world, pos, side ) : -1;
+ return !world.isInBuildLimit( pos ) ? DefaultBundledRedstoneProvider.getDefaultBundledRedstoneOutput( world, pos, side ) : -1;
}
public static int getOutput( World world, BlockPos pos, Direction side )
@@ -43,7 +43,7 @@ public final class BundledRedstone
private static int getUnmaskedOutput( World world, BlockPos pos, Direction side )
{
- if( !World.isInBuildLimit( pos ) )
+ if( !world.isInBuildLimit( pos ) )
{
return -1;
}
diff --git a/src/main/java/dan200/computercraft/shared/ComputerCraftRegistry.java b/src/main/java/dan200/computercraft/shared/ComputerCraftRegistry.java
index 3e45b482f..faee5795c 100644
--- a/src/main/java/dan200/computercraft/shared/ComputerCraftRegistry.java
+++ b/src/main/java/dan200/computercraft/shared/ComputerCraftRegistry.java
@@ -43,6 +43,7 @@ import dan200.computercraft.shared.turtle.inventory.ContainerTurtle;
import dan200.computercraft.shared.turtle.items.ItemTurtle;
import dan200.computercraft.shared.turtle.upgrades.*;
import dan200.computercraft.shared.util.FixedPointTileEntityType;
+import net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityTypeBuilder;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.screenhandler.v1.ScreenHandlerRegistry;
import net.minecraft.block.AbstractBlock;
@@ -151,19 +152,19 @@ public final class ComputerCraftRegistry
public static final BlockEntityType MONITOR_NORMAL = ofBlock( () -> ModBlocks.MONITOR_NORMAL,
"monitor_normal",
- f -> new TileMonitor( f, false ) );
+ f -> new TileMonitor( f, false, null, null ) );
public static final BlockEntityType MONITOR_ADVANCED = ofBlock( () -> ModBlocks.MONITOR_ADVANCED,
"monitor_advanced",
- f -> new TileMonitor( f, true ) );
+ f -> new TileMonitor( f, true, null, null ) );
public static final BlockEntityType COMPUTER_NORMAL = ofBlock( () -> ModBlocks.COMPUTER_NORMAL,
"computer_normal",
- f -> new TileComputer( ComputerFamily.NORMAL, f ) );
+ f -> new TileComputer( ComputerFamily.NORMAL, f, null, null ) );
public static final BlockEntityType COMPUTER_ADVANCED = ofBlock( () -> ModBlocks.COMPUTER_ADVANCED,
"computer_advanced",
- f -> new TileComputer( ComputerFamily.ADVANCED, f ) );
+ f -> new TileComputer( ComputerFamily.ADVANCED, f, null, null ) );
public static final BlockEntityType COMPUTER_COMMAND = ofBlock( () -> ModBlocks.COMPUTER_COMMAND,
"computer_command",
- f -> new TileCommandComputer( ComputerFamily.COMMAND, f ) );
+ f -> new TileCommandComputer( ComputerFamily.COMMAND, f, null, null ) );
public static final BlockEntityType TURTLE_NORMAL = ofBlock( () -> ModBlocks.TURTLE_NORMAL,
"turtle_normal",
f -> new TileTurtle( f, ComputerFamily.NORMAL ) );
@@ -179,16 +180,17 @@ public final class ComputerCraftRegistry
public static final BlockEntityType CABLE = ofBlock( () -> ModBlocks.CABLE, "cable", TileCable::new );
public static final BlockEntityType WIRELESS_MODEM_NORMAL = ofBlock( () -> ModBlocks.WIRELESS_MODEM_NORMAL,
"wireless_modem_normal",
- f -> new TileWirelessModem( f, false ) );
+ f -> new TileWirelessModem( f, false, null, null ) );
public static final BlockEntityType WIRELESS_MODEM_ADVANCED = ofBlock( () -> ModBlocks.WIRELESS_MODEM_ADVANCED,
"wireless_modem_advanced",
f -> new TileWirelessModem( f, true ) );
private static BlockEntityType ofBlock( Supplier block, String id, Function, T> factory )
{
+ FabricBlockEntityTypeBuilder.create(factory, block);
return Registry.register( BLOCK_ENTITY_TYPE,
new Identifier( MOD_ID, id ),
- FixedPointTileEntityType.create( Objects.requireNonNull( block ), factory ) );
+ FabricBlockEntityTypeBuilder.create);
}
}
diff --git a/src/main/java/dan200/computercraft/shared/Peripherals.java b/src/main/java/dan200/computercraft/shared/Peripherals.java
index 38fc5676e..4cab4a12a 100644
--- a/src/main/java/dan200/computercraft/shared/Peripherals.java
+++ b/src/main/java/dan200/computercraft/shared/Peripherals.java
@@ -35,7 +35,7 @@ public final class Peripherals
@Nullable
public static IPeripheral getPeripheral( World world, BlockPos pos, Direction side )
{
- return World.isInBuildLimit( pos ) && !world.isClient ? getPeripheralAt( world, pos, side ) : null;
+ return world.isInBuildLimit( pos ) && !world.isClient ? getPeripheralAt( world, pos, side ) : null;
}
@Nullable
diff --git a/src/main/java/dan200/computercraft/shared/command/CommandComputerCraft.java b/src/main/java/dan200/computercraft/shared/command/CommandComputerCraft.java
index 41c593766..e10a31cc7 100644
--- a/src/main/java/dan200/computercraft/shared/command/CommandComputerCraft.java
+++ b/src/main/java/dan200/computercraft/shared/command/CommandComputerCraft.java
@@ -182,7 +182,7 @@ public final class CommandComputerCraft
ServerPlayerEntity player = (ServerPlayerEntity) entity;
if( player.getEntityWorld() == world )
{
- player.networkHandler.teleportRequest(
+ player.networkHandler.requestTeleport(
pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, 0, 0,
EnumSet.noneOf( PlayerPositionLookS2CPacket.Flag.class )
);
diff --git a/src/main/java/dan200/computercraft/shared/common/BlockGeneric.java b/src/main/java/dan200/computercraft/shared/common/BlockGeneric.java
index 4781320ac..f93a40494 100644
--- a/src/main/java/dan200/computercraft/shared/common/BlockGeneric.java
+++ b/src/main/java/dan200/computercraft/shared/common/BlockGeneric.java
@@ -94,8 +94,8 @@ public abstract class BlockGeneric extends BlockWithEntity
@Nullable
@Override
- public BlockEntity createBlockEntity( @Nonnull BlockView world )
+ public BlockEntity createBlockEntity(BlockPos pos, BlockState state)
{
- return type.instantiate();
+ return type.instantiate(pos, state);
}
}
diff --git a/src/main/java/dan200/computercraft/shared/common/ClientTerminal.java b/src/main/java/dan200/computercraft/shared/common/ClientTerminal.java
index be189e35e..ae0433e11 100644
--- a/src/main/java/dan200/computercraft/shared/common/ClientTerminal.java
+++ b/src/main/java/dan200/computercraft/shared/common/ClientTerminal.java
@@ -8,7 +8,7 @@ package dan200.computercraft.shared.common;
import dan200.computercraft.core.terminal.Terminal;
import dan200.computercraft.shared.network.client.TerminalState;
-import net.minecraft.nbt.CompoundTag;
+import net.minecraft.nbt.NbtCompound;
public class ClientTerminal implements ITerminal
{
@@ -80,12 +80,12 @@ public class ClientTerminal implements ITerminal
}
}
- public void readDescription( CompoundTag nbt )
+ public void readDescription( NbtCompound nbt )
{
colour = nbt.getBoolean( "colour" );
if( nbt.contains( "terminal" ) )
{
- CompoundTag terminal = nbt.getCompound( "terminal" );
+ NbtCompound terminal = nbt.getCompound( "terminal" );
resizeTerminal( terminal.getInt( "term_width" ), terminal.getInt( "term_height" ) );
this.terminal.readFromNBT( terminal );
}
diff --git a/src/main/java/dan200/computercraft/shared/common/IColouredItem.java b/src/main/java/dan200/computercraft/shared/common/IColouredItem.java
index d654d9466..04b82d567 100644
--- a/src/main/java/dan200/computercraft/shared/common/IColouredItem.java
+++ b/src/main/java/dan200/computercraft/shared/common/IColouredItem.java
@@ -7,7 +7,7 @@
package dan200.computercraft.shared.common;
import net.minecraft.item.ItemStack;
-import net.minecraft.nbt.CompoundTag;
+import net.minecraft.nbt.NbtCompound;
public interface IColouredItem
{
@@ -20,7 +20,7 @@ public interface IColouredItem
static int getColourBasic( ItemStack stack )
{
- CompoundTag tag = stack.getTag();
+ NbtCompound tag = stack.getTag();
return tag != null && tag.contains( NBT_COLOUR ) ? tag.getInt( NBT_COLOUR ) : -1;
}
@@ -35,7 +35,7 @@ public interface IColouredItem
{
if( colour == -1 )
{
- CompoundTag tag = stack.getTag();
+ NbtCompound tag = stack.getTag();
if( tag != null )
{
tag.remove( NBT_COLOUR );
diff --git a/src/main/java/dan200/computercraft/shared/common/ServerTerminal.java b/src/main/java/dan200/computercraft/shared/common/ServerTerminal.java
index 6a95c9e5b..b53b4963f 100644
--- a/src/main/java/dan200/computercraft/shared/common/ServerTerminal.java
+++ b/src/main/java/dan200/computercraft/shared/common/ServerTerminal.java
@@ -8,7 +8,7 @@ package dan200.computercraft.shared.common;
import dan200.computercraft.core.terminal.Terminal;
import dan200.computercraft.shared.network.client.TerminalState;
-import net.minecraft.nbt.CompoundTag;
+import net.minecraft.nbt.NbtCompound;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -85,12 +85,12 @@ public class ServerTerminal implements ITerminal
return new TerminalState( colour, terminal );
}
- public void writeDescription( CompoundTag nbt )
+ public void writeDescription( NbtCompound nbt )
{
nbt.putBoolean( "colour", colour );
if( terminal != null )
{
- CompoundTag terminal = new CompoundTag();
+ NbtCompound terminal = new NbtCompound();
terminal.putInt( "term_width", this.terminal.getWidth() );
terminal.putInt( "term_height", this.terminal.getHeight() );
this.terminal.writeToNBT( terminal );
diff --git a/src/main/java/dan200/computercraft/shared/common/TileGeneric.java b/src/main/java/dan200/computercraft/shared/common/TileGeneric.java
index 9690ef44c..787a18442 100644
--- a/src/main/java/dan200/computercraft/shared/common/TileGeneric.java
+++ b/src/main/java/dan200/computercraft/shared/common/TileGeneric.java
@@ -11,7 +11,7 @@ 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.nbt.CompoundTag;
+import net.minecraft.nbt.NbtCompound;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
@@ -21,9 +21,9 @@ import javax.annotation.Nonnull;
public abstract class TileGeneric extends BlockEntity implements BlockEntityClientSerializable
{
- public TileGeneric( BlockEntityType extends TileGeneric> type )
+ public TileGeneric( BlockEntityType extends TileGeneric> type, BlockPos pos, BlockState state )
{
- super( type );
+ super( type, pos, state );
}
public void destroy()
@@ -82,23 +82,23 @@ public abstract class TileGeneric extends BlockEntity implements BlockEntityClie
}
@Override
- public void fromClientTag( CompoundTag compoundTag )
+ public void fromClientTag( NbtCompound compoundTag )
{
readDescription( compoundTag );
}
- protected void readDescription( @Nonnull CompoundTag nbt )
+ protected void readDescription( @Nonnull NbtCompound nbt )
{
}
@Override
- public CompoundTag toClientTag( CompoundTag compoundTag )
+ public NbtCompound toClientTag( NbtCompound compoundTag )
{
writeDescription( compoundTag );
return compoundTag;
}
- protected void writeDescription( @Nonnull CompoundTag nbt )
+ protected void writeDescription( @Nonnull NbtCompound nbt )
{
}
}
diff --git a/src/main/java/dan200/computercraft/shared/computer/apis/CommandAPI.java b/src/main/java/dan200/computercraft/shared/computer/apis/CommandAPI.java
index 290daff6e..a739044e2 100644
--- a/src/main/java/dan200/computercraft/shared/computer/apis/CommandAPI.java
+++ b/src/main/java/dan200/computercraft/shared/computer/apis/CommandAPI.java
@@ -16,7 +16,7 @@ import dan200.computercraft.shared.util.NBTUtil;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
-import net.minecraft.nbt.CompoundTag;
+import net.minecraft.nbt.NbtCompound;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.command.CommandManager;
import net.minecraft.server.command.ServerCommandSource;
@@ -204,7 +204,7 @@ public class CommandAPI implements ILuaAPI
World world = computer.getWorld();
BlockPos min = new BlockPos( Math.min( minX, maxX ), Math.min( minY, maxY ), Math.min( minZ, maxZ ) );
BlockPos max = new BlockPos( Math.max( minX, maxX ), Math.max( minY, maxY ), Math.max( minZ, maxZ ) );
- if( !World.isInBuildLimit( min ) || !World.isInBuildLimit( max ) )
+ if( !world.isInBuildLimit( min ) || !world.isInBuildLimit( max ) )
{
throw new LuaException( "Co-ordinates out of range" );
}
@@ -252,7 +252,7 @@ public class CommandAPI implements ILuaAPI
BlockEntity tile = world.getBlockEntity( pos );
if( tile != null )
{
- table.put( "nbt", NBTUtil.toLua( tile.toTag( new CompoundTag() ) ) );
+ table.put( "nbt", NBTUtil.toLua( tile.writeNbt( new NbtCompound() ) ) );
}
return table;
@@ -289,7 +289,7 @@ public class CommandAPI implements ILuaAPI
// Get the details of the block
World world = computer.getWorld();
BlockPos position = new BlockPos( x, y, z );
- if( World.isInBuildLimit( position ) )
+ if( world.isInBuildLimit( position ) )
{
return getBlockInfo( world, position );
}
diff --git a/src/main/java/dan200/computercraft/shared/computer/blocks/TileCommandComputer.java b/src/main/java/dan200/computercraft/shared/computer/blocks/TileCommandComputer.java
index 60dd39182..c9cc998e1 100644
--- a/src/main/java/dan200/computercraft/shared/computer/blocks/TileCommandComputer.java
+++ b/src/main/java/dan200/computercraft/shared/computer/blocks/TileCommandComputer.java
@@ -10,6 +10,7 @@ import dan200.computercraft.ComputerCraft;
import dan200.computercraft.shared.computer.apis.CommandAPI;
import dan200.computercraft.shared.computer.core.ComputerFamily;
import dan200.computercraft.shared.computer.core.ServerComputer;
+import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.server.MinecraftServer;
@@ -19,6 +20,7 @@ import net.minecraft.server.world.ServerWorld;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
+import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec2f;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.GameRules;
@@ -32,9 +34,9 @@ public class TileCommandComputer extends TileComputer
{
private final CommandReceiver receiver;
- public TileCommandComputer( ComputerFamily family, BlockEntityType extends TileCommandComputer> type )
+ public TileCommandComputer( ComputerFamily family, BlockEntityType extends TileCommandComputer> type, BlockPos pos, BlockState state )
{
- super( family, type );
+ super( family, type, pos, state );
receiver = new CommandReceiver();
}
diff --git a/src/main/java/dan200/computercraft/shared/computer/blocks/TileComputer.java b/src/main/java/dan200/computercraft/shared/computer/blocks/TileComputer.java
index 078a9925a..0ace27064 100644
--- a/src/main/java/dan200/computercraft/shared/computer/blocks/TileComputer.java
+++ b/src/main/java/dan200/computercraft/shared/computer/blocks/TileComputer.java
@@ -17,6 +17,7 @@ import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.screen.ScreenHandler;
+import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import javax.annotation.Nonnull;
@@ -26,9 +27,9 @@ public class TileComputer extends TileComputerBase
{
private ComputerProxy proxy;
- public TileComputer( ComputerFamily family, BlockEntityType extends TileComputer> type )
+ public TileComputer( ComputerFamily family, BlockEntityType extends TileComputer> type, BlockPos pos, BlockState state )
{
- super( type, family );
+ super( type, family, pos, state );
}
public boolean isUsableByPlayer( PlayerEntity player )
diff --git a/src/main/java/dan200/computercraft/shared/computer/blocks/TileComputerBase.java b/src/main/java/dan200/computercraft/shared/computer/blocks/TileComputerBase.java
index e4104daa6..549f56b47 100644
--- a/src/main/java/dan200/computercraft/shared/computer/blocks/TileComputerBase.java
+++ b/src/main/java/dan200/computercraft/shared/computer/blocks/TileComputerBase.java
@@ -17,6 +17,7 @@ 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.network.container.ComputerContainerData;
+import dan200.computercraft.shared.peripheral.diskdrive.TileDiskDrive;
import dan200.computercraft.shared.util.DirectionUtil;
import dan200.computercraft.shared.util.RedstoneUtil;
import joptsimple.internal.Strings;
@@ -28,7 +29,7 @@ import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
-import net.minecraft.nbt.CompoundTag;
+import net.minecraft.nbt.NbtCompound;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.LiteralText;
@@ -37,7 +38,6 @@ import net.minecraft.text.TranslatableText;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.Nameable;
-import net.minecraft.util.Tickable;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
@@ -47,7 +47,7 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Objects;
-public abstract class TileComputerBase extends TileGeneric implements IComputerTile, Tickable, IPeripheralTile, Nameable,
+public abstract class TileComputerBase extends TileGeneric implements IComputerTile, IPeripheralTile, Nameable,
ExtendedScreenHandlerFactory
{
private static final String NBT_ID = "ComputerId";
@@ -61,9 +61,9 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT
private boolean on = false;
private boolean fresh = false;
- public TileComputerBase( BlockEntityType extends TileGeneric> type, ComputerFamily family )
+ public TileComputerBase( BlockEntityType extends TileGeneric> type, ComputerFamily family, BlockPos pos, BlockState state )
{
- super( type );
+ super( type, pos, state );
this.family = family;
}
@@ -250,7 +250,7 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT
}
@Override
- protected void readDescription( @Nonnull CompoundTag nbt )
+ protected void readDescription( @Nonnull NbtCompound nbt )
{
super.readDescription( nbt );
label = nbt.contains( NBT_LABEL ) ? nbt.getString( NBT_LABEL ) : null;
@@ -258,7 +258,7 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT
}
@Override
- protected void writeDescription( @Nonnull CompoundTag nbt )
+ protected void writeDescription( @Nonnull NbtCompound nbt )
{
super.writeDescription( nbt );
if( label != null )
@@ -271,43 +271,42 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT
}
}
- @Override
- public void tick()
+ public static void tick( World world, BlockPos pos, BlockState state, TileComputerBase tileComputerBase )
{
- if( !getWorld().isClient )
+ if( !world.isClient )
{
- ServerComputer computer = createServerComputer();
+ ServerComputer computer = tileComputerBase.createServerComputer();
if( computer == null )
{
return;
}
// If the computer isn't on and should be, then turn it on
- if( startOn || (fresh && on) )
+ if( tileComputerBase.startOn || (tileComputerBase.fresh && tileComputerBase.on) )
{
computer.turnOn();
- startOn = false;
+ tileComputerBase.startOn = false;
}
computer.keepAlive();
- fresh = false;
- computerID = computer.getID();
- label = computer.getLabel();
- on = computer.isOn();
+ tileComputerBase.fresh = false;
+ tileComputerBase.computerID = computer.getID();
+ tileComputerBase.label = computer.getLabel();
+ tileComputerBase.on = computer.isOn();
if( computer.hasOutputChanged() )
{
- updateOutput();
+ tileComputerBase.updateOutput();
}
// Update the block state if needed. We don't fire a block update intentionally,
// as this only really is needed on the client side.
- updateBlockState( computer.getState() );
+ tileComputerBase.updateBlockState( computer.getState() );
if( computer.hasOutputChanged() )
{
- updateOutput();
+ tileComputerBase.updateOutput();
}
}
}
@@ -325,9 +324,9 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT
protected abstract void updateBlockState( ComputerState newState );
@Override
- public void fromTag( @Nonnull BlockState state, @Nonnull CompoundTag nbt )
+ public void readNbt( @Nonnull NbtCompound nbt )
{
- super.fromTag( state, nbt );
+ super.readNbt( nbt );
// Load ID, label and power state
computerID = nbt.contains( NBT_ID ) ? nbt.getInt( NBT_ID ) : -1;
@@ -337,8 +336,9 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT
@Nonnull
@Override
- public CompoundTag toTag( @Nonnull CompoundTag nbt )
+ public NbtCompound writeNbt( @Nonnull NbtCompound nbt )
{
+ super.writeNbt( nbt );
// Save ID, label and power state
if( computerID >= 0 )
{
@@ -349,8 +349,7 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT
nbt.putString( NBT_LABEL, label );
}
nbt.putBoolean( NBT_ON, on );
-
- return super.toTag( nbt );
+ return nbt;
}
@Override
@@ -362,7 +361,7 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT
private void updateInput( BlockPos neighbour )
{
- if( getWorld() == null || getWorld().isClient )
+ if( getWorld() == null || this.world.isClient )
{
return;
}
@@ -384,12 +383,12 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT
}
// If the position is not any adjacent one, update all inputs.
- updateInput();
+ this.updateInput();
}
private void updateInput( Direction dir )
{
- if( getWorld() == null || getWorld().isClient )
+ if( getWorld() == null || this.world.isClient )
{
return;
}
@@ -412,7 +411,7 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT
@Override
public final void setComputerID( int id )
{
- if( getWorld().isClient || computerID == id )
+ if( this.world.isClient || computerID == id )
{
return;
}
@@ -437,7 +436,7 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT
@Override
public final void setLabel( String label )
{
- if( getWorld().isClient || Objects.equals( this.label, label ) )
+ if( this.world.isClient || Objects.equals( this.label, label ) )
{
return;
}
diff --git a/src/main/java/dan200/computercraft/shared/computer/core/ClientComputer.java b/src/main/java/dan200/computercraft/shared/computer/core/ClientComputer.java
index df0a18625..615b65eef 100644
--- a/src/main/java/dan200/computercraft/shared/computer/core/ClientComputer.java
+++ b/src/main/java/dan200/computercraft/shared/computer/core/ClientComputer.java
@@ -9,7 +9,7 @@ package dan200.computercraft.shared.computer.core;
import dan200.computercraft.shared.common.ClientTerminal;
import dan200.computercraft.shared.network.NetworkHandler;
import dan200.computercraft.shared.network.server.*;
-import net.minecraft.nbt.CompoundTag;
+import net.minecraft.nbt.NbtCompound;
public class ClientComputer extends ClientTerminal implements IComputer
{
@@ -17,7 +17,7 @@ public class ClientComputer extends ClientTerminal implements IComputer
private boolean on = false;
private boolean blinking = false;
- private CompoundTag userData = null;
+ private NbtCompound userData = null;
public ClientComputer( int instanceID )
@@ -26,7 +26,7 @@ public class ClientComputer extends ClientTerminal implements IComputer
this.instanceID = instanceID;
}
- public CompoundTag getUserData()
+ public NbtCompound getUserData()
{
return userData;
}
@@ -123,7 +123,7 @@ public class ClientComputer extends ClientTerminal implements IComputer
NetworkHandler.sendToServer( new MouseEventServerMessage( instanceID, MouseEventServerMessage.TYPE_SCROLL, direction, x, y ) );
}
- public void setState( ComputerState state, CompoundTag userData )
+ public void setState( ComputerState state, NbtCompound userData )
{
on = state != ComputerState.OFF;
blinking = state == ComputerState.BLINKING;
diff --git a/src/main/java/dan200/computercraft/shared/computer/core/ServerComputer.java b/src/main/java/dan200/computercraft/shared/computer/core/ServerComputer.java
index 3bbf9bd20..8204424c9 100644
--- a/src/main/java/dan200/computercraft/shared/computer/core/ServerComputer.java
+++ b/src/main/java/dan200/computercraft/shared/computer/core/ServerComputer.java
@@ -25,7 +25,7 @@ import dan200.computercraft.shared.network.client.ComputerDeletedClientMessage;
import dan200.computercraft.shared.network.client.ComputerTerminalClientMessage;
import me.shedaniel.cloth.api.utils.v1.GameInstanceUtils;
import net.minecraft.entity.player.PlayerEntity;
-import net.minecraft.nbt.CompoundTag;
+import net.minecraft.nbt.NbtCompound;
import net.minecraft.screen.ScreenHandler;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.math.BlockPos;
@@ -42,7 +42,7 @@ public class ServerComputer extends ServerTerminal implements IComputer, IComput
private final Computer computer;
private World world;
private BlockPos position;
- private CompoundTag userData;
+ private NbtCompound userData;
private boolean changed;
private boolean changedLastFrame;
@@ -128,11 +128,11 @@ public class ServerComputer extends ServerTerminal implements IComputer, IComput
computer.unload();
}
- public CompoundTag getUserData()
+ public NbtCompound getUserData()
{
if( userData == null )
{
- userData = new CompoundTag();
+ userData = new NbtCompound();
}
return userData;
}
diff --git a/src/main/java/dan200/computercraft/shared/computer/items/IComputerItem.java b/src/main/java/dan200/computercraft/shared/computer/items/IComputerItem.java
index 1b802e19d..fd4d6bf51 100644
--- a/src/main/java/dan200/computercraft/shared/computer/items/IComputerItem.java
+++ b/src/main/java/dan200/computercraft/shared/computer/items/IComputerItem.java
@@ -8,7 +8,7 @@ package dan200.computercraft.shared.computer.items;
import dan200.computercraft.shared.computer.core.ComputerFamily;
import net.minecraft.item.ItemStack;
-import net.minecraft.nbt.CompoundTag;
+import net.minecraft.nbt.NbtCompound;
import javax.annotation.Nonnull;
@@ -18,7 +18,7 @@ public interface IComputerItem
default int getComputerID( @Nonnull ItemStack stack )
{
- CompoundTag nbt = stack.getTag();
+ NbtCompound nbt = stack.getTag();
return nbt != null && nbt.contains( NBT_ID ) ? nbt.getInt( NBT_ID ) : -1;
}
diff --git a/src/main/java/dan200/computercraft/shared/computer/recipe/ComputerFamilyRecipe.java b/src/main/java/dan200/computercraft/shared/computer/recipe/ComputerFamilyRecipe.java
index 4e9342a49..d882505f9 100644
--- a/src/main/java/dan200/computercraft/shared/computer/recipe/ComputerFamilyRecipe.java
+++ b/src/main/java/dan200/computercraft/shared/computer/recipe/ComputerFamilyRecipe.java
@@ -45,7 +45,7 @@ public abstract class ComputerFamilyRecipe extends ComputerConvertRecipe
ComputerFamily family = RecipeUtil.getFamily( json, "family" );
RecipeUtil.ShapedTemplate template = RecipeUtil.getTemplate( json );
- ItemStack result = getItemStack( JsonHelper.getObject( json, "result" ) );
+ ItemStack result = outputFromJson( JsonHelper.getObject( json, "result" ) );
return create( identifier, group, template.width, template.height, template.ingredients, result, family );
}
@@ -78,7 +78,7 @@ public abstract class ComputerFamilyRecipe extends ComputerConvertRecipe
buf.writeVarInt( recipe.getWidth() );
buf.writeVarInt( recipe.getHeight() );
buf.writeString( recipe.getGroup() );
- for( Ingredient ingredient : recipe.getPreviewInputs() )
+ for( Ingredient ingredient : recipe.getIngredients() )
{
ingredient.write( buf );
}
diff --git a/src/main/java/dan200/computercraft/shared/data/PlayerCreativeLootCondition.java b/src/main/java/dan200/computercraft/shared/data/PlayerCreativeLootCondition.java
index e52690853..debdffb46 100644
--- a/src/main/java/dan200/computercraft/shared/data/PlayerCreativeLootCondition.java
+++ b/src/main/java/dan200/computercraft/shared/data/PlayerCreativeLootCondition.java
@@ -35,7 +35,7 @@ public final class PlayerCreativeLootCondition implements LootCondition
public boolean test( LootContext lootContext )
{
Entity entity = lootContext.get( LootContextParameters.THIS_ENTITY );
- return entity instanceof PlayerEntity && ((PlayerEntity) entity).abilities.creativeMode;
+ return entity instanceof PlayerEntity && ((PlayerEntity) entity).getAbilities().creativeMode;
}
@Nonnull
diff --git a/src/main/java/dan200/computercraft/shared/media/items/ItemDisk.java b/src/main/java/dan200/computercraft/shared/media/items/ItemDisk.java
index a858fd6c4..650360e86 100644
--- a/src/main/java/dan200/computercraft/shared/media/items/ItemDisk.java
+++ b/src/main/java/dan200/computercraft/shared/media/items/ItemDisk.java
@@ -17,7 +17,7 @@ import net.minecraft.client.item.TooltipContext;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
-import net.minecraft.nbt.CompoundTag;
+import net.minecraft.nbt.NbtCompound;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
@@ -85,7 +85,7 @@ public class ItemDisk extends Item implements IMedia, IColouredItem
public static int getDiskID( @Nonnull ItemStack stack )
{
- CompoundTag nbt = stack.getTag();
+ NbtCompound nbt = stack.getTag();
return nbt != null && nbt.contains( NBT_ID ) ? nbt.getInt( NBT_ID ) : -1;
}
diff --git a/src/main/java/dan200/computercraft/shared/media/items/ItemPrintout.java b/src/main/java/dan200/computercraft/shared/media/items/ItemPrintout.java
index 77a15ef4e..aabd204b9 100644
--- a/src/main/java/dan200/computercraft/shared/media/items/ItemPrintout.java
+++ b/src/main/java/dan200/computercraft/shared/media/items/ItemPrintout.java
@@ -13,7 +13,7 @@ import net.minecraft.client.item.TooltipContext;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
-import net.minecraft.nbt.CompoundTag;
+import net.minecraft.nbt.NbtCompound;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import net.minecraft.util.ActionResult;
@@ -60,7 +60,7 @@ public class ItemPrintout extends Item
}
if( text != null )
{
- CompoundTag tag = stack.getOrCreateTag();
+ NbtCompound tag = stack.getOrCreateTag();
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 )
{
- CompoundTag tag = stack.getOrCreateTag();
+ NbtCompound tag = stack.getOrCreateTag();
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 )
{
- CompoundTag nbt = stack.getTag();
+ NbtCompound nbt = stack.getTag();
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 )
{
- CompoundTag nbt = stack.getTag();
+ NbtCompound nbt = stack.getTag();
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 )
{
- CompoundTag nbt = stack.getTag();
+ NbtCompound nbt = stack.getTag();
return nbt != null && nbt.contains( NBT_TITLE ) ? nbt.getString( NBT_TITLE ) : null;
}
diff --git a/src/main/java/dan200/computercraft/shared/media/items/ItemTreasureDisk.java b/src/main/java/dan200/computercraft/shared/media/items/ItemTreasureDisk.java
index 7e0783999..44e28960f 100644
--- a/src/main/java/dan200/computercraft/shared/media/items/ItemTreasureDisk.java
+++ b/src/main/java/dan200/computercraft/shared/media/items/ItemTreasureDisk.java
@@ -16,7 +16,7 @@ import net.minecraft.client.item.TooltipContext;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
-import net.minecraft.nbt.CompoundTag;
+import net.minecraft.nbt.NbtCompound;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import net.minecraft.util.collection.DefaultedList;
@@ -41,7 +41,7 @@ public class ItemTreasureDisk extends Item implements IMedia
public static ItemStack create( String subPath, int colourIndex )
{
ItemStack result = new ItemStack( ComputerCraftRegistry.ModItems.TREASURE_DISK );
- CompoundTag nbt = result.getOrCreateTag();
+ NbtCompound nbt = result.getOrCreateTag();
nbt.putString( NBT_SUB_PATH, subPath );
int slash = subPath.indexOf( '/' );
@@ -62,7 +62,7 @@ public class ItemTreasureDisk extends Item implements IMedia
public static int getColour( @Nonnull ItemStack stack )
{
- CompoundTag nbt = stack.getTag();
+ NbtCompound nbt = stack.getTag();
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 )
{
- CompoundTag nbt = stack.getTag();
+ NbtCompound nbt = stack.getTag();
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 )
{
- CompoundTag nbt = stack.getTag();
+ NbtCompound nbt = stack.getTag();
return nbt != null && nbt.contains( NBT_SUB_PATH ) ? nbt.getString( NBT_SUB_PATH ) : "dan200/alongtimeago";
}
}
diff --git a/src/main/java/dan200/computercraft/shared/network/client/ComputerDataClientMessage.java b/src/main/java/dan200/computercraft/shared/network/client/ComputerDataClientMessage.java
index ae04c5310..568338fe1 100644
--- a/src/main/java/dan200/computercraft/shared/network/client/ComputerDataClientMessage.java
+++ b/src/main/java/dan200/computercraft/shared/network/client/ComputerDataClientMessage.java
@@ -9,7 +9,7 @@ package dan200.computercraft.shared.network.client;
import dan200.computercraft.shared.computer.core.ComputerState;
import dan200.computercraft.shared.computer.core.ServerComputer;
import net.fabricmc.fabric.api.network.PacketContext;
-import net.minecraft.nbt.CompoundTag;
+import net.minecraft.nbt.NbtCompound;
import net.minecraft.network.PacketByteBuf;
import javax.annotation.Nonnull;
@@ -20,7 +20,7 @@ import javax.annotation.Nonnull;
public class ComputerDataClientMessage extends ComputerClientMessage
{
private ComputerState state;
- private CompoundTag userData;
+ private NbtCompound userData;
public ComputerDataClientMessage( ServerComputer computer )
{
@@ -38,7 +38,7 @@ public class ComputerDataClientMessage extends ComputerClientMessage
{
super.toBytes( buf );
buf.writeEnumConstant( state );
- buf.writeCompoundTag( userData );
+ buf.writeNbt( userData );
}
@Override
@@ -46,7 +46,7 @@ public class ComputerDataClientMessage extends ComputerClientMessage
{
super.fromBytes( buf );
state = buf.readEnumConstant( ComputerState.class );
- userData = buf.readCompoundTag();
+ userData = buf.readNbt();
}
@Override
diff --git a/src/main/java/dan200/computercraft/shared/network/server/QueueEventServerMessage.java b/src/main/java/dan200/computercraft/shared/network/server/QueueEventServerMessage.java
index d5efb130e..69f94a300 100644
--- a/src/main/java/dan200/computercraft/shared/network/server/QueueEventServerMessage.java
+++ b/src/main/java/dan200/computercraft/shared/network/server/QueueEventServerMessage.java
@@ -9,7 +9,7 @@ package dan200.computercraft.shared.network.server;
import dan200.computercraft.shared.computer.core.IContainerComputer;
import dan200.computercraft.shared.computer.core.ServerComputer;
import dan200.computercraft.shared.util.NBTUtil;
-import net.minecraft.nbt.CompoundTag;
+import net.minecraft.nbt.NbtCompound;
import net.minecraft.network.PacketByteBuf;
import javax.annotation.Nonnull;
@@ -42,7 +42,7 @@ public class QueueEventServerMessage extends ComputerServerMessage
{
super.toBytes( buf );
buf.writeString( event );
- buf.writeCompoundTag( args == null ? null : NBTUtil.encodeObjects( args ) );
+ buf.writeNbt( args == null ? null : NBTUtil.encodeObjects( args ) );
}
@Override
@@ -51,7 +51,7 @@ public class QueueEventServerMessage extends ComputerServerMessage
super.fromBytes( buf );
event = buf.readString( Short.MAX_VALUE );
- CompoundTag args = buf.readCompoundTag();
+ NbtCompound args = buf.readNbt();
this.args = args == null ? null : NBTUtil.decodeObjects( args );
}
diff --git a/src/main/java/dan200/computercraft/shared/peripheral/diskdrive/BlockDiskDrive.java b/src/main/java/dan200/computercraft/shared/peripheral/diskdrive/BlockDiskDrive.java
index 35ec91d6f..f04d00ae3 100644
--- a/src/main/java/dan200/computercraft/shared/peripheral/diskdrive/BlockDiskDrive.java
+++ b/src/main/java/dan200/computercraft/shared/peripheral/diskdrive/BlockDiskDrive.java
@@ -8,9 +8,13 @@ package dan200.computercraft.shared.peripheral.diskdrive;
import dan200.computercraft.shared.ComputerCraftRegistry;
import dan200.computercraft.shared.common.BlockGeneric;
+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;
+import net.minecraft.block.entity.BlockEntityTicker;
+import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemPlacementContext;
@@ -49,7 +53,13 @@ public class BlockDiskDrive extends BlockGeneric
placement.getPlayerFacing()
.getOpposite() );
}
-
+
+ @Nullable
+ @Override
+ public BlockEntityTicker getTicker(World world, BlockState state, BlockEntityType type){
+ return world.isClient ? null : BlockDiskDrive.checkType( type, ComputerCraftRegistry.ModTiles.DISK_DRIVE, TileDiskDrive::tick );
+ }
+
@Override
public void afterBreak(
@Nonnull World world, @Nonnull PlayerEntity player, @Nonnull BlockPos pos, @Nonnull BlockState state, @Nullable BlockEntity te, @Nonnull ItemStack stack
diff --git a/src/main/java/dan200/computercraft/shared/peripheral/diskdrive/TileDiskDrive.java b/src/main/java/dan200/computercraft/shared/peripheral/diskdrive/TileDiskDrive.java
index 4fafe3edd..bc2cabb6d 100644
--- a/src/main/java/dan200/computercraft/shared/peripheral/diskdrive/TileDiskDrive.java
+++ b/src/main/java/dan200/computercraft/shared/peripheral/diskdrive/TileDiskDrive.java
@@ -23,7 +23,7 @@ import net.minecraft.entity.ItemEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.item.ItemStack;
-import net.minecraft.nbt.CompoundTag;
+import net.minecraft.nbt.NbtCompound;
import net.minecraft.screen.NamedScreenHandlerFactory;
import net.minecraft.screen.ScreenHandler;
import net.minecraft.sound.SoundEvent;
@@ -32,10 +32,10 @@ import net.minecraft.text.TranslatableText;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.Nameable;
-import net.minecraft.util.Tickable;
import net.minecraft.util.hit.BlockHitResult;
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;
@@ -43,7 +43,7 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Set;
-public final class TileDiskDrive extends TileGeneric implements DefaultInventory, Tickable, IPeripheralTile, Nameable, NamedScreenHandlerFactory
+public final class TileDiskDrive extends TileGeneric implements DefaultInventory, IPeripheralTile, Nameable, NamedScreenHandlerFactory
{
private static final String NBT_NAME = "CustomName";
private static final String NBT_ITEM = "Item";
@@ -57,9 +57,9 @@ public final class TileDiskDrive extends TileGeneric implements DefaultInventory
private boolean restartRecord = false;
private boolean ejectQueued;
- public TileDiskDrive( BlockEntityType type )
+ public TileDiskDrive( BlockEntityType type, BlockPos pos, BlockState state )
{
- super( type );
+ super( type, pos, state );
}
@Override
@@ -108,22 +108,23 @@ public final class TileDiskDrive extends TileGeneric implements DefaultInventory
}
@Override
- public void fromTag( @Nonnull BlockState state, @Nonnull CompoundTag nbt )
+ public void readNbt( @Nonnull NbtCompound nbt )
{
- super.fromTag( state, nbt );
+ super.readNbt( nbt );
customName = nbt.contains( NBT_NAME ) ? Text.Serializer.fromJson( nbt.getString( NBT_NAME ) ) : null;
if( nbt.contains( NBT_ITEM ) )
{
- CompoundTag item = nbt.getCompound( NBT_ITEM );
- diskStack = ItemStack.fromTag( item );
+ NbtCompound item = nbt.getCompound( NBT_ITEM );
+ diskStack = ItemStack.fromNbt( item );
diskMount = null;
}
}
@Nonnull
@Override
- public CompoundTag toTag( @Nonnull CompoundTag nbt )
+ public NbtCompound writeNbt( @Nonnull NbtCompound nbt )
{
+ super.writeNbt( nbt );
if( customName != null )
{
nbt.putString( NBT_NAME, Text.Serializer.toJson( customName ) );
@@ -131,11 +132,11 @@ public final class TileDiskDrive extends TileGeneric implements DefaultInventory
if( !diskStack.isEmpty() )
{
- CompoundTag item = new CompoundTag();
- diskStack.toTag( item );
+ NbtCompound item = new NbtCompound();
+ diskStack.writeNbt( item );
nbt.put( NBT_ITEM, item );
}
- return super.toTag( nbt );
+ return nbt;
}
@Override
@@ -148,40 +149,39 @@ public final class TileDiskDrive extends TileGeneric implements DefaultInventory
super.markDirty();
}
- @Override
- public void tick()
+ public static void tick( World world, BlockPos pos, BlockState state, TileDiskDrive tileDiskDrive)
{
// Ejection
- if( ejectQueued )
+ if( tileDiskDrive.ejectQueued )
{
- ejectContents( false );
- ejectQueued = false;
+ tileDiskDrive.ejectContents( false );
+ tileDiskDrive.ejectQueued = false;
}
// Music
- synchronized( this )
+ synchronized( tileDiskDrive )
{
- if( !world.isClient && recordPlaying != recordQueued || restartRecord )
+ if( !world.isClient && tileDiskDrive.recordPlaying != tileDiskDrive.recordQueued || tileDiskDrive.restartRecord )
{
- restartRecord = false;
- if( recordQueued )
+ tileDiskDrive.restartRecord = false;
+ if( tileDiskDrive.recordQueued )
{
- IMedia contents = getDiskMedia();
- SoundEvent record = contents != null ? contents.getAudio( diskStack ) : null;
+ IMedia contents = tileDiskDrive.getDiskMedia();
+ SoundEvent record = contents != null ? contents.getAudio( tileDiskDrive.diskStack ) : null;
if( record != null )
{
- recordPlaying = true;
- playRecord();
+ tileDiskDrive.recordPlaying = true;
+ tileDiskDrive.playRecord();
}
else
{
- recordQueued = false;
+ tileDiskDrive.recordQueued = false;
}
}
else
{
- stopRecord();
- recordPlaying = false;
+ tileDiskDrive.stopRecord();
+ tileDiskDrive.recordPlaying = false;
}
}
}
@@ -479,7 +479,7 @@ public final class TileDiskDrive extends TileGeneric implements DefaultInventory
private synchronized void ejectContents( boolean destroyed )
{
- if( getWorld().isClient || diskStack.isEmpty() )
+ if( this.world.isClient || diskStack.isEmpty() )
{
return;
}
diff --git a/src/main/java/dan200/computercraft/shared/peripheral/generic/data/ItemData.java b/src/main/java/dan200/computercraft/shared/peripheral/generic/data/ItemData.java
index f96f36219..c48128802 100644
--- a/src/main/java/dan200/computercraft/shared/peripheral/generic/data/ItemData.java
+++ b/src/main/java/dan200/computercraft/shared/peripheral/generic/data/ItemData.java
@@ -12,12 +12,13 @@ import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.item.EnchantedBookItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
-import net.minecraft.nbt.CompoundTag;
-import net.minecraft.nbt.ListTag;
-import net.minecraft.nbt.Tag;
+import net.minecraft.nbt.NbtCompound;
+import net.minecraft.nbt.NbtList;
+import net.minecraft.nbt.NbtElement;
import net.minecraft.tag.ServerTagManagerHolder;
import net.minecraft.tag.TagGroup;
import net.minecraft.text.Text;
+import net.minecraft.util.registry.Registry;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@@ -71,19 +72,19 @@ 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- itemTags = ServerTagManagerHolder.getTagManager().getItems();
+ TagGroup
- 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() )
) ); // chaos x2
- CompoundTag tag = stack.getTag();
+ NbtCompound tag = stack.getTag();
if( tag != null && tag.contains( "display", NBTUtil.TAG_COMPOUND ) )
{
- CompoundTag displayTag = tag.getCompound( "display" );
+ NbtCompound displayTag = tag.getCompound( "display" );
if( displayTag.contains( "Lore", NBTUtil.TAG_LIST ) )
{
- ListTag loreTag = displayTag.getList( "Lore", NBTUtil.TAG_STRING );
+ NbtList loreTag = displayTag.getList( "Lore", NBTUtil.TAG_STRING );
data.put( "lore", loreTag.stream()
.map( ItemData::parseTextComponent )
.filter( Objects::nonNull )
@@ -112,7 +113,7 @@ public class ItemData
@Nullable
- private static Text parseTextComponent( @Nonnull Tag x )
+ private static Text parseTextComponent( @Nonnull NbtElement x )
{
try
{
@@ -138,7 +139,7 @@ public class ItemData
if( stack.getItem() instanceof EnchantedBookItem && (hideFlags & 32) == 0 )
{
- addEnchantments( EnchantedBookItem.getEnchantmentTag( stack ), enchants );
+ addEnchantments( EnchantedBookItem.getEnchantmentNbt( stack ), enchants );
}
if( stack.hasEnchantments() && (hideFlags & 1) == 0 )
@@ -161,14 +162,14 @@ public class ItemData
* @param enchants The enchantment map to add it to.
* @see EnchantmentHelper
*/
- private static void addEnchantments( @Nonnull ListTag rawEnchants, @Nonnull ArrayList