diff --git a/gradle.properties b/gradle.properties index 3e781c28e..09fb2cb3d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,8 +10,8 @@ artifact_basename=appliedenergistics2 ######################################################### minecraft_release=1.15 minecraft_version=1.15.2 -mcp_mappings=20200514-1.15.1 -forge_version=31.2.0 +mcp_mappings=20200613-1.15.1 +forge_version=31.2.19 ######################################################### # Provided APIs # diff --git a/src/api/java/appeng/api/implementations/TransitionResult.java b/src/api/java/appeng/api/implementations/TransitionResult.java index 9eec763e8..82b459cdf 100644 --- a/src/api/java/appeng/api/implementations/TransitionResult.java +++ b/src/api/java/appeng/api/implementations/TransitionResult.java @@ -33,9 +33,9 @@ public class TransitionResult public final boolean success; public final double energyUsage; - public TransitionResult( final boolean _success, final double power ) + public TransitionResult( final boolean success, final double power ) { - this.success = _success; + this.success = success; this.energyUsage = power; } } diff --git a/src/api/java/appeng/api/storage/ISpatialDimension.java b/src/api/java/appeng/api/storage/ISpatialDimension.java index 4aa0ff85c..08b607e6c 100644 --- a/src/api/java/appeng/api/storage/ISpatialDimension.java +++ b/src/api/java/appeng/api/storage/ISpatialDimension.java @@ -20,11 +20,13 @@ package appeng.api.storage; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.text.ITextComponent; import net.minecraft.world.World; import net.minecraft.world.dimension.DimensionType; import net.minecraft.world.server.ServerWorld; import javax.annotation.Nullable; +import java.util.List; public interface ISpatialDimension @@ -32,7 +34,7 @@ public interface ISpatialDimension ServerWorld getWorld(DimensionType cellDim ); @Nullable - DimensionType createNewCellDimension(BlockPos contentSize); + DimensionType createNewCellDimension(BlockPos capacity); void deleteCellDimension( DimensionType cellDim ); @@ -40,5 +42,12 @@ public interface ISpatialDimension BlockPos getCellDimensionOrigin( DimensionType cellDim ); - BlockPos getCellContentSize( DimensionType cellDim ); + BlockPos getCellDimensionSize(DimensionType cellDim ); + + /** + * Adds a user-facing tooltip that describes this dimension so that a player + * can keep storage cells apart. + */ + void addCellDimensionTooltip(DimensionType cellDim, List lines); + } diff --git a/src/main/java/appeng/block/networking/BlockCableBus.java b/src/main/java/appeng/block/networking/BlockCableBus.java index ec62a09d0..7c5729547 100644 --- a/src/main/java/appeng/block/networking/BlockCableBus.java +++ b/src/main/java/appeng/block/networking/BlockCableBus.java @@ -222,7 +222,7 @@ public class BlockCableBus extends AEBaseTileBlock /* FIXME implem double z = target.getHitVec().z; // FIXME: Check how this looks, probably like shit, maybe provide parts the ability to supply particle textures??? effectRenderer.addEffect(new CableBusBreakingParticle(world, x, y, z, texture) - .multipleParticleScaleBy(0.8F)); + .multiplyParticleScaleBy(0.8F)); } return true; diff --git a/src/main/java/appeng/capabilities/NullSpatialDimension.java b/src/main/java/appeng/capabilities/NullSpatialDimension.java index 743bd6a1f..73734be6e 100644 --- a/src/main/java/appeng/capabilities/NullSpatialDimension.java +++ b/src/main/java/appeng/capabilities/NullSpatialDimension.java @@ -20,12 +20,15 @@ package appeng.capabilities; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.text.ITextComponent; import net.minecraft.world.World; import appeng.api.storage.ISpatialDimension; import net.minecraft.world.dimension.DimensionType; import net.minecraft.world.server.ServerWorld; +import java.util.List; + class NullSpatialDimension implements ISpatialDimension { @@ -47,6 +50,15 @@ class NullSpatialDimension implements ISpatialDimension } @Override + public BlockPos getCellDimensionSize(DimensionType cellDim) { + return BlockPos.ZERO; + } + + @Override + public void addCellDimensionTooltip(DimensionType cellDim, List tooltip) { + } + + @Override public ServerWorld getWorld(DimensionType cellStorageId ) { return null; @@ -57,10 +69,4 @@ class NullSpatialDimension implements ISpatialDimension { return false; } - - @Override - public BlockPos getCellContentSize( DimensionType cellDimId ) - { - return null; - } } diff --git a/src/main/java/appeng/client/render/SpatialSkyRender.java b/src/main/java/appeng/client/render/SpatialSkyRender.java index 83d509f49..2f7ac1704 100644 --- a/src/main/java/appeng/client/render/SpatialSkyRender.java +++ b/src/main/java/appeng/client/render/SpatialSkyRender.java @@ -21,9 +21,11 @@ package appeng.client.render; import java.util.Random; -import com.mojang.blaze3d.platform.GlStateManager; +import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.systems.RenderSystem; +import net.minecraft.client.renderer.Quaternion; +import net.minecraftforge.client.SkyRenderHandler; import org.lwjgl.opengl.GL11; import net.minecraft.client.Minecraft; @@ -36,7 +38,7 @@ import net.minecraftforge.client.IRenderHandler; //TODO https://github.com/MinecraftForge/MinecraftForge/pull/6537 -public class SpatialSkyRender implements IRenderHandler +public class SpatialSkyRender implements SkyRenderHandler { private static final SpatialSkyRender INSTANCE = new SpatialSkyRender(); @@ -55,14 +57,17 @@ public class SpatialSkyRender implements IRenderHandler return INSTANCE; } - @Override - public void render( final int ticks, final float partialTicks, final ClientWorld world, final Minecraft mc ) - { - //FIXME, Do not use this until the above PR is merged. - if (true) { - return; - } + private static final Quaternion[] SKYBOX_SIDE_ROTATIONS = { + Quaternion.ONE, + new Quaternion( 90.0F, 0.0F, 0.0F, true ), + new Quaternion( -90.0F, 0.0F, 0.0F, true ), + new Quaternion( 180.0F, 0.0F, 0.0F, true ), + new Quaternion( 0.0F, 0.0F, 90.0F, true ), + new Quaternion( 0.0F, 0.0F, -90.0F, true ), + }; + @Override + public void render(int ticks, float partialTicks, MatrixStack matrixStack, ClientWorld world, Minecraft mc) { final long now = System.currentTimeMillis(); if( now - this.cycle > 2000 ) { @@ -76,46 +81,22 @@ public class SpatialSkyRender implements IRenderHandler fade /= 1000; fade = 0.15f * ( 1.0f - Math.abs( ( fade - 1.0f ) * ( fade - 1.0f ) ) ); - GlStateManager.disableFog(); - GlStateManager.disableAlphaTest(); + RenderSystem.disableFog(); + RenderSystem.disableAlphaTest(); RenderSystem.disableBlend(); - GlStateManager.depthMask( false ); + RenderSystem.depthMask( false ); RenderSystem.color4f( 0.0f, 0.0f, 0.0f, 1.0f ); final Tessellator tessellator = Tessellator.getInstance(); final BufferBuilder VertexBuffer = tessellator.getBuffer(); // This renders a skybox around the player at a far, fixed distance from them. // The skybox is pitch black and untextured - for( int i = 0; i < 6; ++i ) + for (Quaternion rotation : SKYBOX_SIDE_ROTATIONS) { - GlStateManager.pushMatrix(); + matrixStack.push(); + matrixStack.rotate(rotation); - if( i == 1 ) - { - GlStateManager.rotatef( 90.0F, 1.0F, 0.0F, 0.0F ); - } - - if( i == 2 ) - { - GlStateManager.rotatef( -90.0F, 1.0F, 0.0F, 0.0F ); - } - - if( i == 3 ) - { - GlStateManager.rotatef( 180.0F, 1.0F, 0.0F, 0.0F ); - } - - if( i == 4 ) - { - GlStateManager.rotatef( 90.0F, 0.0F, 0.0F, 1.0F ); - } - - if( i == 5 ) - { - GlStateManager.rotatef( -90.0F, 0.0F, 0.0F, 1.0F ); - } - - GlStateManager.disableTexture(); + RenderSystem.disableTexture(); VertexBuffer.begin( GL11.GL_QUADS, DefaultVertexFormats.POSITION ); VertexBuffer.pos( -100.0D, -100.0D, -100.0D ).endVertex(); VertexBuffer.pos( -100.0D, -100.0D, 100.0D ).endVertex(); @@ -123,19 +104,19 @@ public class SpatialSkyRender implements IRenderHandler VertexBuffer.pos( 100.0D, -100.0D, -100.0D ).endVertex(); tessellator.draw(); RenderSystem.enableTexture(); - GlStateManager.popMatrix(); + matrixStack.pop(); } - GlStateManager.depthMask( true ); + RenderSystem.depthMask( true ); if( fade > 0.0f ) { - GlStateManager.disableFog(); - GlStateManager.disableAlphaTest(); + RenderSystem.disableFog(); + RenderSystem.disableAlphaTest(); RenderSystem.enableBlend(); - GlStateManager.disableTexture(); - GlStateManager.depthMask( false ); - GlStateManager.blendFuncSeparate( GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0 ); + RenderSystem.disableTexture(); + RenderSystem.depthMask( false ); + RenderSystem.blendFuncSeparate( GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0 ); RenderHelper.disableStandardItemLighting(); @@ -143,11 +124,11 @@ public class SpatialSkyRender implements IRenderHandler GL11.glCallList( this.dspList ); } - GlStateManager.depthMask( true ); + RenderSystem.depthMask( true ); RenderSystem.enableBlend(); - GlStateManager.enableAlphaTest(); + RenderSystem.enableAlphaTest(); RenderSystem.enableTexture(); - GlStateManager.enableFog(); + RenderSystem.enableFog(); RenderSystem.color4f( 1.0f, 1.0f, 1.0f, 1.0f ); } @@ -155,8 +136,8 @@ public class SpatialSkyRender implements IRenderHandler private void renderTwinkles() { final Tessellator tessellator = Tessellator.getInstance(); - final BufferBuilder VertexBuffer = tessellator.getBuffer(); - VertexBuffer.begin( GL11.GL_QUADS, DefaultVertexFormats.POSITION ); + final BufferBuilder vb = tessellator.getBuffer(); + vb.begin( GL11.GL_QUADS, DefaultVertexFormats.POSITION ); for( int i = 0; i < 50; ++i ) { @@ -196,7 +177,7 @@ public class SpatialSkyRender implements IRenderHandler final double d23 = d17 * d12 - d20 * d13; final double d24 = d23 * d9 - d21 * d10; final double d25 = d21 * d9 + d23 * d10; - VertexBuffer.pos( x + d24, y + d22, z + d25 ).endVertex(); + vb.pos( x + d24, y + d22, z + d25 ).endVertex(); } } } diff --git a/src/main/java/appeng/core/localization/GuiText.java b/src/main/java/appeng/core/localization/GuiText.java index 49a70d443..8c1f3dff6 100644 --- a/src/main/java/appeng/core/localization/GuiText.java +++ b/src/main/java/appeng/core/localization/GuiText.java @@ -92,8 +92,10 @@ public enum GuiText QuartzCuttingKnife, // spatial + SpatialCapacity, StoredSize, - CellId, + Unformatted, + SerialNumber, CopyMode, CopyModeDesc, @@ -215,4 +217,8 @@ public enum GuiText return new TranslationTextComponent(getTranslationKey()); } + public ITextComponent textComponent(Object... args) { + return new TranslationTextComponent(getTranslationKey(), args); + } + } diff --git a/src/main/java/appeng/items/storage/ItemSpatialStorageCell.java b/src/main/java/appeng/items/storage/ItemSpatialStorageCell.java index 97416ce90..b309412bd 100644 --- a/src/main/java/appeng/items/storage/ItemSpatialStorageCell.java +++ b/src/main/java/appeng/items/storage/ItemSpatialStorageCell.java @@ -34,6 +34,8 @@ import net.minecraft.nbt.CompoundNBT; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.StringTextComponent; +import net.minecraft.util.text.TextFormatting; import net.minecraft.world.World; import net.minecraft.world.dimension.DimensionType; import net.minecraftforge.api.distmarker.Dist; @@ -58,11 +60,17 @@ public class ItemSpatialStorageCell extends AEBaseItem implements ISpatialStorag @Override public void addInformation(final ItemStack stack, final World world, final List lines, final ITooltipFlag advancedTooltips ) { + final DimensionType dimType = this.getStoredDimension(stack); + if (dimType == null) { + lines.add(GuiText.Unformatted.textComponent().applyTextStyle(TextFormatting.ITALIC)); + lines.add( GuiText.SpatialCapacity.textComponent(maxRegion, maxRegion, maxRegion)); + } else { + SpatialDimensionManager.INSTANCE.addCellDimensionTooltip(dimType, lines); + } + if (advancedTooltips.isAdvanced()) { - final DimensionType dimType = this.getStoredDimension(stack); if (dimType != null && dimType.getRegistryName() != null) { - String ae2Id = dimType.getRegistryName().getPath(); - lines.add(GuiText.CellId.textComponent().appendText(": " + ae2Id)); + lines.add(new StringTextComponent("Dimension: " + dimType.getRegistryName())); } } } @@ -105,7 +113,7 @@ public class ItemSpatialStorageCell extends AEBaseItem implements ISpatialStorag final BlockPos targetSize = new BlockPos( targetX, targetY, targetZ ); - ISpatialDimension manager = new SpatialDimensionManager(); + ISpatialDimension manager = SpatialDimensionManager.INSTANCE; DimensionType storedDim = this.getStoredDimension( is ); if( storedDim == null ) @@ -124,7 +132,7 @@ public class ItemSpatialStorageCell extends AEBaseItem implements ISpatialStorag { World cellWorld = manager.getWorld(storedDim); - BlockPos scale = manager.getCellContentSize( storedDim ); + BlockPos scale = manager.getCellDimensionSize( storedDim ); if( scale.equals( targetSize ) ) { diff --git a/src/main/java/appeng/spatial/SpatialDimensionExtraData.java b/src/main/java/appeng/spatial/SpatialDimensionExtraData.java index 712b2d15f..eeaded2b9 100644 --- a/src/main/java/appeng/spatial/SpatialDimensionExtraData.java +++ b/src/main/java/appeng/spatial/SpatialDimensionExtraData.java @@ -1,5 +1,6 @@ package appeng.spatial; +import appeng.core.AELog; import io.netty.buffer.Unpooled; import net.minecraft.network.PacketBuffer; import net.minecraft.util.math.BlockPos; @@ -14,32 +15,51 @@ import javax.annotation.Nullable; */ public final class SpatialDimensionExtraData { - private static final int FORMAT_VERSION = 1; - private static final int OFFSET_VERSION = 0; - private static final int OFFSET_CONTENT_SIZE = 1; + // Used to allow forward compatibility + private static final int CURRENT_FORMAT = 1; - private SpatialDimensionExtraData() { + /** + * The storage size of this dimension. This is dicateted by the pylon structure size used to perform + * the first transfer into this dimension. Once it's set, it cannot be changed anymore. + */ + private final BlockPos size; + + public SpatialDimensionExtraData(BlockPos size) { + this.size = size; } - public static PacketBuffer create(BlockPos contentSize) { - PacketBuffer extraData = new PacketBuffer(Unpooled.buffer()); - extraData.writeByte(FORMAT_VERSION); - extraData.writeBlockPos(contentSize); - // Cut the buffer to minimal size - extraData.capacity(extraData.writerIndex()); - return extraData; + public PacketBuffer write() { + PacketBuffer buf = new PacketBuffer(Unpooled.buffer()); + buf.writeByte(CURRENT_FORMAT); + buf.writeBlockPos(size); + buf.capacity(buf.writerIndex()); // This cuts the backing buffer to the required size + return buf; } - private static boolean checkVersion(PacketBuffer data){ - return data.getByte(OFFSET_VERSION) == FORMAT_VERSION; + public BlockPos getSize() { + return size; } - public static BlockPos getContentSize(@Nullable PacketBuffer data) { - if (data == null || !checkVersion(data)) { - return BlockPos.ZERO; + @Nullable + public static SpatialDimensionExtraData read(@Nullable PacketBuffer buf) { + if (buf == null) { + return null; } - data.readerIndex(OFFSET_CONTENT_SIZE); - return data.readBlockPos(); + try { + buf.readerIndex(0); + byte version = buf.readByte(); + if (version != CURRENT_FORMAT) { + // Currently no new format has been defined, as such anything but the current version is invalid + return null; + } + + BlockPos size = buf.readBlockPos(); + return new SpatialDimensionExtraData(size); + } catch (IndexOutOfBoundsException e) { + AELog.warn(e, "Failed to read spatial storage dimension data."); + return null; + } } + } diff --git a/src/main/java/appeng/spatial/SpatialDimensionManager.java b/src/main/java/appeng/spatial/SpatialDimensionManager.java index 15c440fa6..437a702fb 100644 --- a/src/main/java/appeng/spatial/SpatialDimensionManager.java +++ b/src/main/java/appeng/spatial/SpatialDimensionManager.java @@ -22,33 +22,44 @@ package appeng.spatial; import appeng.api.storage.ISpatialDimension; import appeng.core.AELog; import appeng.core.AppEng; +import appeng.core.localization.GuiText; import net.minecraft.network.PacketBuffer; import net.minecraft.server.MinecraftServer; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.text.ITextComponent; import net.minecraft.world.dimension.DimensionType; import net.minecraft.world.server.ServerWorld; import net.minecraftforge.common.DimensionManager; import net.minecraftforge.fml.server.ServerLifecycleHooks; +import javax.annotation.Nullable; +import java.util.List; +import java.util.Locale; -public class SpatialDimensionManager implements ISpatialDimension + +public final class SpatialDimensionManager implements ISpatialDimension { + public static final ISpatialDimension INSTANCE = new SpatialDimensionManager(); + private static final String DIM_ID_PREFIX = "spatial_"; + private SpatialDimensionManager() { + } + @Override public ServerWorld getWorld(DimensionType cellDim) { return DimensionManager.getWorld(getServer(), cellDim, true, true); } @Override - public DimensionType createNewCellDimension(BlockPos contentSize) + public DimensionType createNewCellDimension(BlockPos size) { ResourceLocation dimKey = findFreeDimensionId(); - AELog.info("Allocating storage cell dimension '%s' for %d", dimKey); + AELog.info("Allocating storage cell dimension '%s'", dimKey); - PacketBuffer extraData = SpatialDimensionExtraData.create(contentSize); + PacketBuffer extraData = new SpatialDimensionExtraData(size).write(); return DimensionManager.registerDimension(dimKey, StorageCellModDimension.INSTANCE, extraData, true); } @@ -114,13 +125,48 @@ public class SpatialDimensionManager implements ISpatialDimension } @Override - public BlockPos getCellContentSize( DimensionType cellDim ) + public BlockPos getCellDimensionSize(DimensionType cellDim ) { - if (!(cellDim.getModType() instanceof StorageCellModDimension)) { - return BlockPos.ZERO; + SpatialDimensionExtraData extraData = getExtraData(cellDim); + return extraData != null ? extraData.getSize() : BlockPos.ZERO; + } + + @Override + public void addCellDimensionTooltip(DimensionType cellDim, List lines) { + // Check if the cell dimension type is even registered + ResourceLocation registryName = cellDim.getRegistryName(); + if (registryName == null || !AppEng.MOD_ID.equals(registryName.getNamespace())) { + return; } - return SpatialDimensionExtraData.getContentSize(cellDim.getData()); + if (!registryName.getPath().startsWith(DIM_ID_PREFIX)) { + return; + } + + // Add the actual stored size + BlockPos size = SpatialDimensionManager.INSTANCE.getCellDimensionSize(cellDim); + lines.add( GuiText.StoredSize.textComponent(size.getX(), size.getY(), size.getZ())); + + // Add a serial number to allows players to keep different cells apart + int dimId; + try { + String numericIdPart = registryName.getPath().substring(DIM_ID_PREFIX.length()); + dimId = Integer.parseUnsignedInt(numericIdPart); + } catch (NumberFormatException ignored) { + return; + } + + // Try to make this a little more flavorful. + String serialNumber = String.format(Locale.ROOT, "SP-%04d", dimId); + lines.add(GuiText.SerialNumber.textComponent(serialNumber)); + } + + @Nullable + private SpatialDimensionExtraData getExtraData( DimensionType cellDim) { + if (!(cellDim.getModType() instanceof StorageCellModDimension)) { + return null; + } + return SpatialDimensionExtraData.read(cellDim.getData()); } private static MinecraftServer getServer() { diff --git a/src/main/resources/assets/appliedenergistics2/lang/en_us.json b/src/main/resources/assets/appliedenergistics2/lang/en_us.json index 6d0f1dd21..9a46c2e73 100644 --- a/src/main/resources/assets/appliedenergistics2/lang/en_us.json +++ b/src/main/resources/assets/appliedenergistics2/lang/en_us.json @@ -158,7 +158,6 @@ "gui.appliedenergistics2.CPUs": "CPU", "gui.appliedenergistics2.CalculatingWait": "Calculating Please Wait...", "gui.appliedenergistics2.Cancel": "Cancel", - "gui.appliedenergistics2.CellId": "Cell ID", "gui.appliedenergistics2.CellWorkbench": "Cell Workbench", "gui.appliedenergistics2.ChargedQuartz": "Charged Certus Quartz is crafted by inserting an uncharged Certus Quartz Crystal into the Charger, and powering it.", "gui.appliedenergistics2.ChargedQuartzFind": "Charged Certus Quartz can be found in world semi rarely, it appears similar to normal Certus Quartz, except it sparkles.", @@ -182,6 +181,8 @@ "gui.appliedenergistics2.ETAFormat": "HH:mm:ss", "gui.appliedenergistics2.Efficiency": "Efficiency", "gui.appliedenergistics2.Empty": "Empty", + "gui.appliedenergistics2.Unformatted": "Unformatted", + "gui.appliedenergistics2.SerialNumber": "Serial Number: %s", "gui.appliedenergistics2.Encoded": "Encoded", "gui.appliedenergistics2.EnergyDrain": "Passive Drain", "gui.appliedenergistics2.Excluded": "Excluded", @@ -272,7 +273,8 @@ "gui.appliedenergistics2.StoredFluids": "Stored Fluids", "gui.appliedenergistics2.StoredItems": "Stored Items", "gui.appliedenergistics2.StoredPower": "Stored Power", - "gui.appliedenergistics2.StoredSize": "Stored Size", + "gui.appliedenergistics2.StoredSize": "Stored Size: %dx%dx%d", + "gui.appliedenergistics2.SpatialCapacity": "Capacity: %dx%dx%d", "gui.appliedenergistics2.Stores": "Stores", "gui.appliedenergistics2.Substitute": "Using Substitutions:", "gui.appliedenergistics2.Terminal": "Terminal", diff --git a/src/test/java/appeng/core/worlddata/SpatialDimensionExtraDataTest.java b/src/test/java/appeng/core/worlddata/SpatialDimensionExtraDataTest.java index 19da64f56..5427438ea 100644 --- a/src/test/java/appeng/core/worlddata/SpatialDimensionExtraDataTest.java +++ b/src/test/java/appeng/core/worlddata/SpatialDimensionExtraDataTest.java @@ -15,18 +15,19 @@ public class SpatialDimensionExtraDataTest { */ @Test public void testCreatedBufferSize() { - PacketBuffer buffer = SpatialDimensionExtraData.create(BlockPos.ZERO); - assertEquals(9, buffer.array().length); + PacketBuffer buffer = new SpatialDimensionExtraData(BlockPos.ZERO).write(); + assertEquals(1 + 8 + 8, buffer.array().length); } @Test public void testReadWriteSize() { - BlockPos pos = new BlockPos(1, 2, 3); - PacketBuffer buffer = SpatialDimensionExtraData.create(pos); + BlockPos capacity = new BlockPos(1, 2, 3); + PacketBuffer buffer = new SpatialDimensionExtraData(capacity).write(); PacketBuffer readBackBuf = new PacketBuffer(Unpooled.wrappedBuffer(buffer.array())); - BlockPos actualPos = SpatialDimensionExtraData.getContentSize(readBackBuf); - assertEquals(pos, actualPos); + SpatialDimensionExtraData extraData = SpatialDimensionExtraData.read(readBackBuf); + assertNotNull(extraData); + assertEquals(capacity, extraData.getSize()); } /** @@ -34,14 +35,12 @@ public class SpatialDimensionExtraDataTest { */ @Test public void testHandleInvalidFormatVersion() { - BlockPos pos = new BlockPos(1, 2, 3); - PacketBuffer buffer = SpatialDimensionExtraData.create(pos); + PacketBuffer buffer = new SpatialDimensionExtraData(BlockPos.ZERO).write(); buffer.writerIndex(0); buffer.writeByte(5); PacketBuffer readBackBuf = new PacketBuffer(Unpooled.wrappedBuffer(buffer.array())); - BlockPos actualPos = SpatialDimensionExtraData.getContentSize(readBackBuf); - assertEquals(BlockPos.ZERO, actualPos); + assertNull(SpatialDimensionExtraData.read(readBackBuf)); } } \ No newline at end of file