1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-08-28 00:12:16 +00:00

Now only need to mess with rendering...

This commit is contained in:
coolsa 2021-09-30 02:43:57 -06:00
parent 9e57150384
commit 8d3b94734d
30 changed files with 297 additions and 252 deletions

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/cc-restiched"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
</listAttribute>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/>
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.buildship.core.classpathprovider"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="net.fabricmc.devlaunchinjector.Main"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value=""/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="cc-restiched"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Dfabric.dli.config=/home/cloud/Code/Java/cc-restitched/.gradle/loom-cache/launch.cfg -Dfabric.dli.env=client -Dfabric.dli.main=net.fabricmc.loader.launch.knot.KnotClient"/>
<stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="${workspace_loc:cc-restiched}/run"/>
</launchConfiguration>

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/cc-restiched"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
</listAttribute>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/>
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.buildship.core.classpathprovider"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="net.fabricmc.devlaunchinjector.Main"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="nogui"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="cc-restiched"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Dfabric.dli.config=/home/cloud/Code/Java/cc-restitched/.gradle/loom-cache/launch.cfg -Dfabric.dli.env=server -Dfabric.dli.main=net.fabricmc.loader.launch.knot.KnotServer"/>
<stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="${workspace_loc:cc-restiched}/run"/>
</launchConfiguration>

View File

@ -5,13 +5,13 @@ org.gradle.jvmargs=-Xmx1G
mod_version=1.96.1-rc1
# Minecraft properties
mc_version=1.17
mappings_version=9
mc_version=1.17.1
mappings_version=61
# Dependencies
cloth_config_version=5.0.34
fabric_loader_version=0.11.6
fabric_api_version=0.36.0+1.16
fabric_loader_version=0.11.7
fabric_api_version=0.40.1+1.17
jankson_version=1.2.0
modmenu_version=2.0.2
cloth_api_version=2.0.54

View File

@ -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.
NbtCompound shareTag = stack.getTag();
NbtCompound 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();

View File

@ -23,15 +23,15 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public final class FixedWidthFontRenderer
{ //FIXME Make this work like a gui, via BufferBuilder's
{
public static final int FONT_HEIGHT = 9;
public static final int FONT_WIDTH = 6;
public static final float WIDTH = 256.0f;
public static final float BACKGROUND_START = (WIDTH - 6.0f) / WIDTH;
public static final float BACKGROUND_END = (WIDTH - 4.0f) / WIDTH;
private static final Matrix4f IDENTITY = AffineTransformation.identity()
.getMatrix();
private static final Identifier FONT = new Identifier( "computercraft", "textures/gui/term_font.png" );
.getMatrix();
public static final Identifier FONT = new Identifier( "computercraft", "textures/gui/term_font.png" );
public static final RenderLayer TYPE = Type.MAIN;

View File

@ -152,9 +152,9 @@ public class GuiComputer<T extends ContainerComputerBase> extends HandledScreen<
}
@Override
public void tick()
public void handledScreenTick()
{
super.tick();
super.handledScreenTick(); // FIXME most likely unneeded.
terminal.update();
}
}

View File

