Spatial Sky Renderer fixed

Changed Tooltips for Spatial Cells
Updated forge + mcp
This commit is contained in:
Sebastian Hartte
2020-06-13 15:51:04 +02:00
parent 5ec9600177
commit a4b16c21a3
12 changed files with 187 additions and 110 deletions
+2 -2
View File
@@ -10,8 +10,8 @@ artifact_basename=appliedenergistics2
######################################################### #########################################################
minecraft_release=1.15 minecraft_release=1.15
minecraft_version=1.15.2 minecraft_version=1.15.2
mcp_mappings=20200514-1.15.1 mcp_mappings=20200613-1.15.1
forge_version=31.2.0 forge_version=31.2.19
######################################################### #########################################################
# Provided APIs # # Provided APIs #
@@ -33,9 +33,9 @@ public class TransitionResult
public final boolean success; public final boolean success;
public final double energyUsage; 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; this.energyUsage = power;
} }
} }
@@ -20,11 +20,13 @@ package appeng.api.storage;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.dimension.DimensionType; import net.minecraft.world.dimension.DimensionType;
import net.minecraft.world.server.ServerWorld; import net.minecraft.world.server.ServerWorld;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.List;
public interface ISpatialDimension public interface ISpatialDimension
@@ -32,7 +34,7 @@ public interface ISpatialDimension
ServerWorld getWorld(DimensionType cellDim ); ServerWorld getWorld(DimensionType cellDim );
@Nullable @Nullable
DimensionType createNewCellDimension(BlockPos contentSize); DimensionType createNewCellDimension(BlockPos capacity);
void deleteCellDimension( DimensionType cellDim ); void deleteCellDimension( DimensionType cellDim );
@@ -40,5 +42,12 @@ public interface ISpatialDimension
BlockPos getCellDimensionOrigin( DimensionType cellDim ); 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<ITextComponent> lines);
} }
@@ -222,7 +222,7 @@ public class BlockCableBus extends AEBaseTileBlock<TileCableBus> /* FIXME implem
double z = target.getHitVec().z; double z = target.getHitVec().z;
// FIXME: Check how this looks, probably like shit, maybe provide parts the ability to supply particle textures??? // 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) effectRenderer.addEffect(new CableBusBreakingParticle(world, x, y, z, texture)
.multipleParticleScaleBy(0.8F)); .multiplyParticleScaleBy(0.8F));
} }
return true; return true;
@@ -20,12 +20,15 @@ package appeng.capabilities;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.world.World; import net.minecraft.world.World;
import appeng.api.storage.ISpatialDimension; import appeng.api.storage.ISpatialDimension;
import net.minecraft.world.dimension.DimensionType; import net.minecraft.world.dimension.DimensionType;
import net.minecraft.world.server.ServerWorld; import net.minecraft.world.server.ServerWorld;
import java.util.List;
class NullSpatialDimension implements ISpatialDimension class NullSpatialDimension implements ISpatialDimension
{ {
@@ -47,6 +50,15 @@ class NullSpatialDimension implements ISpatialDimension
} }
@Override @Override
public BlockPos getCellDimensionSize(DimensionType cellDim) {
return BlockPos.ZERO;
}
@Override
public void addCellDimensionTooltip(DimensionType cellDim, List<ITextComponent> tooltip) {
}
@Override
public ServerWorld getWorld(DimensionType cellStorageId ) public ServerWorld getWorld(DimensionType cellStorageId )
{ {
return null; return null;
@@ -57,10 +69,4 @@ class NullSpatialDimension implements ISpatialDimension
{ {
return false; return false;
} }
@Override
public BlockPos getCellContentSize( DimensionType cellDimId )
{
return null;
}
} }
@@ -21,9 +21,11 @@ package appeng.client.render;
import java.util.Random; import java.util.Random;
import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.renderer.Quaternion;
import net.minecraftforge.client.SkyRenderHandler;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
@@ -36,7 +38,7 @@ import net.minecraftforge.client.IRenderHandler;
//TODO https://github.com/MinecraftForge/MinecraftForge/pull/6537 //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(); private static final SpatialSkyRender INSTANCE = new SpatialSkyRender();
@@ -55,14 +57,17 @@ public class SpatialSkyRender implements IRenderHandler
return INSTANCE; return INSTANCE;
} }
@Override private static final Quaternion[] SKYBOX_SIDE_ROTATIONS = {
public void render( final int ticks, final float partialTicks, final ClientWorld world, final Minecraft mc ) Quaternion.ONE,
{ new Quaternion( 90.0F, 0.0F, 0.0F, true ),
//FIXME, Do not use this until the above PR is merged. new Quaternion( -90.0F, 0.0F, 0.0F, true ),
if (true) { new Quaternion( 180.0F, 0.0F, 0.0F, true ),
return; 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(); final long now = System.currentTimeMillis();
if( now - this.cycle > 2000 ) if( now - this.cycle > 2000 )
{ {
@@ -76,46 +81,22 @@ public class SpatialSkyRender implements IRenderHandler
fade /= 1000; fade /= 1000;
fade = 0.15f * ( 1.0f - Math.abs( ( fade - 1.0f ) * ( fade - 1.0f ) ) ); fade = 0.15f * ( 1.0f - Math.abs( ( fade - 1.0f ) * ( fade - 1.0f ) ) );
GlStateManager.disableFog(); RenderSystem.disableFog();
GlStateManager.disableAlphaTest(); RenderSystem.disableAlphaTest();
RenderSystem.disableBlend(); RenderSystem.disableBlend();
GlStateManager.depthMask( false ); RenderSystem.depthMask( false );
RenderSystem.color4f( 0.0f, 0.0f, 0.0f, 1.0f ); RenderSystem.color4f( 0.0f, 0.0f, 0.0f, 1.0f );
final Tessellator tessellator = Tessellator.getInstance(); final Tessellator tessellator = Tessellator.getInstance();
final BufferBuilder VertexBuffer = tessellator.getBuffer(); final BufferBuilder VertexBuffer = tessellator.getBuffer();
// This renders a skybox around the player at a far, fixed distance from them. // This renders a skybox around the player at a far, fixed distance from them.
// The skybox is pitch black and untextured // 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 ) RenderSystem.disableTexture();
{
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();
VertexBuffer.begin( GL11.GL_QUADS, DefaultVertexFormats.POSITION ); 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();
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(); VertexBuffer.pos( 100.0D, -100.0D, -100.0D ).endVertex();
tessellator.draw(); tessellator.draw();
RenderSystem.enableTexture(); RenderSystem.enableTexture();
GlStateManager.popMatrix(); matrixStack.pop();
} }
GlStateManager.depthMask( true ); RenderSystem.depthMask( true );
if( fade > 0.0f ) if( fade > 0.0f )
{ {
GlStateManager.disableFog(); RenderSystem.disableFog();
GlStateManager.disableAlphaTest(); RenderSystem.disableAlphaTest();
RenderSystem.enableBlend(); RenderSystem.enableBlend();
GlStateManager.disableTexture(); RenderSystem.disableTexture();
GlStateManager.depthMask( false ); RenderSystem.depthMask( false );
GlStateManager.blendFuncSeparate( GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0 ); RenderSystem.blendFuncSeparate( GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0 );
RenderHelper.disableStandardItemLighting(); RenderHelper.disableStandardItemLighting();
@@ -143,11 +124,11 @@ public class SpatialSkyRender implements IRenderHandler
GL11.glCallList( this.dspList ); GL11.glCallList( this.dspList );
} }
GlStateManager.depthMask( true ); RenderSystem.depthMask( true );
RenderSystem.enableBlend(); RenderSystem.enableBlend();
GlStateManager.enableAlphaTest(); RenderSystem.enableAlphaTest();
RenderSystem.enableTexture(); RenderSystem.enableTexture();
GlStateManager.enableFog(); RenderSystem.enableFog();
RenderSystem.color4f( 1.0f, 1.0f, 1.0f, 1.0f ); RenderSystem.color4f( 1.0f, 1.0f, 1.0f, 1.0f );
} }
@@ -155,8 +136,8 @@ public class SpatialSkyRender implements IRenderHandler
private void renderTwinkles() private void renderTwinkles()
{ {
final Tessellator tessellator = Tessellator.getInstance(); final Tessellator tessellator = Tessellator.getInstance();
final BufferBuilder VertexBuffer = tessellator.getBuffer(); final BufferBuilder vb = tessellator.getBuffer();
VertexBuffer.begin( GL11.GL_QUADS, DefaultVertexFormats.POSITION ); vb.begin( GL11.GL_QUADS, DefaultVertexFormats.POSITION );
for( int i = 0; i < 50; ++i ) 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 d23 = d17 * d12 - d20 * d13;
final double d24 = d23 * d9 - d21 * d10; final double d24 = d23 * d9 - d21 * d10;
final double d25 = d21 * d9 + d23 * 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();
} }
} }
} }
@@ -92,8 +92,10 @@ public enum GuiText
QuartzCuttingKnife, QuartzCuttingKnife,
// spatial // spatial
SpatialCapacity,
StoredSize, StoredSize,
CellId, Unformatted,
SerialNumber,
CopyMode, CopyMode,
CopyModeDesc, CopyModeDesc,
@@ -215,4 +217,8 @@ public enum GuiText
return new TranslationTextComponent(getTranslationKey()); return new TranslationTextComponent(getTranslationKey());
} }
public ITextComponent textComponent(Object... args) {
return new TranslationTextComponent(getTranslationKey(), args);
}
} }
@@ -34,6 +34,8 @@ import net.minecraft.nbt.CompoundNBT;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent; 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.World;
import net.minecraft.world.dimension.DimensionType; import net.minecraft.world.dimension.DimensionType;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
@@ -58,11 +60,17 @@ public class ItemSpatialStorageCell extends AEBaseItem implements ISpatialStorag
@Override @Override
public void addInformation(final ItemStack stack, final World world, final List<ITextComponent> lines, final ITooltipFlag advancedTooltips ) public void addInformation(final ItemStack stack, final World world, final List<ITextComponent> 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()) { if (advancedTooltips.isAdvanced()) {
final DimensionType dimType = this.getStoredDimension(stack);
if (dimType != null && dimType.getRegistryName() != null) { if (dimType != null && dimType.getRegistryName() != null) {
String ae2Id = dimType.getRegistryName().getPath(); lines.add(new StringTextComponent("Dimension: " + dimType.getRegistryName()));
lines.add(GuiText.CellId.textComponent().appendText(": " + ae2Id));
} }
} }
} }
@@ -105,7 +113,7 @@ public class ItemSpatialStorageCell extends AEBaseItem implements ISpatialStorag
final BlockPos targetSize = new BlockPos( targetX, targetY, targetZ ); final BlockPos targetSize = new BlockPos( targetX, targetY, targetZ );
ISpatialDimension manager = new SpatialDimensionManager(); ISpatialDimension manager = SpatialDimensionManager.INSTANCE;
DimensionType storedDim = this.getStoredDimension( is ); DimensionType storedDim = this.getStoredDimension( is );
if( storedDim == null ) if( storedDim == null )
@@ -124,7 +132,7 @@ public class ItemSpatialStorageCell extends AEBaseItem implements ISpatialStorag
{ {
World cellWorld = manager.getWorld(storedDim); World cellWorld = manager.getWorld(storedDim);
BlockPos scale = manager.getCellContentSize( storedDim ); BlockPos scale = manager.getCellDimensionSize( storedDim );
if( scale.equals( targetSize ) ) if( scale.equals( targetSize ) )
{ {
@@ -1,5 +1,6 @@
package appeng.spatial; package appeng.spatial;
import appeng.core.AELog;
import io.netty.buffer.Unpooled; import io.netty.buffer.Unpooled;
import net.minecraft.network.PacketBuffer; import net.minecraft.network.PacketBuffer;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
@@ -14,32 +15,51 @@ import javax.annotation.Nullable;
*/ */
public final class SpatialDimensionExtraData { public final class SpatialDimensionExtraData {
private static final int FORMAT_VERSION = 1; // Used to allow forward compatibility
private static final int OFFSET_VERSION = 0; private static final int CURRENT_FORMAT = 1;
private static final int OFFSET_CONTENT_SIZE = 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) { public PacketBuffer write() {
PacketBuffer extraData = new PacketBuffer(Unpooled.buffer()); PacketBuffer buf = new PacketBuffer(Unpooled.buffer());
extraData.writeByte(FORMAT_VERSION); buf.writeByte(CURRENT_FORMAT);
extraData.writeBlockPos(contentSize); buf.writeBlockPos(size);
// Cut the buffer to minimal size buf.capacity(buf.writerIndex()); // This cuts the backing buffer to the required size
extraData.capacity(extraData.writerIndex()); return buf;
return extraData;
} }
private static boolean checkVersion(PacketBuffer data){ public BlockPos getSize() {
return data.getByte(OFFSET_VERSION) == FORMAT_VERSION; return size;
} }
public static BlockPos getContentSize(@Nullable PacketBuffer data) { @Nullable
if (data == null || !checkVersion(data)) { public static SpatialDimensionExtraData read(@Nullable PacketBuffer buf) {
return BlockPos.ZERO; if (buf == null) {
return null;
} }
data.readerIndex(OFFSET_CONTENT_SIZE); try {
return data.readBlockPos(); 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;
}
} }
} }
@@ -22,33 +22,44 @@ package appeng.spatial;
import appeng.api.storage.ISpatialDimension; import appeng.api.storage.ISpatialDimension;
import appeng.core.AELog; import appeng.core.AELog;
import appeng.core.AppEng; import appeng.core.AppEng;
import appeng.core.localization.GuiText;
import net.minecraft.network.PacketBuffer; import net.minecraft.network.PacketBuffer;
import net.minecraft.server.MinecraftServer; import net.minecraft.server.MinecraftServer;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.world.dimension.DimensionType; import net.minecraft.world.dimension.DimensionType;
import net.minecraft.world.server.ServerWorld; import net.minecraft.world.server.ServerWorld;
import net.minecraftforge.common.DimensionManager; import net.minecraftforge.common.DimensionManager;
import net.minecraftforge.fml.server.ServerLifecycleHooks; 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 static final String DIM_ID_PREFIX = "spatial_";
private SpatialDimensionManager() {
}
@Override @Override
public ServerWorld getWorld(DimensionType cellDim) { public ServerWorld getWorld(DimensionType cellDim) {
return DimensionManager.getWorld(getServer(), cellDim, true, true); return DimensionManager.getWorld(getServer(), cellDim, true, true);
} }
@Override @Override
public DimensionType createNewCellDimension(BlockPos contentSize) public DimensionType createNewCellDimension(BlockPos size)
{ {
ResourceLocation dimKey = findFreeDimensionId(); 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); return DimensionManager.registerDimension(dimKey, StorageCellModDimension.INSTANCE, extraData, true);
} }
@@ -114,13 +125,48 @@ public class SpatialDimensionManager implements ISpatialDimension
} }
@Override @Override
public BlockPos getCellContentSize( DimensionType cellDim ) public BlockPos getCellDimensionSize(DimensionType cellDim )
{ {
if (!(cellDim.getModType() instanceof StorageCellModDimension)) { SpatialDimensionExtraData extraData = getExtraData(cellDim);
return BlockPos.ZERO; return extraData != null ? extraData.getSize() : BlockPos.ZERO;
}
@Override
public void addCellDimensionTooltip(DimensionType cellDim, List<ITextComponent> 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() { private static MinecraftServer getServer() {
@@ -158,7 +158,6 @@
"gui.appliedenergistics2.CPUs": "CPU", "gui.appliedenergistics2.CPUs": "CPU",
"gui.appliedenergistics2.CalculatingWait": "Calculating Please Wait...", "gui.appliedenergistics2.CalculatingWait": "Calculating Please Wait...",
"gui.appliedenergistics2.Cancel": "Cancel", "gui.appliedenergistics2.Cancel": "Cancel",
"gui.appliedenergistics2.CellId": "Cell ID",
"gui.appliedenergistics2.CellWorkbench": "Cell Workbench", "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.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.", "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.ETAFormat": "HH:mm:ss",
"gui.appliedenergistics2.Efficiency": "Efficiency", "gui.appliedenergistics2.Efficiency": "Efficiency",
"gui.appliedenergistics2.Empty": "Empty", "gui.appliedenergistics2.Empty": "Empty",
"gui.appliedenergistics2.Unformatted": "Unformatted",
"gui.appliedenergistics2.SerialNumber": "Serial Number: %s",
"gui.appliedenergistics2.Encoded": "Encoded", "gui.appliedenergistics2.Encoded": "Encoded",
"gui.appliedenergistics2.EnergyDrain": "Passive Drain", "gui.appliedenergistics2.EnergyDrain": "Passive Drain",
"gui.appliedenergistics2.Excluded": "Excluded", "gui.appliedenergistics2.Excluded": "Excluded",
@@ -272,7 +273,8 @@
"gui.appliedenergistics2.StoredFluids": "Stored Fluids", "gui.appliedenergistics2.StoredFluids": "Stored Fluids",
"gui.appliedenergistics2.StoredItems": "Stored Items", "gui.appliedenergistics2.StoredItems": "Stored Items",
"gui.appliedenergistics2.StoredPower": "Stored Power", "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.Stores": "Stores",
"gui.appliedenergistics2.Substitute": "Using Substitutions:", "gui.appliedenergistics2.Substitute": "Using Substitutions:",
"gui.appliedenergistics2.Terminal": "Terminal", "gui.appliedenergistics2.Terminal": "Terminal",
@@ -15,18 +15,19 @@ public class SpatialDimensionExtraDataTest {
*/ */
@Test @Test
public void testCreatedBufferSize() { public void testCreatedBufferSize() {
PacketBuffer buffer = SpatialDimensionExtraData.create(BlockPos.ZERO); PacketBuffer buffer = new SpatialDimensionExtraData(BlockPos.ZERO).write();
assertEquals(9, buffer.array().length); assertEquals(1 + 8 + 8, buffer.array().length);
} }
@Test @Test
public void testReadWriteSize() { public void testReadWriteSize() {
BlockPos pos = new BlockPos(1, 2, 3); BlockPos capacity = new BlockPos(1, 2, 3);
PacketBuffer buffer = SpatialDimensionExtraData.create(pos); PacketBuffer buffer = new SpatialDimensionExtraData(capacity).write();
PacketBuffer readBackBuf = new PacketBuffer(Unpooled.wrappedBuffer(buffer.array())); PacketBuffer readBackBuf = new PacketBuffer(Unpooled.wrappedBuffer(buffer.array()));
BlockPos actualPos = SpatialDimensionExtraData.getContentSize(readBackBuf); SpatialDimensionExtraData extraData = SpatialDimensionExtraData.read(readBackBuf);
assertEquals(pos, actualPos); assertNotNull(extraData);
assertEquals(capacity, extraData.getSize());
} }
/** /**
@@ -34,14 +35,12 @@ public class SpatialDimensionExtraDataTest {
*/ */
@Test @Test
public void testHandleInvalidFormatVersion() { public void testHandleInvalidFormatVersion() {
BlockPos pos = new BlockPos(1, 2, 3); PacketBuffer buffer = new SpatialDimensionExtraData(BlockPos.ZERO).write();
PacketBuffer buffer = SpatialDimensionExtraData.create(pos);
buffer.writerIndex(0); buffer.writerIndex(0);
buffer.writeByte(5); buffer.writeByte(5);
PacketBuffer readBackBuf = new PacketBuffer(Unpooled.wrappedBuffer(buffer.array())); PacketBuffer readBackBuf = new PacketBuffer(Unpooled.wrappedBuffer(buffer.array()));
BlockPos actualPos = SpatialDimensionExtraData.getContentSize(readBackBuf); assertNull(SpatialDimensionExtraData.read(readBackBuf));
assertEquals(BlockPos.ZERO, actualPos);
} }
} }