mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-10-28 20:37:38 +00:00
move remappedSrc to src/main/java
This commit is contained in:
@@ -9,6 +9,7 @@ package dan200.computercraft;
|
||||
import dan200.computercraft.api.turtle.event.TurtleAction;
|
||||
import dan200.computercraft.core.apis.http.options.Action;
|
||||
import dan200.computercraft.core.apis.http.options.AddressRule;
|
||||
import dan200.computercraft.shared.ComputerCraftRegistry.ModBlocks;
|
||||
import dan200.computercraft.shared.common.ColourableRecipe;
|
||||
import dan200.computercraft.shared.computer.core.ClientComputerRegistry;
|
||||
import dan200.computercraft.shared.computer.core.ServerComputerRegistry;
|
||||
|
||||
@@ -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.getNbt();
|
||||
NbtCompound craftingShareTag = crafting.getNbt();
|
||||
if( shareTag == craftingShareTag ) return true;
|
||||
if( shareTag == null ) return craftingShareTag.isEmpty();
|
||||
if( craftingShareTag == null ) return shareTag.isEmpty();
|
||||
|
||||
@@ -13,10 +13,9 @@ 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.client.util.math.MatrixStack;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import net.minecraft.util.math.AffineTransformation;
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -128,7 +128,7 @@ public class FakePlayer extends ServerPlayerEntity
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openEditBookScreen( ItemStack stack, Hand hand )
|
||||
public void useBook( ItemStack stack, Hand hand )
|
||||
{
|
||||
}
|
||||
|
||||
@@ -191,7 +191,7 @@ 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 )
|
||||
{
|
||||
}
|
||||
|
||||
@@ -216,7 +216,7 @@ public class FakePlayer extends ServerPlayerEntity
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGameMode( GameMode gameMode )
|
||||
public void changeGameMode( GameMode gameMode )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -14,8 +14,8 @@ 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.Identifier;
|
||||
import net.minecraft.util.math.AffineTransformation;
|
||||
import net.minecraft.util.math.Matrix4f;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
|
||||
@@ -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 );
|
||||
|
||||
|
||||
@@ -20,9 +20,9 @@ import net.minecraft.client.render.Tessellator;
|
||||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
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.Matrix4f;
|
||||
import net.minecraft.util.math.Vec3f;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import static dan200.computercraft.client.gui.FixedWidthFontRenderer.FONT_HEIGHT;
|
||||
@@ -64,8 +64,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 );
|
||||
|
||||
@@ -9,9 +9,9 @@ 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.item.ItemStack;
|
||||
import net.minecraft.util.math.Matrix4f;
|
||||
import net.minecraft.util.math.Vec3f;
|
||||
|
||||
import static dan200.computercraft.client.gui.FixedWidthFontRenderer.FONT_HEIGHT;
|
||||
import static dan200.computercraft.client.gui.FixedWidthFontRenderer.FONT_WIDTH;
|
||||
@@ -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 );
|
||||
|
||||
|
||||
@@ -12,9 +12,8 @@ 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.Matrix4f;
|
||||
|
||||
import net.minecraft.util.math.Vector4f;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -66,7 +65,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 +80,7 @@ public final class ModelTransformer
|
||||
vertexData[start + 1] = Float.floatToRawIntBits( pos.getY() );
|
||||
vertexData[start + 2] = Float.floatToRawIntBits( pos.getZ() );
|
||||
}
|
||||
offsetBytes += element.getSize();
|
||||
offsetBytes += element.getByteLength();
|
||||
}
|
||||
}
|
||||
return copy;
|
||||
|
||||
@@ -42,7 +42,7 @@ class MonitorTextureBufferShader
|
||||
static void setupUniform( Matrix4f transform, int width, int height, Palette palette, boolean greyscale )
|
||||
{
|
||||
MATRIX_BUFFER.rewind();
|
||||
transform.writeToBuffer( MATRIX_BUFFER );
|
||||
transform.writeColumnMajor( MATRIX_BUFFER );
|
||||
MATRIX_BUFFER.rewind();
|
||||
RenderSystem.glUniformMatrix4( uniformMv, false, MATRIX_BUFFER );
|
||||
|
||||
|
||||
@@ -21,12 +21,12 @@ 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.client.util.math.MatrixStack;
|
||||
import net.minecraft.client.util.math.Vector3f;
|
||||
import net.minecraft.util.math.AffineTransformation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.math.Matrix4f;
|
||||
import net.minecraft.util.math.Vec3f;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL13;
|
||||
import org.lwjgl.opengl.GL20;
|
||||
@@ -89,8 +89,8 @@ public class TileEntityMonitorRenderer extends BlockEntityRenderer<TileMonitor>
|
||||
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 );
|
||||
|
||||
@@ -26,14 +26,13 @@ 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.Identifier;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.hit.HitResult;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.math.Matrix4f;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
import net.minecraft.util.math.Vec3f;
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
@@ -147,7 +146,7 @@ public class TileEntityTurtleRenderer extends BlockEntityRenderer<TileTurtle>
|
||||
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 +188,7 @@ public class TileEntityTurtleRenderer extends BlockEntityRenderer<TileTurtle>
|
||||
|
||||
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 );
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -24,12 +24,12 @@ 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.client.util.math.MatrixStack;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.AffineTransformation;
|
||||
import net.minecraft.util.math.Direction;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
@@ -12,11 +12,12 @@ import com.google.common.io.ByteStreams;
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.filesystem.IMount;
|
||||
import dan200.computercraft.core.apis.handles.ArrayByteChannel;
|
||||
import dan200.computercraft.core.filesystem.ResourceMount.Listener;
|
||||
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.util.Identifier;
|
||||
import net.minecraft.util.InvalidIdentifierException;
|
||||
import net.minecraft.util.profiler.Profiler;
|
||||
@@ -294,12 +295,12 @@ public final class ResourceMount implements IMount
|
||||
}
|
||||
|
||||
/**
|
||||
* A {@link ResourceReloadListener} which reloads any associated mounts.
|
||||
* A {@link ResourceReloader} which reloads any associated mounts.
|
||||
*
|
||||
* 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 );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ package dan200.computercraft.core.lua;
|
||||
import dan200.computercraft.ComputerCraft;
|
||||
import dan200.computercraft.api.lua.*;
|
||||
import dan200.computercraft.core.asm.LuaMethod;
|
||||
import dan200.computercraft.core.lua.ResultInterpreterFunction.Container;
|
||||
import org.squiddev.cobalt.*;
|
||||
import org.squiddev.cobalt.debug.DebugFrame;
|
||||
import org.squiddev.cobalt.function.ResumableVarArgFunction;
|
||||
|
||||
@@ -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" );
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
*/
|
||||
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.Quaternion;
|
||||
import net.minecraft.util.math.Vec3f;
|
||||
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();
|
||||
|
||||
@@ -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 )
|
||||
);
|
||||
|
||||
@@ -59,7 +59,7 @@ public enum UserLevel implements Predicate<ServerCommandSource>
|
||||
|
||||
if( this == OWNER || this == OWNER_OP )
|
||||
{
|
||||
MinecraftServer server = source.getMinecraftServer();
|
||||
MinecraftServer server = source.getServer();
|
||||
Entity sender = source.getEntity();
|
||||
if( server.isSinglePlayer() && sender instanceof PlayerEntity &&
|
||||
((PlayerEntity) sender).getGameProfile().getName().equalsIgnoreCase( server.getServerModName() ) )
|
||||
|
||||
@@ -66,7 +66,7 @@ public final class HelpingArgumentBuilder extends LiteralArgumentBuilder<ServerC
|
||||
// An ugly hack to extract usage information from the dispatcher. We generate a temporary node, generate
|
||||
// the shorthand usage, and emit that.
|
||||
CommandDispatcher<ServerCommandSource> dispatcher = context.getSource()
|
||||
.getMinecraftServer()
|
||||
.getServer()
|
||||
.getCommandManager()
|
||||
.getDispatcher();
|
||||
CommandNode<ServerCommandSource> temp = new LiteralCommandNode<>( "_", null, x -> true, null, null, false );
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
|
||||
@@ -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.getNbt();
|
||||
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.getNbt();
|
||||
if( tag != null )
|
||||
{
|
||||
tag.remove( NBT_COLOUR );
|
||||
@@ -43,7 +43,7 @@ public interface IColouredItem
|
||||
}
|
||||
else
|
||||
{
|
||||
stack.getOrCreateTag()
|
||||
stack.getOrCreateNbt()
|
||||
.putInt( NBT_COLOUR, colour );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,9 +8,8 @@ package dan200.computercraft.shared.common;
|
||||
|
||||
import dan200.computercraft.core.terminal.Terminal;
|
||||
import dan200.computercraft.shared.network.client.TerminalState;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
|
||||
public class ServerTerminal implements ITerminal
|
||||
{
|
||||
@@ -85,12 +84,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 );
|
||||
|
||||
@@ -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;
|
||||
@@ -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 )
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
|
||||
@@ -28,7 +28,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;
|
||||
@@ -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 )
|
||||
@@ -325,9 +325,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 BlockState state, @Nonnull NbtCompound nbt )
|
||||
{
|
||||
super.fromTag( state, nbt );
|
||||
super.readNbt( state, nbt );
|
||||
|
||||
// Load ID, label and power state
|
||||
computerID = nbt.contains( NBT_ID ) ? nbt.getInt( NBT_ID ) : -1;
|
||||
@@ -337,7 +337,7 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public CompoundTag toTag( @Nonnull CompoundTag nbt )
|
||||
public NbtCompound writeNbt( @Nonnull NbtCompound nbt )
|
||||
{
|
||||
// Save ID, label and power state
|
||||
if( computerID >= 0 )
|
||||
@@ -350,7 +350,7 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT
|
||||
}
|
||||
nbt.putBoolean( NBT_ON, on );
|
||||
|
||||
return super.toTag( nbt );
|
||||
return super.writeNbt( nbt );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -8,8 +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;
|
||||
|
||||
public interface IComputerItem
|
||||
@@ -18,7 +17,7 @@ public interface IComputerItem
|
||||
|
||||
default int getComputerID( @Nonnull ItemStack stack )
|
||||
{
|
||||
CompoundTag nbt = stack.getTag();
|
||||
NbtCompound nbt = stack.getNbt();
|
||||
return nbt != null && nbt.contains( NBT_ID ) ? nbt.getInt( NBT_ID ) : -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ public class ItemComputer extends ItemComputerBase
|
||||
ItemStack result = new ItemStack( this );
|
||||
if( id >= 0 )
|
||||
{
|
||||
result.getOrCreateTag()
|
||||
result.getOrCreateNbt()
|
||||
.putInt( NBT_ID, id );
|
||||
}
|
||||
if( label != null )
|
||||
|
||||
@@ -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 = getItem( 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 );
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -78,14 +78,14 @@ public class ItemDisk extends Item implements IMedia, IColouredItem
|
||||
{
|
||||
if( id >= 0 )
|
||||
{
|
||||
stack.getOrCreateTag()
|
||||
stack.getOrCreateNbt()
|
||||
.putInt( NBT_ID, id );
|
||||
}
|
||||
}
|
||||
|
||||
public static int getDiskID( @Nonnull ItemStack stack )
|
||||
{
|
||||
CompoundTag nbt = stack.getTag();
|
||||
NbtCompound nbt = stack.getNbt();
|
||||
return nbt != null && nbt.contains( NBT_ID ) ? nbt.getInt( NBT_ID ) : -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
@@ -55,12 +55,12 @@ public class ItemPrintout extends Item
|
||||
// Build NBT
|
||||
if( title != null )
|
||||
{
|
||||
stack.getOrCreateTag()
|
||||
stack.getOrCreateNbt()
|
||||
.putString( NBT_TITLE, title );
|
||||
}
|
||||
if( text != null )
|
||||
{
|
||||
CompoundTag tag = stack.getOrCreateTag();
|
||||
NbtCompound tag = stack.getOrCreateNbt();
|
||||
tag.putInt( NBT_PAGES, text.length / LINES_PER_PAGE );
|
||||
for( int i = 0; i < text.length; i++ )
|
||||
{
|
||||
@@ -72,7 +72,7 @@ public class ItemPrintout extends Item
|
||||
}
|
||||
if( colours != null )
|
||||
{
|
||||
CompoundTag tag = stack.getOrCreateTag();
|
||||
NbtCompound tag = stack.getOrCreateNbt();
|
||||
for( int i = 0; i < colours.length; i++ )
|
||||
{
|
||||
if( colours[i] != null )
|
||||
@@ -105,7 +105,7 @@ public class ItemPrintout extends Item
|
||||
|
||||
private static String[] getLines( @Nonnull ItemStack stack, String prefix )
|
||||
{
|
||||
CompoundTag nbt = stack.getTag();
|
||||
NbtCompound nbt = stack.getNbt();
|
||||
int numLines = getPageCount( stack ) * LINES_PER_PAGE;
|
||||
String[] lines = new String[numLines];
|
||||
for( int i = 0; i < lines.length; i++ )
|
||||
@@ -117,7 +117,7 @@ public class ItemPrintout extends Item
|
||||
|
||||
public static int getPageCount( @Nonnull ItemStack stack )
|
||||
{
|
||||
CompoundTag nbt = stack.getTag();
|
||||
NbtCompound nbt = stack.getNbt();
|
||||
return nbt != null && nbt.contains( NBT_PAGES ) ? nbt.getInt( NBT_PAGES ) : 1;
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@ public class ItemPrintout extends Item
|
||||
|
||||
public static String getTitle( @Nonnull ItemStack stack )
|
||||
{
|
||||
CompoundTag nbt = stack.getTag();
|
||||
NbtCompound nbt = stack.getNbt();
|
||||
return nbt != null && nbt.contains( NBT_TITLE ) ? nbt.getString( NBT_TITLE ) : null;
|
||||
}
|
||||
|
||||
|
||||
@@ -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.getOrCreateNbt();
|
||||
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.getNbt();
|
||||
return nbt != null && nbt.contains( NBT_COLOUR ) ? nbt.getInt( NBT_COLOUR ) : Colour.BLUE.getHex();
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ public class ItemTreasureDisk extends Item implements IMedia
|
||||
@Nonnull
|
||||
private static String getTitle( @Nonnull ItemStack stack )
|
||||
{
|
||||
CompoundTag nbt = stack.getTag();
|
||||
NbtCompound nbt = stack.getNbt();
|
||||
return nbt != null && nbt.contains( NBT_TITLE ) ? nbt.getString( NBT_TITLE ) : "'alongtimeago' by dan200";
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ public class ItemTreasureDisk extends Item implements IMedia
|
||||
@Nonnull
|
||||
private static String getSubPath( @Nonnull ItemStack stack )
|
||||
{
|
||||
CompoundTag nbt = stack.getTag();
|
||||
NbtCompound nbt = stack.getNbt();
|
||||
return nbt != null && nbt.contains( NBT_SUB_PATH ) ? nbt.getString( NBT_SUB_PATH ) : "dan200/alongtimeago";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
@@ -108,21 +108,21 @@ public final class TileDiskDrive extends TileGeneric implements DefaultInventory
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromTag( @Nonnull BlockState state, @Nonnull CompoundTag nbt )
|
||||
public void readNbt( @Nonnull BlockState state, @Nonnull NbtCompound nbt )
|
||||
{
|
||||
super.fromTag( state, nbt );
|
||||
super.readNbt( state, 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 )
|
||||
{
|
||||
if( customName != null )
|
||||
{
|
||||
@@ -131,11 +131,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 super.writeNbt( nbt );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -12,9 +12,9 @@ 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.NbtElement;
|
||||
import net.minecraft.nbt.NbtList;
|
||||
import net.minecraft.tag.ServerTagManagerHolder;
|
||||
import net.minecraft.tag.TagGroup;
|
||||
import net.minecraft.text.Text;
|
||||
@@ -42,7 +42,7 @@ public class ItemData
|
||||
public static <T extends Map<? super String, Object>> T fillBasic( @Nonnull T data, @Nonnull ItemStack stack )
|
||||
{
|
||||
fillBasicSafe( data, stack );
|
||||
String hash = NBTUtil.getNBTHash( stack.getTag() );
|
||||
String hash = NBTUtil.getNBTHash( stack.getNbt() );
|
||||
if( hash != null ) data.put( "nbt", hash );
|
||||
|
||||
return data;
|
||||
@@ -77,13 +77,13 @@ public class ItemData
|
||||
.collect( Collectors.toList() )
|
||||
) ); // chaos x2
|
||||
|
||||
CompoundTag tag = stack.getTag();
|
||||
NbtCompound tag = stack.getNbt();
|
||||
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 +112,7 @@ public class ItemData
|
||||
|
||||
|
||||
@Nullable
|
||||
private static Text parseTextComponent( @Nonnull Tag x )
|
||||
private static Text parseTextComponent( @Nonnull NbtElement x )
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -138,7 +138,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 +161,14 @@ public class ItemData
|
||||
* @param enchants The enchantment map to add it to.
|
||||
* @see EnchantmentHelper
|
||||
*/
|
||||
private static void addEnchantments( @Nonnull ListTag rawEnchants, @Nonnull ArrayList<Map<String, Object>> enchants )
|
||||
private static void addEnchantments( @Nonnull NbtList rawEnchants, @Nonnull ArrayList<Map<String, Object>> enchants )
|
||||
{
|
||||
if( rawEnchants.isEmpty() ) return;
|
||||
|
||||
enchants.ensureCapacity( enchants.size() + rawEnchants.size() );
|
||||
|
||||
|
||||
for( Map.Entry<Enchantment, Integer> entry : EnchantmentHelper.fromTag( rawEnchants ).entrySet() )
|
||||
for( Map.Entry<Enchantment, Integer> entry : EnchantmentHelper.fromNbt( rawEnchants ).entrySet() )
|
||||
{
|
||||
Enchantment enchantment = entry.getKey();
|
||||
Integer level = entry.getValue();
|
||||
|
||||
@@ -23,7 +23,7 @@ import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
@@ -377,20 +377,20 @@ public class TileCable extends TileGeneric implements IPeripheralTile
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromTag( @Nonnull BlockState state, @Nonnull CompoundTag nbt )
|
||||
public void readNbt( @Nonnull BlockState state, @Nonnull NbtCompound nbt )
|
||||
{
|
||||
super.fromTag( state, nbt );
|
||||
super.readNbt( state, nbt );
|
||||
peripheralAccessAllowed = nbt.getBoolean( NBT_PERIPHERAL_ENABLED );
|
||||
peripheral.read( nbt, "" );
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public CompoundTag toTag( CompoundTag nbt )
|
||||
public NbtCompound writeNbt( NbtCompound nbt )
|
||||
{
|
||||
nbt.putBoolean( NBT_PERIPHERAL_ENABLED, peripheralAccessAllowed );
|
||||
peripheral.write( nbt, "" );
|
||||
return super.toTag( nbt );
|
||||
return super.writeNbt( nbt );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -20,7 +20,7 @@ import dan200.computercraft.shared.util.TickScheduler;
|
||||
import net.minecraft.block.BlockState;
|
||||
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.text.LiteralText;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
import net.minecraft.util.ActionResult;
|
||||
@@ -315,9 +315,9 @@ public class TileWiredModemFull extends TileGeneric implements IPeripheralTile
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromTag( @Nonnull BlockState state, @Nonnull CompoundTag nbt )
|
||||
public void readNbt( @Nonnull BlockState state, @Nonnull NbtCompound nbt )
|
||||
{
|
||||
super.fromTag( state, nbt );
|
||||
super.readNbt( state, nbt );
|
||||
peripheralAccessAllowed = nbt.getBoolean( NBT_PERIPHERAL_ENABLED );
|
||||
for( int i = 0; i < peripherals.length; i++ )
|
||||
{
|
||||
@@ -327,14 +327,14 @@ public class TileWiredModemFull extends TileGeneric implements IPeripheralTile
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public CompoundTag toTag( CompoundTag nbt )
|
||||
public NbtCompound writeNbt( NbtCompound nbt )
|
||||
{
|
||||
nbt.putBoolean( NBT_PERIPHERAL_ENABLED, peripheralAccessAllowed );
|
||||
for( int i = 0; i < peripherals.length; i++ )
|
||||
{
|
||||
peripherals[i].write( nbt, Integer.toString( i ) );
|
||||
}
|
||||
return super.toTag( nbt );
|
||||
return super.writeNbt( nbt );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -12,7 +12,7 @@ import dan200.computercraft.shared.Peripherals;
|
||||
import dan200.computercraft.shared.util.IDAssigner;
|
||||
import dan200.computercraft.shared.util.NBTUtil;
|
||||
import net.minecraft.block.Block;
|
||||
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.world.World;
|
||||
@@ -135,7 +135,7 @@ public final class WiredModemLocalPeripheral
|
||||
return peripheral == null ? Collections.emptyMap() : Collections.singletonMap( type + "_" + id, peripheral );
|
||||
}
|
||||
|
||||
public void write( @Nonnull CompoundTag tag, @Nonnull String suffix )
|
||||
public void write( @Nonnull NbtCompound tag, @Nonnull String suffix )
|
||||
{
|
||||
if( id >= 0 )
|
||||
{
|
||||
@@ -147,7 +147,7 @@ public final class WiredModemLocalPeripheral
|
||||
}
|
||||
}
|
||||
|
||||
public void read( @Nonnull CompoundTag tag, @Nonnull String suffix )
|
||||
public void read( @Nonnull NbtCompound tag, @Nonnull String suffix )
|
||||
{
|
||||
id = tag.contains( NBT_PERIPHERAL_ID + suffix, NBTUtil.TAG_ANY_NUMERIC ) ? tag.getInt( NBT_PERIPHERAL_ID + suffix ) : -1;
|
||||
|
||||
|
||||
@@ -19,7 +19,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;
|
||||
@@ -164,7 +164,7 @@ public class TileMonitor extends TileGeneric implements IPeripheralTile
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final void readDescription( @Nonnull CompoundTag nbt )
|
||||
protected final void readDescription( @Nonnull NbtCompound nbt )
|
||||
{
|
||||
super.readDescription( nbt );
|
||||
|
||||
@@ -207,7 +207,7 @@ public class TileMonitor extends TileGeneric implements IPeripheralTile
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeDescription( @Nonnull CompoundTag nbt )
|
||||
protected void writeDescription( @Nonnull NbtCompound nbt )
|
||||
{
|
||||
super.writeDescription( nbt );
|
||||
nbt.putInt( NBT_X, xIndex );
|
||||
@@ -286,9 +286,9 @@ public class TileMonitor extends TileGeneric implements IPeripheralTile
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromTag( @Nonnull BlockState state, @Nonnull CompoundTag nbt )
|
||||
public void readNbt( @Nonnull BlockState state, @Nonnull NbtCompound nbt )
|
||||
{
|
||||
super.fromTag( state, nbt );
|
||||
super.readNbt( state, nbt );
|
||||
|
||||
xIndex = nbt.getInt( NBT_X );
|
||||
yIndex = nbt.getInt( NBT_Y );
|
||||
@@ -300,13 +300,13 @@ public class TileMonitor extends TileGeneric implements IPeripheralTile
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public CompoundTag toTag( CompoundTag tag )
|
||||
public NbtCompound writeNbt( NbtCompound tag )
|
||||
{
|
||||
tag.putInt( NBT_X, xIndex );
|
||||
tag.putInt( NBT_Y, yIndex );
|
||||
tag.putInt( NBT_WIDTH, width );
|
||||
tag.putInt( NBT_HEIGHT, height );
|
||||
return super.toTag( tag );
|
||||
return super.writeNbt( tag );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -23,7 +23,7 @@ import net.minecraft.inventory.Inventories;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
import net.minecraft.screen.NamedScreenHandlerFactory;
|
||||
import net.minecraft.screen.ScreenHandler;
|
||||
import net.minecraft.text.Text;
|
||||
@@ -165,9 +165,9 @@ public final class TilePrinter extends TileGeneric implements DefaultSidedInvent
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromTag( @Nonnull BlockState state, @Nonnull CompoundTag nbt )
|
||||
public void readNbt( @Nonnull BlockState state, @Nonnull NbtCompound nbt )
|
||||
{
|
||||
super.fromTag( state, nbt );
|
||||
super.readNbt( state, nbt );
|
||||
|
||||
customName = nbt.contains( NBT_NAME ) ? Text.Serializer.fromJson( nbt.getString( NBT_NAME ) ) : null;
|
||||
|
||||
@@ -180,12 +180,12 @@ public final class TilePrinter extends TileGeneric implements DefaultSidedInvent
|
||||
}
|
||||
|
||||
// Read inventory
|
||||
Inventories.fromTag( nbt, inventory );
|
||||
Inventories.readNbt( nbt, inventory );
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public CompoundTag toTag( @Nonnull CompoundTag nbt )
|
||||
public NbtCompound writeNbt( @Nonnull NbtCompound nbt )
|
||||
{
|
||||
if( customName != null )
|
||||
{
|
||||
@@ -201,9 +201,9 @@ public final class TilePrinter extends TileGeneric implements DefaultSidedInvent
|
||||
}
|
||||
|
||||
// Write inventory
|
||||
Inventories.toTag( nbt, inventory );
|
||||
Inventories.writeNbt( nbt, inventory );
|
||||
|
||||
return super.toTag( nbt );
|
||||
return super.writeNbt( nbt );
|
||||
}
|
||||
|
||||
boolean isPrinting()
|
||||
|
||||
@@ -22,7 +22,7 @@ import net.minecraft.entity.LivingEntity;
|
||||
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.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.world.World;
|
||||
@@ -87,14 +87,14 @@ public class PocketServerComputer extends ServerComputer implements IPocketAcces
|
||||
@Override
|
||||
public int getLight()
|
||||
{
|
||||
CompoundTag tag = getUserData();
|
||||
NbtCompound tag = getUserData();
|
||||
return tag.contains( NBT_LIGHT, NBTUtil.TAG_ANY_NUMERIC ) ? tag.getInt( NBT_LIGHT ) : -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLight( int colour )
|
||||
{
|
||||
CompoundTag tag = getUserData();
|
||||
NbtCompound tag = getUserData();
|
||||
if( colour >= 0 && colour <= 0xFFFFFF )
|
||||
{
|
||||
if( !tag.contains( NBT_LIGHT, NBTUtil.TAG_ANY_NUMERIC ) || tag.getInt( NBT_LIGHT ) != colour )
|
||||
@@ -112,7 +112,7 @@ public class PocketServerComputer extends ServerComputer implements IPocketAcces
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public CompoundTag getUpgradeNBTData()
|
||||
public NbtCompound getUpgradeNBTData()
|
||||
{
|
||||
return ItemPocketComputer.getUpgradeInfo( stack );
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ import net.minecraft.inventory.Inventory;
|
||||
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;
|
||||
@@ -92,7 +92,7 @@ public class ItemPocketComputer extends Item implements IComputerItem, IMedia, I
|
||||
ClientComputer computer = getClientComputer( stack );
|
||||
if( computer != null && computer.isOn() )
|
||||
{
|
||||
CompoundTag computerNBT = computer.getUserData();
|
||||
NbtCompound computerNBT = computer.getUserData();
|
||||
if( computerNBT != null && computerNBT.contains( NBT_LIGHT ) )
|
||||
{
|
||||
return computerNBT.getInt( NBT_LIGHT );
|
||||
@@ -103,7 +103,7 @@ public class ItemPocketComputer extends Item implements IComputerItem, IMedia, I
|
||||
|
||||
public static void setUpgrade( @Nonnull ItemStack stack, IPocketUpgrade upgrade )
|
||||
{
|
||||
CompoundTag compound = stack.getOrCreateTag();
|
||||
NbtCompound compound = stack.getOrCreateNbt();
|
||||
|
||||
if( upgrade == null )
|
||||
{
|
||||
@@ -119,9 +119,9 @@ public class ItemPocketComputer extends Item implements IComputerItem, IMedia, I
|
||||
compound.remove( NBT_UPGRADE_INFO );
|
||||
}
|
||||
|
||||
public static CompoundTag getUpgradeInfo( @Nonnull ItemStack stack )
|
||||
public static NbtCompound getUpgradeInfo( @Nonnull ItemStack stack )
|
||||
{
|
||||
return stack.getOrCreateSubTag( NBT_UPGRADE_INFO );
|
||||
return stack.getOrCreateSubNbt( NBT_UPGRADE_INFO );
|
||||
}
|
||||
|
||||
// @Nullable
|
||||
@@ -274,7 +274,7 @@ public class ItemPocketComputer extends Item implements IComputerItem, IMedia, I
|
||||
ItemStack result = new ItemStack( this );
|
||||
if( id >= 0 )
|
||||
{
|
||||
result.getOrCreateTag()
|
||||
result.getOrCreateNbt()
|
||||
.putInt( NBT_ID, id );
|
||||
}
|
||||
if( label != null )
|
||||
@@ -283,14 +283,14 @@ public class ItemPocketComputer extends Item implements IComputerItem, IMedia, I
|
||||
}
|
||||
if( upgrade != null )
|
||||
{
|
||||
result.getOrCreateTag()
|
||||
result.getOrCreateNbt()
|
||||
.putString( NBT_UPGRADE,
|
||||
upgrade.getUpgradeID()
|
||||
.toString() );
|
||||
}
|
||||
if( colour != -1 )
|
||||
{
|
||||
result.getOrCreateTag()
|
||||
result.getOrCreateNbt()
|
||||
.putInt( NBT_COLOUR, colour );
|
||||
}
|
||||
return result;
|
||||
@@ -341,7 +341,7 @@ public class ItemPocketComputer extends Item implements IComputerItem, IMedia, I
|
||||
|
||||
public static IPocketUpgrade getUpgrade( @Nonnull ItemStack stack )
|
||||
{
|
||||
CompoundTag compound = stack.getTag();
|
||||
NbtCompound compound = stack.getNbt();
|
||||
return compound != null && compound.contains( NBT_UPGRADE ) ? PocketUpgrades.get( compound.getString( NBT_UPGRADE ) ) : null;
|
||||
|
||||
}
|
||||
@@ -350,7 +350,7 @@ public class ItemPocketComputer extends Item implements IComputerItem, IMedia, I
|
||||
|
||||
private static void setComputerID( @Nonnull ItemStack stack, int computerID )
|
||||
{
|
||||
stack.getOrCreateTag()
|
||||
stack.getOrCreateNbt()
|
||||
.putInt( NBT_ID, computerID );
|
||||
}
|
||||
|
||||
@@ -402,25 +402,25 @@ public class ItemPocketComputer extends Item implements IComputerItem, IMedia, I
|
||||
|
||||
private static int getInstanceID( @Nonnull ItemStack stack )
|
||||
{
|
||||
CompoundTag nbt = stack.getTag();
|
||||
NbtCompound nbt = stack.getNbt();
|
||||
return nbt != null && nbt.contains( NBT_INSTANCE ) ? nbt.getInt( NBT_INSTANCE ) : -1;
|
||||
}
|
||||
|
||||
private static int getSessionID( @Nonnull ItemStack stack )
|
||||
{
|
||||
CompoundTag nbt = stack.getTag();
|
||||
NbtCompound nbt = stack.getNbt();
|
||||
return nbt != null && nbt.contains( NBT_SESSION ) ? nbt.getInt( NBT_SESSION ) : -1;
|
||||
}
|
||||
|
||||
private static void setInstanceID( @Nonnull ItemStack stack, int instanceID )
|
||||
{
|
||||
stack.getOrCreateTag()
|
||||
stack.getOrCreateNbt()
|
||||
.putInt( NBT_INSTANCE, instanceID );
|
||||
}
|
||||
|
||||
private static void setSessionID( @Nonnull ItemStack stack, int sessionID )
|
||||
{
|
||||
stack.getOrCreateTag()
|
||||
stack.getOrCreateNbt()
|
||||
.putInt( NBT_SESSION, sessionID );
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,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.turtle.apis.TurtleAPI;
|
||||
import dan200.computercraft.shared.turtle.blocks.TileTurtle.MoveState;
|
||||
import dan200.computercraft.shared.turtle.core.TurtleBrain;
|
||||
import dan200.computercraft.shared.turtle.inventory.ContainerTurtle;
|
||||
import dan200.computercraft.shared.util.*;
|
||||
@@ -29,8 +30,8 @@ import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.item.DyeItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
import net.minecraft.nbt.NbtList;
|
||||
import net.minecraft.screen.ScreenHandler;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.DyeColor;
|
||||
@@ -292,19 +293,19 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public CompoundTag toTag( @Nonnull CompoundTag nbt )
|
||||
public NbtCompound writeNbt( @Nonnull NbtCompound nbt )
|
||||
{
|
||||
// Write inventory
|
||||
ListTag nbttaglist = new ListTag();
|
||||
NbtList nbttaglist = new NbtList();
|
||||
for( int i = 0; i < INVENTORY_SIZE; i++ )
|
||||
{
|
||||
if( !inventory.get( i )
|
||||
.isEmpty() )
|
||||
{
|
||||
CompoundTag tag = new CompoundTag();
|
||||
NbtCompound tag = new NbtCompound();
|
||||
tag.putByte( "Slot", (byte) i );
|
||||
inventory.get( i )
|
||||
.toTag( tag );
|
||||
.writeNbt( tag );
|
||||
nbttaglist.add( tag );
|
||||
}
|
||||
}
|
||||
@@ -313,27 +314,27 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default
|
||||
// Write brain
|
||||
nbt = brain.writeToNBT( nbt );
|
||||
|
||||
return super.toTag( nbt );
|
||||
return super.writeNbt( nbt );
|
||||
}
|
||||
|
||||
// IDirectionalTile
|
||||
|
||||
@Override
|
||||
public void fromTag( @Nonnull BlockState state, @Nonnull CompoundTag nbt )
|
||||
public void readNbt( @Nonnull BlockState state, @Nonnull NbtCompound nbt )
|
||||
{
|
||||
super.fromTag( state, nbt );
|
||||
super.readNbt( state, nbt );
|
||||
|
||||
// Read inventory
|
||||
ListTag nbttaglist = nbt.getList( "Items", NBTUtil.TAG_COMPOUND );
|
||||
NbtList nbttaglist = nbt.getList( "Items", NBTUtil.TAG_COMPOUND );
|
||||
inventory.clear();
|
||||
previousInventory.clear();
|
||||
for( int i = 0; i < nbttaglist.size(); i++ )
|
||||
{
|
||||
CompoundTag tag = nbttaglist.getCompound( i );
|
||||
NbtCompound tag = nbttaglist.getCompound( i );
|
||||
int slot = tag.getByte( "Slot" ) & 0xff;
|
||||
if( slot < size() )
|
||||
{
|
||||
inventory.set( slot, ItemStack.fromTag( tag ) );
|
||||
inventory.set( slot, ItemStack.fromNbt( tag ) );
|
||||
previousInventory.set( slot, inventory.get( slot )
|
||||
.copy() );
|
||||
}
|
||||
@@ -372,14 +373,14 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeDescription( @Nonnull CompoundTag nbt )
|
||||
protected void writeDescription( @Nonnull NbtCompound nbt )
|
||||
{
|
||||
super.writeDescription( nbt );
|
||||
brain.writeDescription( nbt );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readDescription( @Nonnull CompoundTag nbt )
|
||||
protected void readDescription( @Nonnull NbtCompound nbt )
|
||||
{
|
||||
super.readDescription( nbt );
|
||||
brain.readDescription( nbt );
|
||||
|
||||
@@ -27,7 +27,7 @@ import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.MovementType;
|
||||
import net.minecraft.fluid.FluidState;
|
||||
import net.minecraft.inventory.Inventory;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
import net.minecraft.particle.ParticleTypes;
|
||||
import net.minecraft.predicate.entity.EntityPredicates;
|
||||
import net.minecraft.tag.FluidTags;
|
||||
@@ -62,7 +62,7 @@ public class TurtleBrain implements ITurtleAccess
|
||||
private final Queue<TurtleCommandQueueEntry> commandQueue = new ArrayDeque<>();
|
||||
private final Map<TurtleSide, ITurtleUpgrade> upgrades = new EnumMap<>( TurtleSide.class );
|
||||
private final Map<TurtleSide, IPeripheral> peripherals = new EnumMap<>( TurtleSide.class );
|
||||
private final Map<TurtleSide, CompoundTag> upgradeNBTData = new EnumMap<>( TurtleSide.class );
|
||||
private final Map<TurtleSide, NbtCompound> upgradeNBTData = new EnumMap<>( TurtleSide.class );
|
||||
TurtlePlayer cachedPlayer;
|
||||
private TileTurtle owner;
|
||||
private final Inventory inventory = (InventoryDelegate) () -> owner;
|
||||
@@ -543,12 +543,12 @@ public class TurtleBrain implements ITurtleAccess
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public CompoundTag getUpgradeNBTData( TurtleSide side )
|
||||
public NbtCompound getUpgradeNBTData( TurtleSide side )
|
||||
{
|
||||
CompoundTag nbt = upgradeNBTData.get( side );
|
||||
NbtCompound nbt = upgradeNBTData.get( side );
|
||||
if( nbt == null )
|
||||
{
|
||||
upgradeNBTData.put( side, nbt = new CompoundTag() );
|
||||
upgradeNBTData.put( side, nbt = new NbtCompound() );
|
||||
}
|
||||
return nbt;
|
||||
}
|
||||
@@ -800,7 +800,7 @@ public class TurtleBrain implements ITurtleAccess
|
||||
return previous + (next - previous) * f;
|
||||
}
|
||||
|
||||
public void readFromNBT( CompoundTag nbt )
|
||||
public void readFromNBT( NbtCompound nbt )
|
||||
{
|
||||
readCommon( nbt );
|
||||
|
||||
@@ -810,7 +810,7 @@ public class TurtleBrain implements ITurtleAccess
|
||||
// Read owner
|
||||
if( nbt.contains( "Owner", NBTUtil.TAG_COMPOUND ) )
|
||||
{
|
||||
CompoundTag owner = nbt.getCompound( "Owner" );
|
||||
NbtCompound owner = nbt.getCompound( "Owner" );
|
||||
owningPlayer = new GameProfile( new UUID( owner.getLong( "UpperId" ), owner.getLong( "LowerId" ) ), owner.getString( "Name" ) );
|
||||
}
|
||||
else
|
||||
@@ -824,7 +824,7 @@ public class TurtleBrain implements ITurtleAccess
|
||||
*
|
||||
* @param nbt The tag to read from
|
||||
*/
|
||||
private void readCommon( CompoundTag nbt )
|
||||
private void readCommon( NbtCompound nbt )
|
||||
{
|
||||
// Read fields
|
||||
colourHex = nbt.contains( NBT_COLOUR ) ? nbt.getInt( NBT_COLOUR ) : -1;
|
||||
@@ -851,7 +851,7 @@ public class TurtleBrain implements ITurtleAccess
|
||||
}
|
||||
}
|
||||
|
||||
public CompoundTag writeToNBT( CompoundTag nbt )
|
||||
public NbtCompound writeToNBT( NbtCompound nbt )
|
||||
{
|
||||
writeCommon( nbt );
|
||||
|
||||
@@ -861,7 +861,7 @@ public class TurtleBrain implements ITurtleAccess
|
||||
// Write owner
|
||||
if( owningPlayer != null )
|
||||
{
|
||||
CompoundTag owner = new CompoundTag();
|
||||
NbtCompound owner = new NbtCompound();
|
||||
nbt.put( "Owner", owner );
|
||||
|
||||
owner.putLong( "UpperId", owningPlayer.getId()
|
||||
@@ -874,7 +874,7 @@ public class TurtleBrain implements ITurtleAccess
|
||||
return nbt;
|
||||
}
|
||||
|
||||
private void writeCommon( CompoundTag nbt )
|
||||
private void writeCommon( NbtCompound nbt )
|
||||
{
|
||||
nbt.putInt( NBT_FUEL, fuelLevel );
|
||||
if( colourHex != -1 )
|
||||
@@ -917,7 +917,7 @@ public class TurtleBrain implements ITurtleAccess
|
||||
.toString() : null;
|
||||
}
|
||||
|
||||
public void readDescription( CompoundTag nbt )
|
||||
public void readDescription( NbtCompound nbt )
|
||||
{
|
||||
readCommon( nbt );
|
||||
|
||||
@@ -931,7 +931,7 @@ public class TurtleBrain implements ITurtleAccess
|
||||
}
|
||||
}
|
||||
|
||||
public void writeDescription( CompoundTag nbt )
|
||||
public void writeDescription( NbtCompound nbt )
|
||||
{
|
||||
writeCommon( nbt );
|
||||
nbt.putInt( "Animation", animation.ordinal() );
|
||||
|
||||
@@ -208,7 +208,7 @@ public final class TurtlePlayer extends FakePlayer
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openEditBookScreen( @Nonnull ItemStack stack, @Nonnull Hand hand )
|
||||
public void useBook( @Nonnull ItemStack stack, @Nonnull Hand hand )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ import dan200.computercraft.shared.computer.items.ItemComputerBase;
|
||||
import dan200.computercraft.shared.turtle.blocks.BlockTurtle;
|
||||
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;
|
||||
@@ -60,24 +60,24 @@ public class ItemTurtle extends ItemComputerBase implements ITurtleItem
|
||||
}
|
||||
if( id >= 0 )
|
||||
{
|
||||
stack.getOrCreateTag()
|
||||
stack.getOrCreateNbt()
|
||||
.putInt( NBT_ID, id );
|
||||
}
|
||||
IColouredItem.setColourBasic( stack, colour );
|
||||
if( fuelLevel > 0 )
|
||||
{
|
||||
stack.getOrCreateTag()
|
||||
stack.getOrCreateNbt()
|
||||
.putInt( NBT_FUEL, fuelLevel );
|
||||
}
|
||||
if( overlay != null )
|
||||
{
|
||||
stack.getOrCreateTag()
|
||||
stack.getOrCreateNbt()
|
||||
.putString( NBT_OVERLAY, overlay.toString() );
|
||||
}
|
||||
|
||||
if( leftUpgrade != null )
|
||||
{
|
||||
stack.getOrCreateTag()
|
||||
stack.getOrCreateNbt()
|
||||
.putString( NBT_LEFT_UPGRADE,
|
||||
leftUpgrade.getUpgradeID()
|
||||
.toString() );
|
||||
@@ -85,7 +85,7 @@ public class ItemTurtle extends ItemComputerBase implements ITurtleItem
|
||||
|
||||
if( rightUpgrade != null )
|
||||
{
|
||||
stack.getOrCreateTag()
|
||||
stack.getOrCreateNbt()
|
||||
.putString( NBT_RIGHT_UPGRADE,
|
||||
rightUpgrade.getUpgradeID()
|
||||
.toString() );
|
||||
@@ -148,7 +148,7 @@ public class ItemTurtle extends ItemComputerBase implements ITurtleItem
|
||||
@Override
|
||||
public ITurtleUpgrade getUpgrade( @Nonnull ItemStack stack, @Nonnull TurtleSide side )
|
||||
{
|
||||
CompoundTag tag = stack.getTag();
|
||||
NbtCompound tag = stack.getNbt();
|
||||
if( tag == null )
|
||||
{
|
||||
return null;
|
||||
@@ -161,14 +161,14 @@ public class ItemTurtle extends ItemComputerBase implements ITurtleItem
|
||||
@Override
|
||||
public int getFuelLevel( @Nonnull ItemStack stack )
|
||||
{
|
||||
CompoundTag tag = stack.getTag();
|
||||
NbtCompound tag = stack.getNbt();
|
||||
return tag != null && tag.contains( NBT_FUEL ) ? tag.getInt( NBT_FUEL ) : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identifier getOverlay( @Nonnull ItemStack stack )
|
||||
{
|
||||
CompoundTag tag = stack.getTag();
|
||||
NbtCompound tag = stack.getNbt();
|
||||
return tag != null && tag.contains( NBT_OVERLAY ) ? new Identifier( tag.getString( NBT_OVERLAY ) ) : null;
|
||||
}
|
||||
|
||||
|
||||
@@ -117,7 +117,7 @@ public class TurtleInventoryCrafting extends CraftingInventory
|
||||
results.add( result );
|
||||
|
||||
result.onCraft( world, player, result.getCount() );
|
||||
DefaultedList<ItemStack> remainders = recipe.getRemainingStacks( this );
|
||||
DefaultedList<ItemStack> remainders = recipe.getRemainder( this );
|
||||
|
||||
for( int slot = 0; slot < remainders.size(); slot++ )
|
||||
{
|
||||
@@ -141,7 +141,7 @@ public class TurtleInventoryCrafting extends CraftingInventory
|
||||
{
|
||||
setStack( slot, remainder );
|
||||
}
|
||||
else if( ItemStack.areItemsEqualIgnoreDamage( existing, remainder ) && ItemStack.areTagsEqual( existing, remainder ) )
|
||||
else if( ItemStack.areItemsEqualIgnoreDamage( existing, remainder ) && ItemStack.areNbtEqual( existing, remainder ) )
|
||||
{
|
||||
remainder.increment( existing.getCount() );
|
||||
setStack( slot, remainder );
|
||||
|
||||
@@ -15,7 +15,7 @@ import dan200.computercraft.shared.peripheral.modem.wireless.WirelessModemPeriph
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.minecraft.client.util.ModelIdentifier;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
@@ -67,7 +67,7 @@ public class TurtleModem extends AbstractTurtleUpgrade
|
||||
boolean active = false;
|
||||
if( turtle != null )
|
||||
{
|
||||
CompoundTag turtleNBT = turtle.getUpgradeNBTData( side );
|
||||
NbtCompound turtleNBT = turtle.getUpgradeNBTData( side );
|
||||
active = turtleNBT.contains( "active" ) && turtleNBT.getBoolean( "active" );
|
||||
}
|
||||
|
||||
|
||||
@@ -26,21 +26,21 @@ import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.client.util.math.AffineTransformation;
|
||||
import net.minecraft.client.util.math.Vector3f;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.attribute.EntityAttributes;
|
||||
import net.minecraft.entity.damage.DamageSource;
|
||||
import net.minecraft.entity.decoration.ArmorStandEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.AffineTransformation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.Vec3f;
|
||||
import net.minecraft.world.World;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
@@ -76,7 +76,7 @@ public class TurtleTool extends AbstractTurtleUpgrade
|
||||
@Override
|
||||
public boolean isItemSuitable( @Nonnull ItemStack stack )
|
||||
{
|
||||
CompoundTag tag = stack.getTag();
|
||||
NbtCompound tag = stack.getNbt();
|
||||
if( tag == null || tag.isEmpty() ) return true;
|
||||
|
||||
// Check we've not got anything vaguely interesting on the item. We allow other mods to add their
|
||||
@@ -107,7 +107,7 @@ public class TurtleTool extends AbstractTurtleUpgrade
|
||||
public TransformedModel getModel( ITurtleAccess turtle, @Nonnull TurtleSide side )
|
||||
{
|
||||
float xOffset = side == TurtleSide.LEFT ? -0.40625f : 0.40625f;
|
||||
return TransformedModel.of( getCraftingItem(), new AffineTransformation( new Vector3f( xOffset + 1, 0, 1 ), Vector3f.POSITIVE_Y.getDegreesQuaternion( 270 ), new Vector3f( 1, 1, 1 ), Vector3f.POSITIVE_Z.getDegreesQuaternion( 90 ) ) );
|
||||
return TransformedModel.of( getCraftingItem(), new AffineTransformation( new Vec3f( xOffset + 1, 0, 1 ), Vec3f.POSITIVE_Y.getDegreesQuaternion( 270 ), new Vec3f( 1, 1, 1 ), Vec3f.POSITIVE_Z.getDegreesQuaternion( 90 ) ) );
|
||||
}
|
||||
|
||||
private TurtleCommandResult attack( ITurtleAccess turtle, Direction direction, TurtleSide side )
|
||||
@@ -255,7 +255,7 @@ public class TurtleTool extends AbstractTurtleUpgrade
|
||||
{
|
||||
state.getBlock()
|
||||
.onBroken( world, blockPosition, state );
|
||||
if( turtlePlayer.isUsingEffectiveTool( state ) )
|
||||
if( turtlePlayer.canHarvest( state ) )
|
||||
{
|
||||
state.getBlock()
|
||||
.afterBreak( world, turtlePlayer, blockPosition, state, tile, turtlePlayer.getMainHandStack() );
|
||||
|
||||
@@ -29,8 +29,8 @@ public final class ImpostorRecipe extends ShapedRecipe
|
||||
{
|
||||
String group = JsonHelper.getString( json, "group", "" );
|
||||
ShapedRecipe recipe = RecipeSerializer.SHAPED.read( identifier, json );
|
||||
ItemStack result = ShapedRecipe.getItemStack( JsonHelper.getObject( json, "result" ) );
|
||||
return new ImpostorRecipe( identifier, group, recipe.getWidth(), recipe.getHeight(), recipe.getPreviewInputs(), result );
|
||||
ItemStack result = ShapedRecipe.getItem( JsonHelper.getObject( json, "result" ) );
|
||||
return new ImpostorRecipe( identifier, group, recipe.getWidth(), recipe.getHeight(), recipe.getIngredients(), result );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -54,7 +54,7 @@ public final class ImpostorRecipe extends ShapedRecipe
|
||||
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 );
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public final class ImpostorShapelessRecipe extends ShapelessRecipe
|
||||
throw new JsonParseException( "Too many ingredients for shapeless recipe the max is 9" );
|
||||
}
|
||||
|
||||
ItemStack itemstack = ShapedRecipe.getItemStack( JsonHelper.getObject( json, "result" ) );
|
||||
ItemStack itemstack = ShapedRecipe.getItem( JsonHelper.getObject( json, "result" ) );
|
||||
return new ImpostorShapelessRecipe( id, s, itemstack, ingredients );
|
||||
}
|
||||
|
||||
@@ -81,10 +81,10 @@ public final class ImpostorShapelessRecipe extends ShapelessRecipe
|
||||
public void write( @Nonnull PacketByteBuf buffer, @Nonnull ImpostorShapelessRecipe recipe )
|
||||
{
|
||||
buffer.writeString( recipe.getGroup() );
|
||||
buffer.writeVarInt( recipe.getPreviewInputs()
|
||||
buffer.writeVarInt( recipe.getIngredients()
|
||||
.size() );
|
||||
|
||||
for( Ingredient ingredient : recipe.getPreviewInputs() )
|
||||
for( Ingredient ingredient : recipe.getIngredients() )
|
||||
{
|
||||
ingredient.write( buffer );
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public final class InventoryUtil
|
||||
|
||||
public static boolean areItemsStackable( @Nonnull ItemStack a, @Nonnull ItemStack b )
|
||||
{
|
||||
return a == b || (a.getItem() == b.getItem() && ItemStack.areTagsEqual( a, b ));
|
||||
return a == b || (a.getItem() == b.getItem() && ItemStack.areNbtEqual( a, b ));
|
||||
}
|
||||
|
||||
// Methods for finding inventories:
|
||||
|
||||
@@ -34,7 +34,7 @@ public interface ItemStorage
|
||||
|
||||
static boolean areStackable( @Nonnull ItemStack a, @Nonnull ItemStack b )
|
||||
{
|
||||
return a == b || (a.getItem() == b.getItem() && ItemStack.areTagsEqual( a, b ));
|
||||
return a == b || (a.getItem() == b.getItem() && ItemStack.areNbtEqual( a, b ));
|
||||
}
|
||||
|
||||
int size();
|
||||
|
||||
@@ -40,7 +40,7 @@ public final class NBTUtil
|
||||
|
||||
private NBTUtil() {}
|
||||
|
||||
private static Tag toNBTTag( Object object )
|
||||
private static NbtElement toNBTTag( Object object )
|
||||
{
|
||||
if( object == null )
|
||||
{
|
||||
@@ -48,25 +48,25 @@ public final class NBTUtil
|
||||
}
|
||||
if( object instanceof Boolean )
|
||||
{
|
||||
return ByteTag.of( (byte) ((boolean) (Boolean) object ? 1 : 0) );
|
||||
return NbtByte.of( (byte) ((boolean) (Boolean) object ? 1 : 0) );
|
||||
}
|
||||
if( object instanceof Number )
|
||||
{
|
||||
return DoubleTag.of( ((Number) object).doubleValue() );
|
||||
return NbtDouble.of( ((Number) object).doubleValue() );
|
||||
}
|
||||
if( object instanceof String )
|
||||
{
|
||||
return StringTag.of( object.toString() );
|
||||
return NbtString.of( object.toString() );
|
||||
}
|
||||
if( object instanceof Map )
|
||||
{
|
||||
Map<?, ?> m = (Map<?, ?>) object;
|
||||
CompoundTag nbt = new CompoundTag();
|
||||
NbtCompound nbt = new NbtCompound();
|
||||
int i = 0;
|
||||
for( Map.Entry<?, ?> entry : m.entrySet() )
|
||||
{
|
||||
Tag key = toNBTTag( entry.getKey() );
|
||||
Tag value = toNBTTag( entry.getKey() );
|
||||
NbtElement key = toNBTTag( entry.getKey() );
|
||||
NbtElement value = toNBTTag( entry.getKey() );
|
||||
if( key != null && value != null )
|
||||
{
|
||||
nbt.put( "k" + i, key );
|
||||
@@ -81,18 +81,18 @@ public final class NBTUtil
|
||||
return null;
|
||||
}
|
||||
|
||||
public static CompoundTag encodeObjects( Object[] objects )
|
||||
public static NbtCompound encodeObjects( Object[] objects )
|
||||
{
|
||||
if( objects == null || objects.length <= 0 )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
CompoundTag nbt = new CompoundTag();
|
||||
NbtCompound nbt = new NbtCompound();
|
||||
nbt.putInt( "len", objects.length );
|
||||
for( int i = 0; i < objects.length; i++ )
|
||||
{
|
||||
Tag child = toNBTTag( objects[i] );
|
||||
NbtElement child = toNBTTag( objects[i] );
|
||||
if( child != null )
|
||||
{
|
||||
nbt.put( Integer.toString( i ), child );
|
||||
@@ -101,7 +101,7 @@ public final class NBTUtil
|
||||
return nbt;
|
||||
}
|
||||
|
||||
private static Object fromNBTTag( Tag tag )
|
||||
private static Object fromNBTTag( NbtElement tag )
|
||||
{
|
||||
if( tag == null )
|
||||
{
|
||||
@@ -110,14 +110,14 @@ public final class NBTUtil
|
||||
switch( tag.getType() )
|
||||
{
|
||||
case TAG_BYTE:
|
||||
return ((ByteTag) tag).getByte() > 0;
|
||||
return ((NbtByte) tag).byteValue() > 0;
|
||||
case TAG_DOUBLE:
|
||||
return ((DoubleTag) tag).getDouble();
|
||||
return ((NbtDouble) tag).doubleValue();
|
||||
default:
|
||||
case TAG_STRING:
|
||||
return tag.asString();
|
||||
case TAG_COMPOUND:
|
||||
CompoundTag c = (CompoundTag) tag;
|
||||
NbtCompound c = (NbtCompound) tag;
|
||||
int len = c.getInt( "len" );
|
||||
Map<Object, Object> map = new HashMap<>( len );
|
||||
for( int i = 0; i < len; i++ )
|
||||
@@ -133,7 +133,7 @@ public final class NBTUtil
|
||||
}
|
||||
}
|
||||
|
||||
public static Object toLua( Tag tag )
|
||||
public static Object toLua( NbtElement tag )
|
||||
{
|
||||
if( tag == null )
|
||||
{
|
||||
@@ -147,15 +147,15 @@ public final class NBTUtil
|
||||
case TAG_SHORT:
|
||||
case TAG_INT:
|
||||
case TAG_LONG:
|
||||
return ((AbstractNumberTag) tag).getLong();
|
||||
return ((AbstractNbtNumber) tag).longValue();
|
||||
case TAG_FLOAT:
|
||||
case TAG_DOUBLE:
|
||||
return ((AbstractNumberTag) tag).getDouble();
|
||||
return ((AbstractNbtNumber) tag).doubleValue();
|
||||
case TAG_STRING: // String
|
||||
return tag.asString();
|
||||
case TAG_COMPOUND: // Compound
|
||||
{
|
||||
CompoundTag compound = (CompoundTag) tag;
|
||||
NbtCompound compound = (NbtCompound) tag;
|
||||
Map<String, Object> map = new HashMap<>( compound.getSize() );
|
||||
for( String key : compound.getKeys() )
|
||||
{
|
||||
@@ -169,7 +169,7 @@ public final class NBTUtil
|
||||
}
|
||||
case TAG_LIST:
|
||||
{
|
||||
ListTag list = (ListTag) tag;
|
||||
NbtList list = (NbtList) tag;
|
||||
Map<Integer, Object> map = new HashMap<>( list.size() );
|
||||
for( int i = 0; i < list.size(); i++ )
|
||||
{
|
||||
@@ -179,7 +179,7 @@ public final class NBTUtil
|
||||
}
|
||||
case TAG_BYTE_ARRAY:
|
||||
{
|
||||
byte[] array = ((ByteArrayTag) tag).getByteArray();
|
||||
byte[] array = ((NbtByteArray) tag).getByteArray();
|
||||
Map<Integer, Byte> map = new HashMap<>( array.length );
|
||||
for( int i = 0; i < array.length; i++ )
|
||||
{
|
||||
@@ -188,7 +188,7 @@ public final class NBTUtil
|
||||
return map;
|
||||
}
|
||||
case TAG_INT_ARRAY:
|
||||
int[] array = ((IntArrayTag) tag).getIntArray();
|
||||
int[] array = ((NbtIntArray) tag).getIntArray();
|
||||
Map<Integer, Integer> map = new HashMap<>( array.length );
|
||||
for( int i = 0; i < array.length; i++ )
|
||||
{
|
||||
@@ -201,7 +201,7 @@ public final class NBTUtil
|
||||
}
|
||||
}
|
||||
|
||||
public static Object[] decodeObjects( CompoundTag tag )
|
||||
public static Object[] decodeObjects( NbtCompound tag )
|
||||
{
|
||||
int len = tag.getInt( "len" );
|
||||
if( len <= 0 )
|
||||
@@ -222,7 +222,7 @@ public final class NBTUtil
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static String getNBTHash( @Nullable CompoundTag tag )
|
||||
public static String getNBTHash( @Nullable NbtCompound tag )
|
||||
{
|
||||
if( tag == null )
|
||||
{
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
package dan200.computercraft.shared.util;
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
|
||||
public class Palette
|
||||
@@ -83,7 +83,7 @@ public class Palette
|
||||
}
|
||||
}
|
||||
|
||||
public CompoundTag writeToNBT( CompoundTag nbt )
|
||||
public NbtCompound writeToNBT( NbtCompound nbt )
|
||||
{
|
||||
int[] rgb8 = new int[colours.length];
|
||||
|
||||
@@ -105,7 +105,7 @@ public class Palette
|
||||
return (r << 16) | (g << 8) | b;
|
||||
}
|
||||
|
||||
public void readFromNBT( CompoundTag nbt )
|
||||
public void readFromNBT( NbtCompound nbt )
|
||||
{
|
||||
if( !nbt.contains( "term_palette" ) )
|
||||
{
|
||||
|
||||
@@ -62,7 +62,7 @@ public final class WorldUtil
|
||||
|
||||
// Raycast for blocks
|
||||
Entity collisionEntity = getEntity( world );
|
||||
collisionEntity.updatePosition( vecStart.x, vecStart.y, vecStart.z );
|
||||
collisionEntity.setPosition( vecStart.x, vecStart.y, vecStart.z );
|
||||
RaycastContext context = new RaycastContext( vecStart,
|
||||
vecEnd,
|
||||
RaycastContext.ShapeType.COLLIDER,
|
||||
|
||||
Reference in New Issue
Block a user