@ -35,12 +35,13 @@ import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientBlockEntityEvents;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents;
import net.fabricmc.fabric.api.client.model.ModelLoadingRegistry;
import net.fabricmc.fabric.api.client.rendereregistry.v1.BlockEntityRendererRegistry;
import net.fabricmc.fabric.api.client.rendereregistry.v1.EntityRendererRegistry;
import net.fabricmc.fabric.api.client.rendering.v1.BlockEntityRendererRegistry;
import net.fabricmc.fabric.api.client.rendering.v1.EntityRendererRegistry;
import net.fabricmc.fabric.api.client.screenhandler.v1.ScreenRegistry;
import net.fabricmc.fabric.api.event.client.ClientSpriteRegistryCallback;
import net.fabricmc.fabric.mixin.object.builder.ModelPredicateProviderRegistrySpecificAccessor;
import net.fabricmc.fabric.api.object.builder.v1.client.model.FabricModelPredicateProviderRegistry;
import net.minecraft.client.item.ModelPredicateProvider;
import net.minecraft.client.item.UnclampedModelPredicateProvider;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.item.Item;
import net.minecraft.screen.PlayerScreenHandler;
@ -82,10 +83,10 @@ public final class ComputerCraftProxyClient implements ClientModInitializer
BlockRenderLayerMap.INSTANCE.putBlock( ComputerCraftRegistry.ModBlocks.MONITOR_ADVANCED, RenderLayer.getCutout() );
// Setup TESRs
BlockEntityRendererRegistry.INSTANCE.register( ComputerCraftRegistry.ModTiles.MONITOR_NORMAL, TileEntityMonitorRenderer::new );
BlockEntityRendererRegistry.INSTANCE.register( ComputerCraftRegistry.ModTiles.MONITOR_ADVANCED, TileEntityMonitorRenderer::new );
BlockEntityRendererRegistry.INSTANCE.register( ComputerCraftRegistry.ModTiles.TURTLE_NORMAL, TileEntityTurtleRenderer::new );
BlockEntityRendererRegistry.INSTANCE.register( ComputerCraftRegistry.ModTiles.TURTLE_ADVANCED, TileEntityTurtleRenderer::new );
BlockEntityRendererRegistry.register( ComputerCraftRegistry.ModTiles.MONITOR_NORMAL, TileEntityMonitorRenderer::new );
BlockEntityRendererRegistry.register( ComputerCraftRegistry.ModTiles.MONITOR_ADVANCED, TileEntityMonitorRenderer::new );
BlockEntityRendererRegistry.register( ComputerCraftRegistry.ModTiles.TURTLE_NORMAL, TileEntityTurtleRenderer::new );
BlockEntityRendererRegistry.register( ComputerCraftRegistry.ModTiles.TURTLE_ADVANCED, TileEntityTurtleRenderer::new );
ClientSpriteRegistryCallback.event( PlayerScreenHandler.BLOCK_ATLAS_TEXTURE )
.register( ClientRegistry::onTextureStitchEvent );
@ -94,15 +95,15 @@ public final class ComputerCraftProxyClient implements ClientModInitializer
TurtleModelLoader.INSTANCE.loadModel(
name ) : null );
EntityRendererRegistry.INSTANCE.register( ComputerCraftRegistry.ModEntities.TURTLE_PLAYER, TurtlePlayerRenderer::new );
EntityRendererRegistry.register( ComputerCraftRegistry.ModEntities.TURTLE_PLAYER, TurtlePlayerRenderer::new );
registerItemProperty( "state",
( stack, world, player ) -> ItemPocketComputer.getState( stack )
( stack, world, player, integer ) -> ItemPocketComputer.getState( stack )
.ordinal(),
() -> ComputerCraftRegistry.ModItems.POCKET_COMPUTER_NORMAL,
() -> ComputerCraftRegistry.ModItems.POCKET_COMPUTER_ADVANCED );
registerItemProperty( "state",
( stack, world, player ) -> IColouredItem.getColourBasic( stack ) != -1 ? 1 : 0,
( stack, world, player, integer ) -> IColouredItem.getColourBasic( stack ) != -1 ? 1 : 0,
() -> ComputerCraftRegistry.ModItems.POCKET_COMPUTER_NORMAL,
() -> ComputerCraftRegistry.ModItems.POCKET_COMPUTER_ADVANCED );
ClientRegistry.onItemColours();
@ -127,12 +128,12 @@ public final class ComputerCraftProxyClient implements ClientModInitializer
}
@SafeVarargs
private static void registerItemProperty( String name, ModelPredicateProvider getter, Supplier<? extends Item>... items )
private static void registerItemProperty( String name, UnclampedModelPredicateProvider getter, Supplier<? extends Item>... items )
{
Identifier id = new Identifier( ComputerCraft.MOD_ID, name );
for( Supplier<? extends Item> item : items )
{
ModelPredicateProviderRegistrySpecificAccessor.callRegister( item.get(), id, getter );
FabricModelPredicateProviderRegistry.register( item.get(), id, getter );
}
}
}

View File

@ -89,7 +89,7 @@ public class ComputerBorderRenderer
render( IDENTITY, buffer, x, y, z, width, height );
RenderSystem.enableDepthTest(); //TODO: enableAlphaTest(). FIXME
// RenderSystem.enableDepthTest(); //TODO: enableAlphaTest(). FIXME
tessellator.draw();
}

View File

@ -19,7 +19,7 @@ import static dan200.computercraft.client.gui.FixedWidthFontRenderer.FONT_HEIGHT
import static dan200.computercraft.shared.media.items.ItemPrintout.LINES_PER_PAGE;
public final class PrintoutRenderer
{ //FIXME Use BufferBuilders
{
/**
* Width of a page.
*/
@ -189,20 +189,26 @@ public final class PrintoutRenderer
private static final class Type extends RenderLayer
{
static final RenderLayer TYPE = RenderLayer.of( "printout_background",
VertexFormats.POSITION_TEXTURE,
VertexFormat.DrawMode.QUADS,
GL11.GL_QUADS,
1024,
false,
false,
// useDelegate, needsSorting
RenderLayer.MultiPhaseParameters.builder()
Type.MultiPhaseParameters.builder()
.texture( new RenderPhase.Texture( BG, false, false ) ) // blur, minimap
.transparency( TRANSLUCENT_TRANSPARENCY )
.transparency( TRANSLUCENT_TRANSPARENCY)
.lightmap( DISABLE_LIGHTMAP )
.build( false ));
private Type( String name, VertexFormat vertexFormat, VertexFormat.DrawMode drawMode, int expectedBufferSize, boolean hasCrumbling, boolean translucent, RenderLayer.MultiPhaseParameters phases, Runnable setup, Runnable destroy )
.build( false ) );
public Type( String name, VertexFormat vertexFormat, DrawMode drawMode,
int expectedBufferSize, boolean hasCrumbling, boolean translucent,
Runnable startAction, Runnable endAction )
{
super( name, vertexFormat, drawMode, expectedBufferSize, hasCrumbling, hasCrumbling, setup, destroy );
super( name, vertexFormat, drawMode, expectedBufferSize, hasCrumbling, translucent,
startAction, endAction );
}
}
}

