mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-09-01 10:07:56 +00:00
IT COMPILES! but crashes when placing a block.
This commit is contained in:
11
build.gradle
11
build.gradle
@@ -62,14 +62,9 @@ dependencies {
|
|||||||
processResources {
|
processResources {
|
||||||
inputs.property "version", project.version
|
inputs.property "version", project.version
|
||||||
|
|
||||||
from(sourceSets.main.resources.srcDirs) {
|
filesMatching("fabric.mod.json") {
|
||||||
include "fabric.mod.json"
|
expand "version": project.version
|
||||||
expand "version": project.version
|
}
|
||||||
}
|
|
||||||
|
|
||||||
from(sourceSets.main.resources.srcDirs) {
|
|
||||||
exclude "fabric.mod.json"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ensure that the encoding is set to UTF-8, no matter what the system default is
|
// ensure that the encoding is set to UTF-8, no matter what the system default is
|
||||||
|
@@ -347,10 +347,5 @@ public class FakePlayer extends ServerPlayerEntity
|
|||||||
public void disableAutoRead()
|
public void disableAutoRead()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setCompressionThreshold( int size )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -32,7 +32,7 @@ public final class FixedWidthFontRenderer
|
|||||||
private static final Matrix4f IDENTITY = AffineTransformation.identity()
|
private static final Matrix4f IDENTITY = AffineTransformation.identity()
|
||||||
.getMatrix();
|
.getMatrix();
|
||||||
public static final Identifier FONT = new Identifier( "computercraft", "textures/gui/term_font.png" );
|
public static final Identifier FONT = new Identifier( "computercraft", "textures/gui/term_font.png" );
|
||||||
public static final RenderLayer TYPE = Type.MAIN;
|
// public static final RenderLayer TYPE = Type.MAIN;
|
||||||
|
|
||||||
|
|
||||||
private FixedWidthFontRenderer()
|
private FixedWidthFontRenderer()
|
||||||
@@ -48,7 +48,7 @@ public final class FixedWidthFontRenderer
|
|||||||
.getBufferBuilders()
|
.getBufferBuilders()
|
||||||
.getEntityVertexConsumers();
|
.getEntityVertexConsumers();
|
||||||
drawString( IDENTITY,
|
drawString( IDENTITY,
|
||||||
((VertexConsumerProvider) renderer).getBuffer( TYPE ),
|
Tessellator.getInstance().getBuffer(),
|
||||||
x,
|
x,
|
||||||
y,
|
y,
|
||||||
text,
|
text,
|
||||||
@@ -347,9 +347,9 @@ public final class FixedWidthFontRenderer
|
|||||||
VertexConsumerProvider.Immediate renderer = MinecraftClient.getInstance()
|
VertexConsumerProvider.Immediate renderer = MinecraftClient.getInstance()
|
||||||
.getBufferBuilders()
|
.getBufferBuilders()
|
||||||
.getEntityVertexConsumers();
|
.getEntityVertexConsumers();
|
||||||
VertexConsumer buffer = renderer.getBuffer( TYPE );
|
VertexConsumer buffer = Tessellator.getInstance().getBuffer();
|
||||||
drawTerminal( transform, buffer, x, y, terminal, greyscale, topMarginSize, bottomMarginSize, leftMarginSize, rightMarginSize );
|
drawTerminal( transform, buffer, x, y, terminal, greyscale, topMarginSize, bottomMarginSize, leftMarginSize, rightMarginSize );
|
||||||
renderer.draw( TYPE );
|
renderer.draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void drawTerminal( float x, float y, @Nonnull Terminal terminal, boolean greyscale, float topMarginSize, float bottomMarginSize,
|
public static void drawTerminal( float x, float y, @Nonnull Terminal terminal, boolean greyscale, float topMarginSize, float bottomMarginSize,
|
||||||
@@ -378,44 +378,44 @@ public final class FixedWidthFontRenderer
|
|||||||
float height )
|
float height )
|
||||||
{
|
{
|
||||||
Colour colour = Colour.BLACK;
|
Colour colour = Colour.BLACK;
|
||||||
drawQuad( transform, renderer.getBuffer( TYPE ), x, y, width, height, colour.getR(), colour.getG(), colour.getB() );
|
drawQuad( transform, Tessellator.getInstance().getBuffer(), x, y, width, height, colour.getR(), colour.getG(), colour.getB() );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void drawBlocker( @Nonnull Matrix4f transform, @Nonnull VertexConsumerProvider renderer, float x, float y, float width, float height )
|
public static void drawBlocker( @Nonnull Matrix4f transform, @Nonnull VertexConsumerProvider renderer, float x, float y, float width, float height )
|
||||||
{
|
{
|
||||||
Colour colour = Colour.BLACK;
|
Colour colour = Colour.BLACK;
|
||||||
drawQuad( transform, renderer.getBuffer( Type.BLOCKER ), x, y, width, height, colour.getR(), colour.getG(), colour.getB() );
|
drawQuad( transform, Tessellator.getInstance().getBuffer(), x, y, width, height, colour.getR(), colour.getG(), colour.getB() );
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final class Type extends RenderPhase
|
// private static final class Type extends RenderPhase
|
||||||
{
|
// {
|
||||||
private static final int GL_MODE = GL11.GL_TRIANGLES;
|
// private static final int GL_MODE = GL11.GL_TRIANGLES;
|
||||||
|
//
|
||||||
private static final VertexFormat FORMAT = VertexFormats.POSITION_COLOR_TEXTURE;
|
// 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
|
// 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,
|
// .texture( new RenderPhase.Texture( FONT,
|
||||||
false,
|
// false,
|
||||||
false ) ) // blur, minimap
|
// false ) ) // blur, minimap
|
||||||
.transparency( TRANSLUCENT_TRANSPARENCY )
|
// .transparency( TRANSLUCENT_TRANSPARENCY )
|
||||||
.lightmap( DISABLE_LIGHTMAP )
|
// .lightmap( DISABLE_LIGHTMAP )
|
||||||
.writeMaskState( COLOR_MASK )
|
// .writeMaskState( COLOR_MASK )
|
||||||
.build( false ) );
|
// .build( false ) );
|
||||||
|
//
|
||||||
static final RenderLayer BLOCKER = RenderLayer.of( "terminal_blocker", FORMAT, GL_MODE, 256, false, false, // useDelegate, needsSorting
|
// static final RenderLayer BLOCKER = RenderLayer.of( "terminal_blocker", FORMAT, GL_MODE, 256, false, false, // useDelegate, needsSorting
|
||||||
RenderLayer.MultiPhaseParameters.Builder()
|
// RenderLayer.MultiPhaseParameters.Builder()
|
||||||
.texture( new RenderPhase.Texture( FONT,
|
// .texture( new RenderPhase.Texture( FONT,
|
||||||
false,
|
// false,
|
||||||
false ) ) // blur, minimap
|
// false ) ) // blur, minimap
|
||||||
.transparency( TRANSLUCENT_TRANSPARENCY )
|
// .transparency( TRANSLUCENT_TRANSPARENCY )
|
||||||
.writeMaskState( ALL_MASK )
|
// .writeMaskState( ALL_MASK )
|
||||||
.lightmap( DISABLE_LIGHTMAP )
|
// .lightmap( DISABLE_LIGHTMAP )
|
||||||
.build( false ) );
|
// .build( false ) );
|
||||||
|
//
|
||||||
private Type( String name, Runnable setup, Runnable destroy )
|
// private Type( String name, Runnable setup, Runnable destroy )
|
||||||
{
|
// {
|
||||||
super( name, setup, destroy );
|
// super( name, setup, destroy );
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
@@ -53,7 +53,7 @@ public final class PrintoutRenderer
|
|||||||
|
|
||||||
public static void drawText( Matrix4f transform, VertexConsumerProvider renderer, int x, int y, int start, TextBuffer[] text, TextBuffer[] colours )
|
public static void drawText( Matrix4f transform, VertexConsumerProvider renderer, int x, int y, int start, TextBuffer[] text, TextBuffer[] colours )
|
||||||
{
|
{
|
||||||
VertexConsumer buffer = renderer.getBuffer( FixedWidthFontRenderer.TYPE );
|
VertexConsumer buffer = Tessellator.getInstance().getBuffer();
|
||||||
for( int line = 0; line < LINES_PER_PAGE && line < text.length; line++ )
|
for( int line = 0; line < LINES_PER_PAGE && line < text.length; line++ )
|
||||||
{
|
{
|
||||||
FixedWidthFontRenderer.drawString( transform,
|
FixedWidthFontRenderer.drawString( transform,
|
||||||
@@ -72,7 +72,7 @@ public final class PrintoutRenderer
|
|||||||
|
|
||||||
public static void drawText( Matrix4f transform, VertexConsumerProvider renderer, int x, int y, int start, String[] text, String[] colours )
|
public static void drawText( Matrix4f transform, VertexConsumerProvider renderer, int x, int y, int start, String[] text, String[] colours )
|
||||||
{
|
{
|
||||||
VertexConsumer buffer = renderer.getBuffer( FixedWidthFontRenderer.TYPE );
|
VertexConsumer buffer = Tessellator.getInstance().getBuffer();
|
||||||
for( int line = 0; line < LINES_PER_PAGE && line < text.length; line++ )
|
for( int line = 0; line < LINES_PER_PAGE && line < text.length; line++ )
|
||||||
{
|
{
|
||||||
FixedWidthFontRenderer.drawString( transform,
|
FixedWidthFontRenderer.drawString( transform,
|
||||||
@@ -94,7 +94,7 @@ public final class PrintoutRenderer
|
|||||||
int leftPages = page;
|
int leftPages = page;
|
||||||
int rightPages = pages - page - 1;
|
int rightPages = pages - page - 1;
|
||||||
|
|
||||||
VertexConsumer buffer = renderer.getBuffer( Type.TYPE );
|
VertexConsumer buffer = Tessellator.getInstance().getBuffer();
|
||||||
|
|
||||||
if( isBook )
|
if( isBook )
|
||||||
{
|
{
|
||||||
@@ -187,28 +187,28 @@ public final class PrintoutRenderer
|
|||||||
.next();
|
.next();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final class Type extends RenderLayer
|
// private static final class Type extends RenderLayer
|
||||||
{
|
// {
|
||||||
|
//
|
||||||
static final RenderLayer TYPE = RenderLayer.of( "printout_background",
|
// static final RenderLayer TYPE = RenderLayer.of( "printout_background",
|
||||||
VertexFormats.POSITION_TEXTURE,
|
// VertexFormats.POSITION_TEXTURE,
|
||||||
GL11.GL_QUADS,
|
// GL11.GL_QUADS,
|
||||||
1024,
|
// 1024,
|
||||||
false,
|
// false,
|
||||||
false,
|
// false,
|
||||||
// useDelegate, needsSorting
|
// // useDelegate, needsSorting
|
||||||
Type.MultiPhaseParameters.builder()
|
// Type.MultiPhaseParameters.builder()
|
||||||
.texture( new RenderPhase.Texture( BG, false, false ) ) // blur, minimap
|
// .texture( new RenderPhase.Texture( BG, false, false ) ) // blur, minimap
|
||||||
.transparency( TRANSLUCENT_TRANSPARENCY)
|
// .transparency( TRANSLUCENT_TRANSPARENCY)
|
||||||
.lightmap( DISABLE_LIGHTMAP )
|
// .lightmap( DISABLE_LIGHTMAP )
|
||||||
.build( false ) );
|
// .build( false ) );
|
||||||
|
//
|
||||||
public Type( String name, VertexFormat vertexFormat, DrawMode drawMode,
|
// public Type( String name, VertexFormat vertexFormat, DrawMode drawMode,
|
||||||
int expectedBufferSize, boolean hasCrumbling, boolean translucent,
|
// int expectedBufferSize, boolean hasCrumbling, boolean translucent,
|
||||||
Runnable startAction, Runnable endAction )
|
// Runnable startAction, Runnable endAction )
|
||||||
{
|
// {
|
||||||
super( name, vertexFormat, drawMode, expectedBufferSize, hasCrumbling, translucent,
|
// super( name, vertexFormat, drawMode, expectedBufferSize, hasCrumbling, translucent,
|
||||||
startAction, endAction );
|
// startAction, endAction );
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
@@ -34,6 +34,8 @@ import org.lwjgl.opengl.GL20;
|
|||||||
import org.lwjgl.opengl.GL31;
|
import org.lwjgl.opengl.GL31;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
import java.nio.Buffer;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
|
||||||
import static dan200.computercraft.client.gui.FixedWidthFontRenderer.*;
|
import static dan200.computercraft.client.gui.FixedWidthFontRenderer.*;
|
||||||
@@ -125,8 +127,9 @@ public class TileEntityMonitorRenderer implements BlockEntityRenderer<TileMonito
|
|||||||
// Sneaky hack here: we get a buffer now in order to flush existing ones and set up the appropriate
|
// Sneaky hack here: we get a buffer now in order to flush existing ones and set up the appropriate
|
||||||
// render state. I've no clue how well this'll work in future versions of Minecraft, but it does the trick
|
// render state. I've no clue how well this'll work in future versions of Minecraft, but it does the trick
|
||||||
// for now.
|
// for now.
|
||||||
VertexConsumer buffer = renderer.getBuffer( FixedWidthFontRenderer.TYPE );
|
BufferBuilder buffer = Tessellator.getInstance().getBuffer();
|
||||||
FixedWidthFontRenderer.TYPE.startDrawing();
|
buffer.begin( VertexFormat.DrawMode.TRIANGLE_STRIP, VertexFormats.POSITION_COLOR_TEXTURE );
|
||||||
|
// FixedWidthFontRenderer.TYPE.startDrawing();
|
||||||
|
|
||||||
renderTerminal( matrix, originTerminal, (float) (MARGIN / xScale), (float) (MARGIN / yScale) );
|
renderTerminal( matrix, originTerminal, (float) (MARGIN / xScale), (float) (MARGIN / yScale) );
|
||||||
|
|
||||||
@@ -136,7 +139,7 @@ public class TileEntityMonitorRenderer implements BlockEntityRenderer<TileMonito
|
|||||||
|
|
||||||
// To go along with sneaky hack above: make sure state changes are undone. I would have thought this would
|
// To go along with sneaky hack above: make sure state changes are undone. I would have thought this would
|
||||||
// happen automatically after these buffers are drawn, but chests will render weird around monitors without this.
|
// happen automatically after these buffers are drawn, but chests will render weird around monitors without this.
|
||||||
FixedWidthFontRenderer.TYPE.endDrawing();
|
buffer.end();
|
||||||
|
|
||||||
transform.pop();
|
transform.pop();
|
||||||
}
|
}
|
||||||
@@ -233,7 +236,7 @@ public class TileEntityMonitorRenderer implements BlockEntityRenderer<TileMonito
|
|||||||
{
|
{
|
||||||
Tessellator tessellator = Tessellator.getInstance();
|
Tessellator tessellator = Tessellator.getInstance();
|
||||||
BufferBuilder builder = tessellator.getBuffer();
|
BufferBuilder builder = tessellator.getBuffer();
|
||||||
builder.begin( FixedWidthFontRenderer.TYPE.getDrawMode(), FixedWidthFontRenderer.TYPE.getVertexFormat() );
|
builder.begin( VertexFormat.DrawMode.TRIANGLE_STRIP, VertexFormats.POSITION_COLOR_TEXTURE );
|
||||||
FixedWidthFontRenderer.drawTerminalWithoutCursor( IDENTITY,
|
FixedWidthFontRenderer.drawTerminalWithoutCursor( IDENTITY,
|
||||||
builder,
|
builder,
|
||||||
0,
|
0,
|
||||||
@@ -250,12 +253,12 @@ public class TileEntityMonitorRenderer implements BlockEntityRenderer<TileMonito
|
|||||||
}
|
}
|
||||||
|
|
||||||
vbo.bind();
|
vbo.bind();
|
||||||
FixedWidthFontRenderer.TYPE.getVertexFormat()
|
VertexFormats.POSITION_COLOR_TEXTURE
|
||||||
.startDrawing();
|
.startDrawing();
|
||||||
// vbo.draw( matrix, FixedWidthFontRenderer.TYPE.getDrawMode() );
|
// vbo.draw( matrix, FixedWidthFontRenderer.TYPE.getDrawMode() );
|
||||||
vbo.drawElements(); //FIXME: Is this ok?
|
vbo.drawElements(); //FIXME: Is this ok?
|
||||||
VertexBuffer.unbind();
|
VertexBuffer.unbind();
|
||||||
FixedWidthFontRenderer.TYPE.getVertexFormat()
|
VertexFormats.POSITION_COLOR_TEXTURE
|
||||||
.endDrawing();
|
.endDrawing();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@@ -7,9 +7,13 @@ package dan200.computercraft.fabric.mixin;
|
|||||||
|
|
||||||
import dan200.computercraft.shared.util.DropConsumer;
|
import dan200.computercraft.shared.util.DropConsumer;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.entity.ItemEntity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
@@ -23,12 +27,12 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|||||||
@Mixin( Block.class )
|
@Mixin( Block.class )
|
||||||
public class MixinBlock
|
public class MixinBlock
|
||||||
{
|
{
|
||||||
@Inject( method = "dropStack",
|
@Inject( method = "dropStack(Lnet/minecraft/world/World;Ljava/util/function/Supplier;Lnet/minecraft/item/ItemStack;)V",
|
||||||
at = @At( value = "INVOKE", target = "Lnet/minecraft/world/World;spawnEntity(Lnet/minecraft/entity/Entity;)Z" ),
|
at = @At( value = "HEAD" ),
|
||||||
cancellable = true )
|
cancellable = true )
|
||||||
private static void dropStack( World world, BlockPos pos, ItemStack stack, CallbackInfo callbackInfo )
|
private static void dropStack( World world, Supplier<ItemEntity> itemEntitySupplier, ItemStack stack, CallbackInfo callbackInfo )
|
||||||
{
|
{
|
||||||
if( DropConsumer.onHarvestDrops( world, pos, stack ) )
|
if( DropConsumer.onHarvestDrops( world, itemEntitySupplier.get().getBlockPos(), stack ) )
|
||||||
{
|
{
|
||||||
callbackInfo.cancel();
|
callbackInfo.cancel();
|
||||||
}
|
}
|
||||||
|
@@ -9,7 +9,7 @@ import net.minecraft.block.entity.BlockEntity;
|
|||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
@Mixin( BlockEntity.class )
|
@Mixin( BlockEntity.class )
|
||||||
public class BlockEntityMixin
|
public class MixinBlockEntity
|
||||||
{
|
{
|
||||||
@Final
|
@Final
|
||||||
@Mutable
|
@Mutable
|
@@ -29,14 +29,14 @@ public class MixinWorld
|
|||||||
@Shadow
|
@Shadow
|
||||||
protected boolean iteratingTickingBlockEntities;
|
protected boolean iteratingTickingBlockEntities;
|
||||||
|
|
||||||
@Inject( method = "setBlockEntity", at = @At( "HEAD" ) )
|
// @Inject( method = "setBlockEntity", at = @At( "HEAD" ) )
|
||||||
public void setBlockEntity( BlockPos pos, @Nullable BlockEntity entity, CallbackInfo info )
|
// public void setBlockEntity( BlockPos pos, @Nullable BlockEntity entity, CallbackInfo info )
|
||||||
{
|
// {
|
||||||
if( entity != null && !entity.isRemoved() && entity.getWorld().isInBuildLimit(pos) && iteratingTickingBlockEntities )
|
// if( entity != null && !entity.isRemoved() && entity.getWorld().isInBuildLimit(pos) && iteratingTickingBlockEntities )
|
||||||
{
|
// {
|
||||||
setWorld( entity, this );
|
// setWorld( entity, this );
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
private static void setWorld( BlockEntity entity, Object world )
|
private static void setWorld( BlockEntity entity, Object world )
|
||||||
{
|
{
|
||||||
@@ -46,15 +46,15 @@ public class MixinWorld
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject( method = "addBlockEntities", at = @At( "HEAD" ) )
|
// @Inject( method = "addBlockEntities", at = @At( "HEAD" ) )
|
||||||
public void addBlockEntities( Collection<BlockEntity> entities, CallbackInfo info )
|
// public void addBlockEntities( Collection<BlockEntity> entities, CallbackInfo info )
|
||||||
{
|
// {
|
||||||
if( iteratingTickingBlockEntities )
|
// if( iteratingTickingBlockEntities )
|
||||||
{
|
// {
|
||||||
for( BlockEntity entity : entities )
|
// for( BlockEntity entity : entities )
|
||||||
{
|
// {
|
||||||
setWorld( entity, this );
|
// setWorld( entity, this );
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
@@ -14,5 +14,5 @@ import org.spongepowered.asm.mixin.gen.Accessor;
|
|||||||
public interface SignBlockEntityAccess
|
public interface SignBlockEntityAccess
|
||||||
{
|
{
|
||||||
@Accessor
|
@Accessor
|
||||||
Text[] getText();
|
Text[] getTexts();
|
||||||
}
|
}
|
||||||
|
@@ -18,7 +18,7 @@ public interface IComputerItem
|
|||||||
|
|
||||||
default int getComputerID( @Nonnull ItemStack stack )
|
default int getComputerID( @Nonnull ItemStack stack )
|
||||||
{
|
{
|
||||||
NbtCompound nbt = stack.getTag();
|
NbtCompound nbt = stack.getNbt();
|
||||||
return nbt != null && nbt.contains( NBT_ID ) ? nbt.getInt( NBT_ID ) : -1;
|
return nbt != null && nbt.contains( NBT_ID ) ? nbt.getInt( NBT_ID ) : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -25,7 +25,7 @@ public class ItemComputer extends ItemComputerBase
|
|||||||
ItemStack result = new ItemStack( this );
|
ItemStack result = new ItemStack( this );
|
||||||
if( id >= 0 )
|
if( id >= 0 )
|
||||||
{
|
{
|
||||||
result.getOrCreateTag()
|
result.getOrCreateNbt()
|
||||||
.putInt( NBT_ID, id );
|
.putInt( NBT_ID, id );
|
||||||
}
|
}
|
||||||
if( label != null )
|
if( label != null )
|
||||||
|
@@ -78,14 +78,14 @@ public class ItemDisk extends Item implements IMedia, IColouredItem
|
|||||||
{
|
{
|
||||||
if( id >= 0 )
|
if( id >= 0 )
|
||||||
{
|
{
|
||||||
stack.getOrCreateTag()
|
stack.getOrCreateNbt()
|
||||||
.putInt( NBT_ID, id );
|
.putInt( NBT_ID, id );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getDiskID( @Nonnull ItemStack stack )
|
public static int getDiskID( @Nonnull ItemStack stack )
|
||||||
{
|
{
|
||||||
NbtCompound nbt = stack.getTag();
|
NbtCompound nbt = stack.getNbt();
|
||||||
return nbt != null && nbt.contains( NBT_ID ) ? nbt.getInt( NBT_ID ) : -1;
|
return nbt != null && nbt.contains( NBT_ID ) ? nbt.getInt( NBT_ID ) : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -55,12 +55,12 @@ public class ItemPrintout extends Item
|
|||||||
// Build NBT
|
// Build NBT
|
||||||
if( title != null )
|
if( title != null )
|
||||||
{
|
{
|
||||||
stack.getOrCreateTag()
|
stack.getOrCreateNbt()
|
||||||
.putString( NBT_TITLE, title );
|
.putString( NBT_TITLE, title );
|
||||||
}
|
}
|
||||||
if( text != null )
|
if( text != null )
|
||||||
{
|
{
|
||||||
NbtCompound tag = stack.getOrCreateTag();
|
NbtCompound tag = stack.getOrCreateNbt();
|
||||||
tag.putInt( NBT_PAGES, text.length / LINES_PER_PAGE );
|
tag.putInt( NBT_PAGES, text.length / LINES_PER_PAGE );
|
||||||
for( int i = 0; i < text.length; i++ )
|
for( int i = 0; i < text.length; i++ )
|
||||||
{
|
{
|
||||||
@@ -72,7 +72,7 @@ public class ItemPrintout extends Item
|
|||||||
}
|
}
|
||||||
if( colours != null )
|
if( colours != null )
|
||||||
{
|
{
|
||||||
NbtCompound tag = stack.getOrCreateTag();
|
NbtCompound tag = stack.getOrCreateNbt();
|
||||||
for( int i = 0; i < colours.length; i++ )
|
for( int i = 0; i < colours.length; i++ )
|
||||||
{
|
{
|
||||||
if( colours[i] != null )
|
if( colours[i] != null )
|
||||||
@@ -105,7 +105,7 @@ public class ItemPrintout extends Item
|
|||||||
|
|
||||||
private static String[] getLines( @Nonnull ItemStack stack, String prefix )
|
private static String[] getLines( @Nonnull ItemStack stack, String prefix )
|
||||||
{
|
{
|
||||||
NbtCompound nbt = stack.getTag();
|
NbtCompound nbt = stack.getNbt();
|
||||||
int numLines = getPageCount( stack ) * LINES_PER_PAGE;
|
int numLines = getPageCount( stack ) * LINES_PER_PAGE;
|
||||||
String[] lines = new String[numLines];
|
String[] lines = new String[numLines];
|
||||||
for( int i = 0; i < lines.length; i++ )
|
for( int i = 0; i < lines.length; i++ )
|
||||||
@@ -117,7 +117,7 @@ public class ItemPrintout extends Item
|
|||||||
|
|
||||||
public static int getPageCount( @Nonnull ItemStack stack )
|
public static int getPageCount( @Nonnull ItemStack stack )
|
||||||
{
|
{
|
||||||
NbtCompound nbt = stack.getTag();
|
NbtCompound nbt = stack.getNbt();
|
||||||
return nbt != null && nbt.contains( NBT_PAGES ) ? nbt.getInt( NBT_PAGES ) : 1;
|
return nbt != null && nbt.contains( NBT_PAGES ) ? nbt.getInt( NBT_PAGES ) : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,7 +152,7 @@ public class ItemPrintout extends Item
|
|||||||
|
|
||||||
public static String getTitle( @Nonnull ItemStack stack )
|
public static String getTitle( @Nonnull ItemStack stack )
|
||||||
{
|
{
|
||||||
NbtCompound nbt = stack.getTag();
|
NbtCompound nbt = stack.getNbt();
|
||||||
return nbt != null && nbt.contains( NBT_TITLE ) ? nbt.getString( NBT_TITLE ) : null;
|
return nbt != null && nbt.contains( NBT_TITLE ) ? nbt.getString( NBT_TITLE ) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -41,7 +41,7 @@ public class ItemTreasureDisk extends Item implements IMedia
|
|||||||
public static ItemStack create( String subPath, int colourIndex )
|
public static ItemStack create( String subPath, int colourIndex )
|
||||||
{
|
{
|
||||||
ItemStack result = new ItemStack( ComputerCraftRegistry.ModItems.TREASURE_DISK );
|
ItemStack result = new ItemStack( ComputerCraftRegistry.ModItems.TREASURE_DISK );
|
||||||
NbtCompound nbt = result.getOrCreateTag();
|
NbtCompound nbt = result.getOrCreateNbt();
|
||||||
nbt.putString( NBT_SUB_PATH, subPath );
|
nbt.putString( NBT_SUB_PATH, subPath );
|
||||||
|
|
||||||
int slash = subPath.indexOf( '/' );
|
int slash = subPath.indexOf( '/' );
|
||||||
@@ -62,7 +62,7 @@ public class ItemTreasureDisk extends Item implements IMedia
|
|||||||
|
|
||||||
public static int getColour( @Nonnull ItemStack stack )
|
public static int getColour( @Nonnull ItemStack stack )
|
||||||
{
|
{
|
||||||
NbtCompound nbt = stack.getTag();
|
NbtCompound nbt = stack.getNbt();
|
||||||
return nbt != null && nbt.contains( NBT_COLOUR ) ? nbt.getInt( NBT_COLOUR ) : Colour.BLUE.getHex();
|
return nbt != null && nbt.contains( NBT_COLOUR ) ? nbt.getInt( NBT_COLOUR ) : Colour.BLUE.getHex();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,7 +84,7 @@ public class ItemTreasureDisk extends Item implements IMedia
|
|||||||
@Nonnull
|
@Nonnull
|
||||||
private static String getTitle( @Nonnull ItemStack stack )
|
private static String getTitle( @Nonnull ItemStack stack )
|
||||||
{
|
{
|
||||||
NbtCompound nbt = stack.getTag();
|
NbtCompound nbt = stack.getNbt();
|
||||||
return nbt != null && nbt.contains( NBT_TITLE ) ? nbt.getString( NBT_TITLE ) : "'alongtimeago' by dan200";
|
return nbt != null && nbt.contains( NBT_TITLE ) ? nbt.getString( NBT_TITLE ) : "'alongtimeago' by dan200";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,7 +128,7 @@ public class ItemTreasureDisk extends Item implements IMedia
|
|||||||
@Nonnull
|
@Nonnull
|
||||||
private static String getSubPath( @Nonnull ItemStack stack )
|
private static String getSubPath( @Nonnull ItemStack stack )
|
||||||
{
|
{
|
||||||
NbtCompound nbt = stack.getTag();
|
NbtCompound nbt = stack.getNbt();
|
||||||
return nbt != null && nbt.contains( NBT_SUB_PATH ) ? nbt.getString( NBT_SUB_PATH ) : "dan200/alongtimeago";
|
return nbt != null && nbt.contains( NBT_SUB_PATH ) ? nbt.getString( NBT_SUB_PATH ) : "dan200/alongtimeago";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -43,7 +43,7 @@ public class ItemData
|
|||||||
public static <T extends Map<? super String, Object>> T fillBasic( @Nonnull T data, @Nonnull ItemStack stack )
|
public static <T extends Map<? super String, Object>> T fillBasic( @Nonnull T data, @Nonnull ItemStack stack )
|
||||||
{
|
{
|
||||||
fillBasicSafe( data, stack );
|
fillBasicSafe( data, stack );
|
||||||
String hash = NBTUtil.getNBTHash( stack.getTag() );
|
String hash = NBTUtil.getNBTHash( stack.getNbt() );
|
||||||
if( hash != null ) data.put( "nbt", hash );
|
if( hash != null ) data.put( "nbt", hash );
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
@@ -78,7 +78,7 @@ public class ItemData
|
|||||||
.collect( Collectors.toList() )
|
.collect( Collectors.toList() )
|
||||||
) ); // chaos x2
|
) ); // chaos x2
|
||||||
|
|
||||||
NbtCompound tag = stack.getTag();
|
NbtCompound tag = stack.getNbt();
|
||||||
if( tag != null && tag.contains( "display", NBTUtil.TAG_COMPOUND ) )
|
if( tag != null && tag.contains( "display", NBTUtil.TAG_COMPOUND ) )
|
||||||
{
|
{
|
||||||
NbtCompound displayTag = tag.getCompound( "display" );
|
NbtCompound displayTag = tag.getCompound( "display" );
|
||||||
|
@@ -26,7 +26,7 @@ public class SignInspectHandler
|
|||||||
Map<Integer, String> textTable = new HashMap<>();
|
Map<Integer, String> textTable = new HashMap<>();
|
||||||
for( int k = 0; k < 4; k++ )
|
for( int k = 0; k < 4; k++ )
|
||||||
{
|
{
|
||||||
textTable.put( k + 1, ((SignBlockEntityAccess) sbe).getText()[k].asString() );
|
textTable.put( k + 1, ((SignBlockEntityAccess) sbe).getTexts()[k].asString() );
|
||||||
}
|
}
|
||||||
event.getData().put( "text", textTable );
|
event.getData().put( "text", textTable );
|
||||||
}
|
}
|
||||||
|
@@ -12,6 +12,7 @@ import dan200.computercraft.api.turtle.ITurtleAccess;
|
|||||||
import dan200.computercraft.api.turtle.ITurtleUpgrade;
|
import dan200.computercraft.api.turtle.ITurtleUpgrade;
|
||||||
import dan200.computercraft.api.turtle.TurtleSide;
|
import dan200.computercraft.api.turtle.TurtleSide;
|
||||||
import dan200.computercraft.core.computer.ComputerSide;
|
import dan200.computercraft.core.computer.ComputerSide;
|
||||||
|
import dan200.computercraft.fabric.mixin.MixinBlockEntity;
|
||||||
import dan200.computercraft.shared.common.TileGeneric;
|
import dan200.computercraft.shared.common.TileGeneric;
|
||||||
import dan200.computercraft.shared.computer.blocks.ComputerProxy;
|
import dan200.computercraft.shared.computer.blocks.ComputerProxy;
|
||||||
import dan200.computercraft.shared.computer.blocks.TileComputerBase;
|
import dan200.computercraft.shared.computer.blocks.TileComputerBase;
|
||||||
@@ -24,6 +25,7 @@ import dan200.computercraft.shared.turtle.core.TurtleBrain;
|
|||||||
import dan200.computercraft.shared.turtle.inventory.ContainerTurtle;
|
import dan200.computercraft.shared.turtle.inventory.ContainerTurtle;
|
||||||
import dan200.computercraft.shared.util.*;
|
import dan200.computercraft.shared.util.*;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.block.entity.BlockEntity;
|
||||||
import net.minecraft.block.entity.BlockEntityType;
|
import net.minecraft.block.entity.BlockEntityType;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.entity.player.PlayerInventory;
|
import net.minecraft.entity.player.PlayerInventory;
|
||||||
@@ -254,6 +256,10 @@ public class TileTurtle extends TileComputerBase
|
|||||||
// Open GUI or whatever
|
// Open GUI or whatever
|
||||||
return super.onActivate( player, hand, hit );
|
return super.onActivate( player, hand, hit );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setBlockPos( BlockPos pos ) {
|
||||||
|
((MixinBlockEntity) (Object) this).setBlockPos(pos); // FIXME this looks really bad.
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNeighbourChange( @Nonnull BlockPos neighbour )
|
public void onNeighbourChange( @Nonnull BlockPos neighbour )
|
||||||
@@ -406,11 +412,6 @@ public class TileTurtle extends TileComputerBase
|
|||||||
onTileEntityChange();
|
onTileEntityChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBlockPos( BlockPos pos )
|
|
||||||
{
|
|
||||||
this.pos.;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onTileEntityChange()
|
public void onTileEntityChange()
|
||||||
{
|
{
|
||||||
super.markDirty();
|
super.markDirty();
|
||||||
|
@@ -256,7 +256,7 @@ public class TurtleBrain implements ITurtleAccess
|
|||||||
{
|
{
|
||||||
// Copy the old turtle state into the new turtle
|
// Copy the old turtle state into the new turtle
|
||||||
TileTurtle newTurtle = (TileTurtle) newTile;
|
TileTurtle newTurtle = (TileTurtle) newTile;
|
||||||
newTurtle.setLocation( world, pos ); //FIXME: setLocation no longer exists.
|
newTurtle.setBlockPos( pos ); //FIXME: setLocation no longer exists.
|
||||||
newTurtle.transferStateFrom( oldOwner );
|
newTurtle.transferStateFrom( oldOwner );
|
||||||
newTurtle.createServerComputer()
|
newTurtle.createServerComputer()
|
||||||
.setWorld( world );
|
.setWorld( world );
|
||||||
|
@@ -6,6 +6,7 @@
|
|||||||
"MinecraftServerAccess",
|
"MinecraftServerAccess",
|
||||||
"MixinBlock",
|
"MixinBlock",
|
||||||
"MixinEntity",
|
"MixinEntity",
|
||||||
|
"MixinBlockEntity",
|
||||||
"MixinServerWorld",
|
"MixinServerWorld",
|
||||||
"MixinWorld",
|
"MixinWorld",
|
||||||
"SignBlockEntityAccess",
|
"SignBlockEntityAccess",
|
||||||
|
@@ -21,9 +21,9 @@
|
|||||||
],
|
],
|
||||||
"depends": {
|
"depends": {
|
||||||
"fabricloader": ">=0.11.3",
|
"fabricloader": ">=0.11.3",
|
||||||
"fabric": "*"
|
"fabric": "*",
|
||||||
"minecraft": "1.17.x",
|
"minecraft": "1.17.x",
|
||||||
"java": ">=16",
|
"java": ">=16"
|
||||||
},
|
},
|
||||||
"suggests": {
|
"suggests": {
|
||||||
"modmenu": "*"
|
"modmenu": "*"
|
||||||
|
Reference in New Issue
Block a user