View File

@ -20,6 +20,7 @@ import net.minecraft.client.gl.VertexBuffer;
import net.minecraft.client.render.*;
import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher;
import net.minecraft.client.render.block.entity.BlockEntityRenderer;
import net.minecraft.client.render.block.entity.BlockEntityRendererFactory;
import net.minecraft.client.util.GlAllocationUtils;
import net.minecraft.util.math.AffineTransformation;
import net.minecraft.client.util.math.MatrixStack;
@ -47,11 +48,10 @@ public class TileEntityMonitorRenderer implements BlockEntityRenderer<TileMonito
.getMatrix();
private static ByteBuffer tboContents;
public TileEntityMonitorRenderer( BlockEntityRenderDispatcher rendererDispatcher )
public TileEntityMonitorRenderer( BlockEntityRendererFactory.Context context )
{
super( rendererDispatcher );
// super( rendererDispatcher );
}
@Override
public void render( @Nonnull TileMonitor monitor, float partialTicks, @Nonnull MatrixStack transform, @Nonnull VertexConsumerProvider renderer,
int lightmapCoord, int overlayLight )
@ -198,22 +198,21 @@ public class TileEntityMonitorRenderer implements BlockEntityRenderer<TileMonito
}
}
monitorBuffer.flip();
GlStateManager.bindBuffers( GL31.GL_TEXTURE_BUFFER, monitor.tboBuffer );
GlStateManager.bufferData( GL31.GL_TEXTURE_BUFFER, monitorBuffer, GL20.GL_STATIC_DRAW );
GlStateManager.bindBuffers( GL31.GL_TEXTURE_BUFFER, 0 );
GlStateManager._glBindBuffer( GL31.GL_TEXTURE_BUFFER, monitor.tboBuffer );
GlStateManager._glBufferData( GL31.GL_TEXTURE_BUFFER, monitorBuffer, GL20.GL_STATIC_DRAW );
GlStateManager._glBindBuffer( GL31.GL_TEXTURE_BUFFER, 0 );
}
// Nobody knows what they're doing!
GlStateManager.activeTexture( MonitorTextureBufferShader.TEXTURE_INDEX );
GlStateManager._activeTexture( MonitorTextureBufferShader.TEXTURE_INDEX );
GL11.glBindTexture( GL31.GL_TEXTURE_BUFFER, monitor.tboTexture );
GlStateManager.activeTexture( GL13.GL_TEXTURE0 );
GlStateManager._activeTexture( GL13.GL_TEXTURE0 );
MonitorTextureBufferShader.setupUniform( matrix, width, height, terminal.getPalette(), !monitor.isColour() );
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder buffer = tessellator.getBuffer();
buffer.begin( GL11.GL_TRIANGLE_STRIP, VertexFormats.POSITION );
buffer.begin( VertexFormat.DrawMode.TRIANGLE_STRIP, VertexFormats.POSITION );
buffer.vertex( -xMargin, -yMargin, 0 )
.next();
buffer.vertex( -xMargin, pixelHeight + yMargin, 0 )
@ -224,7 +223,7 @@ public class TileEntityMonitorRenderer implements BlockEntityRenderer<TileMonito
.next();
tessellator.draw();
GlStateManager.useProgram( 0 );
GlStateManager._glUseProgram( 0 );
break;
}
@ -252,8 +251,9 @@ public class TileEntityMonitorRenderer implements BlockEntityRenderer<TileMonito
vbo.bind();
FixedWidthFontRenderer.TYPE.getVertexFormat()
.startDrawing( 0L );
vbo.draw( matrix, FixedWidthFontRenderer.TYPE.getDrawMode() );
.startDrawing();
// vbo.draw( matrix, FixedWidthFontRenderer.TYPE.getDrawMode() );
vbo.drawElements(); //FIXME: Is this ok?
VertexBuffer.unbind();
FixedWidthFontRenderer.TYPE.getVertexFormat()
.endDrawing();

View File

@ -21,6 +21,7 @@ import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher;
import net.minecraft.client.render.block.entity.BlockEntityRenderer;
import net.minecraft.client.render.block.entity.BlockEntityRendererFactory;
import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.render.model.BakedModelManager;
import net.minecraft.client.render.model.BakedQuad;
@ -47,11 +48,11 @@ public class TileEntityTurtleRenderer implements BlockEntityRenderer<TileTurtle>
private final Random random = new Random( 0 );
public TileEntityTurtleRenderer( BlockEntityRenderDispatcher renderDispatcher )
public TileEntityTurtleRenderer( BlockEntityRendererFactory.Context context )
{
super( renderDispatcher );
// super( rendererDispatcher );
}
public static ModelIdentifier getTurtleModel( ComputerFamily family, boolean coloured )
{
switch( family )
@ -116,11 +117,11 @@ public class TileEntityTurtleRenderer implements BlockEntityRenderer<TileTurtle>
// Render the label
String label = turtle.createProxy()
.getLabel();
HitResult hit = dispatcher.crosshairTarget;
MinecraftClient mc = MinecraftClient.getInstance();
HitResult hit = mc.crosshairTarget;
if( label != null && hit.getType() == HitResult.Type.BLOCK && turtle.getPos()
.equals( ((BlockHitResult) hit).getBlockPos() ) )
{
MinecraftClient mc = MinecraftClient.getInstance();
TextRenderer font = mc.textRenderer;
transform.push();

View File

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

View File

@ -10,6 +10,7 @@ import net.fabricmc.fabric.api.client.rendereregistry.v1.EntityRendererRegistry;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.render.entity.EntityRenderer;
import net.minecraft.client.render.entity.EntityRendererFactory;
import net.minecraft.client.render.entity.EntityRendererFactory.Context;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.Identifier;
@ -18,14 +19,9 @@ import javax.annotation.Nonnull;
public class TurtlePlayerRenderer extends EntityRenderer<TurtlePlayer>
{ //FIXME Make sure this isn't an issue. Context was EntityRenderDispatcher.
public TurtlePlayerRenderer( Context renderManager )
public TurtlePlayerRenderer( EntityRendererFactory.Context context )
{
super( renderManager );
}
public TurtlePlayerRenderer( Context entityRenderDispatcher, EntityRendererRegistry.Context context )
{
super( entityRenderDispatcher );
super( context );
}
@Override

View File

@ -145,9 +145,9 @@ public class TurtleSmartItemModel implements BakedModel
@Nonnull
@Override
@Deprecated
public Sprite getSprite()
public Sprite getParticleSprite()
{
return familyModel.getSprite();
return familyModel.getParticleSprite();
}
@Nonnull

View File

@ -0,0 +1,23 @@
package dan200.computercraft.fabric.mixin;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Mutable;
import org.spongepowered.asm.mixin.Shadow;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.util.math.BlockPos;
@Mixin( BlockEntity.class )
public class BlockEntityMixin
{
@Final
@Mutable
@Shadow
protected BlockPos pos;
public void setBlockPos( BlockPos pos )
{
this.pos = pos;
}
}

View File

@ -34,7 +34,7 @@ public class MixinServerPlayerInteractionManager
ActionResult actionResult = state.onUse( world, player, hand, hitResult );
if( actionResult.isAccepted() )
{
Criteria.ITEM_USED_ON_BLOCK.test( player, pos, stack );
Criteria.ITEM_USED_ON_BLOCK.trigger( player, pos, stack );
cir.setReturnValue( actionResult );
}
}

View File

@ -42,7 +42,6 @@ import dan200.computercraft.shared.turtle.core.TurtlePlayer;
import dan200.computercraft.shared.turtle.inventory.ContainerTurtle;
import dan200.computercraft.shared.turtle.items.ItemTurtle;
import dan200.computercraft.shared.turtle.upgrades.*;
import dan200.computercraft.shared.util.FixedPointTileEntityType;
import net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityTypeBuilder;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.screenhandler.v1.ScreenHandlerRegistry;
@ -150,48 +149,53 @@ public final class ComputerCraftRegistry
public static class ModTiles
{
public static final BlockEntityType<TileMonitor> MONITOR_NORMAL = ofBlock( () -> ModBlocks.MONITOR_NORMAL,
"monitor_normal",
f -> new TileMonitor( f, false, null, null ) );
public static final BlockEntityType<TileMonitor> MONITOR_ADVANCED = ofBlock( () -> ModBlocks.MONITOR_ADVANCED,
"monitor_advanced",
f -> new TileMonitor( f, true, null, null ) );
public static final BlockEntityType<TileComputer> COMPUTER_NORMAL = ofBlock( () -> ModBlocks.COMPUTER_NORMAL,
"computer_normal",
f -> new TileComputer( ComputerFamily.NORMAL, f, null, null ) );
public static final BlockEntityType<TileComputer> COMPUTER_ADVANCED = ofBlock( () -> ModBlocks.COMPUTER_ADVANCED,
"computer_advanced",
f -> new TileComputer( ComputerFamily.ADVANCED, f, null, null ) );
public static final BlockEntityType<TileCommandComputer> COMPUTER_COMMAND = ofBlock( () -> ModBlocks.COMPUTER_COMMAND,
"computer_command",
f -> new TileCommandComputer( ComputerFamily.COMMAND, f, null, null ) );
public static final BlockEntityType<TileTurtle> TURTLE_NORMAL = ofBlock( () -> ModBlocks.TURTLE_NORMAL,
"turtle_normal",
f -> new TileTurtle( f, ComputerFamily.NORMAL ) );
public static final BlockEntityType<TileTurtle> TURTLE_ADVANCED = ofBlock( () -> ModBlocks.TURTLE_ADVANCED,
"turtle_advanced",
f -> new TileTurtle( f, ComputerFamily.ADVANCED ) );
public static final BlockEntityType<TileSpeaker> SPEAKER = ofBlock( () -> ModBlocks.SPEAKER, "speaker", TileSpeaker::new );
public static final BlockEntityType<TileDiskDrive> DISK_DRIVE = ofBlock( () -> ModBlocks.DISK_DRIVE, "disk_drive", TileDiskDrive::new );
public static final BlockEntityType<TilePrinter> PRINTER = ofBlock( () -> ModBlocks.PRINTER, "printer", TilePrinter::new );
public static final BlockEntityType<TileWiredModemFull> WIRED_MODEM_FULL = ofBlock( () -> ModBlocks.WIRED_MODEM_FULL,
"wired_modem_full",
TileWiredModemFull::new );
public static final BlockEntityType<TileCable> CABLE = ofBlock( () -> ModBlocks.CABLE, "cable", TileCable::new );
public static final BlockEntityType<TileWirelessModem> WIRELESS_MODEM_NORMAL = ofBlock( () -> ModBlocks.WIRELESS_MODEM_NORMAL,
"wireless_modem_normal",
f -> new TileWirelessModem( f, false, null, null ) );
public static final BlockEntityType<TileWirelessModem> WIRELESS_MODEM_ADVANCED = ofBlock( () -> ModBlocks.WIRELESS_MODEM_ADVANCED,
"wireless_modem_advanced",
f -> new TileWirelessModem( f, true ) );
private static <T extends BlockEntity> BlockEntityType<T> ofBlock( Supplier<Block> block, String id, Function<BlockEntityType<T>, T> factory )
{
FabricBlockEntityTypeBuilder.create(factory, block);
return Registry.register( BLOCK_ENTITY_TYPE,
new Identifier( MOD_ID, id ),
FabricBlockEntityTypeBuilder.create);
}
public static final BlockEntityType<TileMonitor> MONITOR_NORMAL = FabricBlockEntityTypeBuilder
.create( ( blockPos, blockState ) -> new TileMonitor( ModTiles.MONITOR_NORMAL, false, blockPos, blockState ),
ModBlocks.MONITOR_NORMAL )
.build();
public static final BlockEntityType<TileMonitor> MONITOR_ADVANCED = FabricBlockEntityTypeBuilder
.create( ( blockPos, blockState ) -> new TileMonitor( ModTiles.MONITOR_ADVANCED, false, blockPos, blockState ),
ModBlocks.MONITOR_ADVANCED )
.build();
public static final BlockEntityType<TileComputer> COMPUTER_NORMAL = FabricBlockEntityTypeBuilder.create(
( blockPos, blockState ) -> new TileComputer( ComputerFamily.NORMAL, ModTiles.COMPUTER_NORMAL, blockPos, blockState ),
ModBlocks.COMPUTER_NORMAL ).build();
public static final BlockEntityType<TileComputer> COMPUTER_ADVANCED = FabricBlockEntityTypeBuilder
.create( ( blockPos, blockState ) -> new TileComputer( ComputerFamily.ADVANCED, ModTiles.COMPUTER_ADVANCED, blockPos,
blockState ), ModBlocks.COMPUTER_ADVANCED )
.build();
public static final BlockEntityType<TileCommandComputer> COMPUTER_COMMAND = FabricBlockEntityTypeBuilder
.create( ( blockPos, blockState ) -> new TileCommandComputer( ComputerFamily.COMMAND, ModTiles.COMPUTER_COMMAND, blockPos,
blockState ), ModBlocks.COMPUTER_COMMAND )
.build();
public static final BlockEntityType<TileTurtle> TURTLE_NORMAL = FabricBlockEntityTypeBuilder.create(
( blockPos, blockState ) -> new TileTurtle( ModTiles.TURTLE_NORMAL, ComputerFamily.NORMAL, blockPos, blockState ),
ModBlocks.TURTLE_NORMAL ).build();
public static final BlockEntityType<TileTurtle> TURTLE_ADVANCED = FabricBlockEntityTypeBuilder.create(
( blockPos, blockState ) -> new TileTurtle( ModTiles.TURTLE_ADVANCED, ComputerFamily.ADVANCED, blockPos, blockState ),
ModBlocks.TURTLE_ADVANCED ).build();
public static final BlockEntityType<TileSpeaker> SPEAKER = FabricBlockEntityTypeBuilder
.create( ( blockPos, blockState ) -> new TileSpeaker( ModTiles.SPEAKER, blockPos, blockState ), ModBlocks.SPEAKER )
.build();
public static final BlockEntityType<TileDiskDrive> DISK_DRIVE = FabricBlockEntityTypeBuilder
.create( ( blockPos, blockState ) -> new TileDiskDrive( ModTiles.DISK_DRIVE, blockPos, blockState ),
ModBlocks.DISK_DRIVE )
.build();
public static final BlockEntityType<TilePrinter> PRINTER = FabricBlockEntityTypeBuilder
.create( ( blockPos, blockState ) -> new TilePrinter( ModTiles.PRINTER, blockPos, blockState ), ModBlocks.PRINTER )
.build();
public static final BlockEntityType<TileWiredModemFull> WIRED_MODEM_FULL = FabricBlockEntityTypeBuilder
.create( ( blockPos, blockState ) -> new TileWiredModemFull( ModTiles.WIRED_MODEM_FULL, blockPos, blockState ),
ModBlocks.WIRED_MODEM_FULL )
.build();
public static final BlockEntityType<TileCable> CABLE = FabricBlockEntityTypeBuilder
.create( ( blockPos, blockState ) -> new TileCable( ModTiles.CABLE, blockPos, blockState ), ModBlocks.CABLE ).build();
public static final BlockEntityType<TileWirelessModem> WIRELESS_MODEM_NORMAL = FabricBlockEntityTypeBuilder.create(
( blockPos, blockState ) -> new TileWirelessModem( ModTiles.WIRELESS_MODEM_NORMAL, false, blockPos, blockState ),
ModBlocks.WIRELESS_MODEM_NORMAL ).build();
public static final BlockEntityType<TileWirelessModem> WIRELESS_MODEM_ADVANCED = FabricBlockEntityTypeBuilder.create(
( blockPos, blockState ) -> new TileWirelessModem( ModTiles.WIRELESS_MODEM_ADVANCED, true, blockPos, blockState ),
ModBlocks.WIRELESS_MODEM_ADVANCED ).build();
}
public static final class ModItems

View File

@ -59,9 +59,9 @@ 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 &&
if( server.isSingleplayer() && sender instanceof PlayerEntity &&
((PlayerEntity) sender).getGameProfile().getName().equalsIgnoreCase( server.getServerModName() ) )
{
return true;

View File

@ -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 );

View File

@ -20,7 +20,7 @@ public interface IColouredItem
static int getColourBasic( ItemStack stack )
{
NbtCompound 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 )
{
NbtCompound 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 );
}
}

View File

@ -103,7 +103,7 @@ public class ItemPocketComputer extends Item implements IComputerItem, IMedia, I
public static void setUpgrade( @Nonnull ItemStack stack, IPocketUpgrade upgrade )
{
NbtCompound compound = stack.getOrCreateTag();
NbtCompound compound = stack.getOrCreateNbt();
if( upgrade == null )
{
@ -121,7 +121,7 @@ public class ItemPocketComputer extends Item implements IComputerItem, IMedia, I
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 )
{
NbtCompound 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 )
{
NbtCompound 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 )
{
NbtCompound 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 );
}

View File

@ -48,18 +48,22 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Collections;
public class TileTurtle extends TileComputerBase implements ITurtleTile, DefaultInventory
public class TileTurtle extends TileComputerBase
implements ITurtleTile, DefaultInventory
{
public static final int INVENTORY_SIZE = 16;
public static final int INVENTORY_WIDTH = 4;
public static final int INVENTORY_HEIGHT = 4;
private final DefaultedList<ItemStack> inventory = DefaultedList.ofSize( INVENTORY_SIZE, ItemStack.EMPTY );
private final DefaultedList<ItemStack> previousInventory = DefaultedList.ofSize( INVENTORY_SIZE, ItemStack.EMPTY );
private final DefaultedList<ItemStack> inventory = DefaultedList
.ofSize( INVENTORY_SIZE, ItemStack.EMPTY );
private final DefaultedList<ItemStack> previousInventory = DefaultedList
.ofSize( INVENTORY_SIZE, ItemStack.EMPTY );
private boolean inventoryChanged = false;
private TurtleBrain brain = new TurtleBrain( this );
private MoveState moveState = MoveState.NOT_MOVED;
public TileTurtle( BlockEntityType<? extends TileGeneric> type, ComputerFamily family, BlockPos pos, BlockState state )
public TileTurtle( BlockEntityType<? extends TileGeneric> type,
ComputerFamily family, BlockPos pos, BlockState state )
{
super( type, family, pos, state );
}
@ -133,7 +137,8 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default
@Override
public ItemStack getStack( int slot )
{
return slot >= 0 && slot < INVENTORY_SIZE ? inventory.get( slot ) : ItemStack.EMPTY;
return slot >= 0 && slot < INVENTORY_SIZE ? inventory.get( slot )
: ItemStack.EMPTY;
}
@Nonnull
@ -174,7 +179,8 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default
@Override
public void setStack( int i, @Nonnull ItemStack stack )
{
if( i >= 0 && i < INVENTORY_SIZE && !InventoryUtil.areItemsEqual( stack, inventory.get( i ) ) )
if( i >= 0 && i < INVENTORY_SIZE
&& !InventoryUtil.areItemsEqual( stack, inventory.get( i ) ) )
{
inventory.set( i, stack );
onInventoryDefinitelyChanged();
@ -224,7 +230,8 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default
}
return ActionResult.SUCCESS;
}
else if( currentItem.getItem() == Items.WATER_BUCKET && brain.getColour() != -1 )
else if( currentItem.getItem() == Items.WATER_BUCKET
&& brain.getColour() != -1 )
{
// Water to remove turtle colour
if( !getWorld().isClient )
@ -234,7 +241,8 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default
brain.setColour( -1 );
if( !player.isCreative() )
{
player.setStackInHand( hand, new ItemStack( Items.BUCKET ) );
player.setStackInHand( hand,
new ItemStack( Items.BUCKET ) );
player.getInventory().markDirty();
}
}
@ -265,9 +273,10 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default
}
}
public static void tick( World world, BlockPos pos, BlockState state, TileTurtle tileTurtle)
public static void tick( World world, BlockPos pos, BlockState state,
TileTurtle tileTurtle )
{
tileTurtle.brain.update();
tileTurtle.brain.update();
if( !tileTurtle.getWorld().isClient && tileTurtle.inventoryChanged )
{
ServerComputer computer = tileTurtle.getServerComputer();
@ -279,30 +288,27 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default
tileTurtle.inventoryChanged = false;
for( int n = 0; n < tileTurtle.size(); n++ )
{
tileTurtle.previousInventory.set( n,
tileTurtle.getStack( n ).copy() );
tileTurtle.previousInventory.set( n, tileTurtle.getStack( n ).copy() );
}
}
}
@Override
protected void updateBlockState( ComputerState newState )
{
}
{}
@Nonnull
@Override
public NbtCompound writeNbt( @Nonnull NbtCompound nbt )
{
super.readNbt( nbt );
super.readNbt( nbt );
// Write inventory
NbtList nbttaglist = new NbtList();
for( int i = 0; i < INVENTORY_SIZE; i++ )
{
if( !inventory.get( i )
.isEmpty() )
if( !inventory.get( i ).isEmpty() )
{
NbtCompound tag = new NbtCompound();
NbtCompound tag = new NbtCompound();
tag.putByte( "Slot", (byte) i );
inventory.get( i ).writeNbt( tag );
nbttaglist.add( tag );
@ -334,8 +340,7 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default
if( slot < size() )
{
inventory.set( slot, ItemStack.fromNbt( tag ) );
previousInventory.set( slot, inventory.get( slot )
.copy() );
previousInventory.set( slot, inventory.get( slot ).copy() );
}
}
@ -360,11 +365,9 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default
@Override
protected ServerComputer createComputer( int instanceID, int id )
{
ServerComputer computer = new ServerComputer( getWorld(),
id, label,
instanceID, getFamily(),
ComputerCraft.turtleTermWidth,
ComputerCraft.turtleTermHeight );
ServerComputer computer = new ServerComputer( getWorld(), id, label, instanceID,
getFamily(), ComputerCraft.turtleTermWidth,
ComputerCraft.turtleTermHeight );
computer.setPosition( getPos() );
computer.addAPI( new TurtleAPI( computer.getAPIEnvironment(), getAccess() ) );
brain.setupComputer( computer );
@ -397,13 +400,17 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default
{
dir = Direction.NORTH;
}
world.setBlockState( pos,
getCachedState().with( BlockTurtle.FACING, dir ) );
world.setBlockState( pos, getCachedState().with( BlockTurtle.FACING, dir ) );
updateOutput();
updateInput();
onTileEntityChange();
}
public void setBlockPos( BlockPos pos )
{
this.pos.;
}
public void onTileEntityChange()
{
super.markDirty();
@ -412,7 +419,7 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default
private boolean hasPeripheralUpgradeOnSide( ComputerSide side )
{
ITurtleUpgrade upgrade;
switch( side )
switch ( side )
{
case RIGHT:
upgrade = getUpgrade( TurtleSide.RIGHT );
@ -423,8 +430,7 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default
default:
return false;
}
return upgrade != null && upgrade.getType()
.isPeripheral();
return upgrade != null && upgrade.getType().isPeripheral();
}
// IInventory
@ -525,8 +531,7 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default
boolean changed = false;
for( int i = 0; i < INVENTORY_SIZE; i++ )
{
if( !inventory.get( i )
.isEmpty() )
if( !inventory.get( i ).isEmpty() )
{
inventory.set( i, ItemStack.EMPTY );
changed = true;
@ -556,7 +561,8 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default
@Nullable
@Override
public ScreenHandler createMenu( int id, @Nonnull PlayerInventory inventory, @Nonnull PlayerEntity player )
public ScreenHandler createMenu( int id, @Nonnull PlayerInventory inventory,
@Nonnull PlayerEntity player )
{
return new ContainerTurtle( id, inventory, brain );
}

View File

@ -207,31 +207,11 @@ public final class TurtlePlayer extends FakePlayer
{
}
// @Override //FIXME: These need to be fixed.
// public void openEditBookScreen( @Nonnull ItemStack stack, @Nonnull Hand hand )
// {
// }
@Override
public void closeHandledScreen()
{
}
// @Override
// public void updateCursorStack()
// {
// }
// @Override
// protected void onStatusEffectApplied( @Nonnull StatusEffectInstance id )
// {
// }
// @Override
// protected void onStatusEffectUpgraded( @Nonnull StatusEffectInstance id, boolean apply )
// {
// }
@Override
protected void onStatusEffectRemoved( @Nonnull StatusEffectInstance effect )
{

View File

@ -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 )
{
NbtCompound 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 )
{
NbtCompound 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 )
{
NbtCompound tag = stack.getTag();
NbtCompound tag = stack.getNbt();
return tag != null && tag.contains( NBT_OVERLAY ) ? new Identifier( tag.getString( NBT_OVERLAY ) ) : null;
}

View File

@ -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 );

View File

@ -76,7 +76,7 @@ public class TurtleTool extends AbstractTurtleUpgrade
@Override
public boolean isItemSuitable( @Nonnull ItemStack stack )
{
NbtCompound 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

View File

@ -367,10 +367,5 @@ public class FakeNetHandler extends ServerPlayNetworkHandler
public void disableAutoRead()
{
}
@Override
public void setCompressionThreshold( int threshold )
{
}
}
}

View File

@ -1,61 +1,62 @@
/*
* This file is part of ComputerCraft - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2021. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com
*/
package dan200.computercraft.shared.util;
import net.minecraft.block.Block;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityType;
import javax.annotation.Nonnull;
import java.util.Collections;
import java.util.function.Function;
import java.util.function.Supplier;
/**
* A {@link BlockEntityType} whose supplier uses itself as an argument.
*
* @param <T> The type of the produced tile entity.
*/
public final class FixedPointTileEntityType<T extends BlockEntity> extends BlockEntityType<T>
{
private final Supplier<Block> block;
private FixedPointTileEntityType( Supplier<Block> block, Supplier<T> builder )
{
super( builder, Collections.emptySet(), null ); //FIXME: Replace with the new BlockEntity handlers.
this.block = block;
}
public static <T extends BlockEntity> FixedPointTileEntityType<T> create( Supplier<Block> block, Function<BlockEntityType<T>, T> builder )
{
return new FixedPointSupplier<>( block, builder ).factory;
}
// @Override
// public boolean supports( @Nonnull Block block )
///*
// * This file is part of ComputerCraft - http://www.computercraft.info
// * Copyright Daniel Ratcliffe, 2011-2021. Do not distribute without permission.
// * Send enquiries to dratcliffe@gmail.com
// */
//
//package dan200.computercraft.shared.util;
//
//import net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityTypeBuilder;
//import net.minecraft.block.Block;
//import net.minecraft.block.entity.BlockEntity;
//import net.minecraft.block.entity.BlockEntityType;
//
//import javax.annotation.Nonnull;
//import java.util.Collections;
//import java.util.function.Function;
//import java.util.function.Supplier;
//
///**
// * A {@link BlockEntityType} whose supplier uses itself as an argument.
// *
// * @param <T> The type of the produced tile entity.
// */
//public final class FixedPointTileEntityType<T extends BlockEntity> extends BlockEntityType<T>
//{
// private final Supplier<Block> block;
//
// private FixedPointTileEntityType( Supplier<Block> block, Supplier<T> builder )
// {
// return block == this.block.get();
// super( builder, Collections.emptySet(), null ); //FIXME: Replace with the new BlockEntity handlers.
// this.block = block;
// }
private static final class FixedPointSupplier<T extends BlockEntity> implements Supplier<T>
{
final FixedPointTileEntityType<T> factory;
private final Function<BlockEntityType<T>, T> builder;
private FixedPointSupplier( Supplier<Block> block, Function<BlockEntityType<T>, T> builder )
{
factory = new FixedPointTileEntityType<>( block, this );
this.builder = builder;
}
@Override
public T get()
{
return builder.apply( factory );
}
}
}
//
// public static <T extends BlockEntity> FixedPointTileEntityType<T> create( Supplier<Block> block, Function<BlockEntityType<T>, T> builder )
// {
// return new FixedPointSupplier<>( block, builder ).factory;
// }
//
//// @Override
//// public boolean supports( @Nonnull Block block )
//// {
//// return block == this.block.get();
//// }
//
// private static final class FixedPointSupplier<T extends BlockEntity> implements Supplier<T>
// {
// final FixedPointTileEntityType<T> factory;
// private final Function<BlockEntityType<T>, T> builder;
//
// private FixedPointSupplier( Supplier<Block> block, Function<BlockEntityType<T>, T> builder )
// {
// factory = FabricBlockEntityTypeBuilder.create( this, block );
// this.builder = builder;
// }
//
// @Override
// public T get()
// {
// return builder.apply( factory );
// }
// }
//}

View File

@ -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:

View File

@ -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();