Remove inheratance from ConnectionMatrix. Save 6 bytes per packet
This commit is contained in:
parent
f9354ed275
commit
83dfaf02d3
3 changed files with 16 additions and 23 deletions
|
@ -14,7 +14,6 @@ import java.io.DataOutputStream;
|
|||
import java.io.IOException;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
|
@ -241,10 +240,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank
|
|||
// Facades
|
||||
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
|
||||
int blockId = this.facadeBlocks[direction.ordinal()];
|
||||
renderState.facadeMatrix.setConnected(direction, blockId != 0 && Block.blocksList[blockId] != null);
|
||||
if (Block.blocksList[blockId] != null) {
|
||||
renderState.facadeMatrix.setFacade(direction, blockId, this.facadeMeta[direction.ordinal()]);
|
||||
}
|
||||
renderState.facadeMatrix.setFacade(direction, blockId, this.facadeMeta[direction.ordinal()]);
|
||||
}
|
||||
|
||||
if (renderState.isDirty()) {
|
||||
|
@ -579,7 +575,7 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, ITank
|
|||
|
||||
public boolean hasFacade(ForgeDirection direction) {
|
||||
if (this.worldObj.isRemote)
|
||||
return renderState.facadeMatrix.isConnected(direction);
|
||||
return renderState.facadeMatrix.getFacadeBlockId(direction) != 0;
|
||||
return (this.facadeBlocks[direction.ordinal()] != 0);
|
||||
}
|
||||
|
||||
|
|
|
@ -181,7 +181,7 @@ public class PipeWorldRenderer implements ISimpleBlockRenderingHandler {
|
|||
zeroState[2][1] = 1.0F;
|
||||
|
||||
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
|
||||
if (state.facadeMatrix.isConnected(direction)) {
|
||||
if (state.facadeMatrix.getFacadeBlockId(direction) != 0) {
|
||||
state.currentTexture = Block.blocksList[state.facadeMatrix.getFacadeBlockId(direction)].getIcon(direction.ordinal(), state.facadeMatrix.getFacadeMetaId(direction));
|
||||
|
||||
// Hollow facade
|
||||
|
@ -243,7 +243,7 @@ public class PipeWorldRenderer implements ISimpleBlockRenderingHandler {
|
|||
state.currentTexture = BuildCraftTransport.instance.pipeIconProvider.getIcon(PipeIconProvider.PipeStructureCobblestone); // Structure Pipe
|
||||
|
||||
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
|
||||
if (state.facadeMatrix.isConnected(direction) && !state.pipeConnectionMatrix.isConnected(direction)) {
|
||||
if (state.facadeMatrix.getFacadeBlockId(direction) != 0 && !state.pipeConnectionMatrix.isConnected(direction)) {
|
||||
float[][] rotated = deepClone(zeroState);
|
||||
transform(rotated, direction);
|
||||
|
||||
|
@ -480,42 +480,46 @@ public class PipeWorldRenderer implements ISimpleBlockRenderingHandler {
|
|||
float min = Utils.pipeMinPos + 0.05F;
|
||||
float max = Utils.pipeMaxPos - 0.05F;
|
||||
|
||||
if (!state.pipeConnectionMatrix.isConnected(ForgeDirection.WEST) && !state.facadeMatrix.isConnected(ForgeDirection.WEST)) {
|
||||
if (shouldRenderNormalPipeSide(state, ForgeDirection.WEST)) {
|
||||
block.setBlockBounds(Utils.pipeMinPos - 0.10F, min, min, Utils.pipeMinPos, max, max);
|
||||
renderblocks.setRenderBoundsFromBlock(block);
|
||||
renderblocks.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
|
||||
if (!state.pipeConnectionMatrix.isConnected(ForgeDirection.EAST) && !state.facadeMatrix.isConnected(ForgeDirection.EAST)) {
|
||||
if (shouldRenderNormalPipeSide(state, ForgeDirection.EAST)) {
|
||||
block.setBlockBounds(Utils.pipeMaxPos, min, min, Utils.pipeMaxPos + 0.10F, max, max);
|
||||
renderblocks.setRenderBoundsFromBlock(block);
|
||||
renderblocks.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
|
||||
if (!state.pipeConnectionMatrix.isConnected(ForgeDirection.DOWN) && !state.facadeMatrix.isConnected(ForgeDirection.DOWN)) {
|
||||
if (shouldRenderNormalPipeSide(state, ForgeDirection.DOWN)) {
|
||||
block.setBlockBounds(min, Utils.pipeMinPos - 0.10F, min, max, Utils.pipeMinPos, max);
|
||||
renderblocks.setRenderBoundsFromBlock(block);
|
||||
renderblocks.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
|
||||
if (!state.pipeConnectionMatrix.isConnected(ForgeDirection.UP) && !state.facadeMatrix.isConnected(ForgeDirection.UP)) {
|
||||
if (shouldRenderNormalPipeSide(state, ForgeDirection.UP)) {
|
||||
block.setBlockBounds(min, Utils.pipeMaxPos, min, max, Utils.pipeMaxPos + 0.10F, max);
|
||||
renderblocks.setRenderBoundsFromBlock(block);
|
||||
renderblocks.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
|
||||
if (!state.pipeConnectionMatrix.isConnected(ForgeDirection.NORTH) && !state.facadeMatrix.isConnected(ForgeDirection.NORTH)) {
|
||||
if (shouldRenderNormalPipeSide(state, ForgeDirection.NORTH)) {
|
||||
block.setBlockBounds(min, min, Utils.pipeMinPos - 0.10F, max, max, Utils.pipeMinPos);
|
||||
renderblocks.setRenderBoundsFromBlock(block);
|
||||
renderblocks.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
|
||||
if (!state.pipeConnectionMatrix.isConnected(ForgeDirection.SOUTH) && !state.facadeMatrix.isConnected(ForgeDirection.SOUTH)) {
|
||||
if (shouldRenderNormalPipeSide(state, ForgeDirection.SOUTH)) {
|
||||
block.setBlockBounds(min, min, Utils.pipeMaxPos, max, max, Utils.pipeMaxPos + 0.10F);
|
||||
renderblocks.setRenderBoundsFromBlock(block);
|
||||
renderblocks.renderStandardBlock(block, x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean shouldRenderNormalPipeSide(PipeRenderState state, ForgeDirection direction){
|
||||
return !state.pipeConnectionMatrix.isConnected(direction) && state.facadeMatrix.getFacadeBlockId(direction) != 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) {
|
||||
|
|
|
@ -6,7 +6,7 @@ import java.io.IOException;
|
|||
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
public class FacadeMatrix extends ConnectionMatrix {
|
||||
public class FacadeMatrix {
|
||||
private final int[] _blockIds = new int[ForgeDirection.VALID_DIRECTIONS.length];
|
||||
private final int[] _blockMetas = new int[ForgeDirection.VALID_DIRECTIONS.length];
|
||||
|
||||
|
@ -31,29 +31,22 @@ public class FacadeMatrix extends ConnectionMatrix {
|
|||
return _blockMetas[direction.ordinal()];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDirty() {
|
||||
return dirty || super.isDirty();
|
||||
return dirty;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clean() {
|
||||
super.clean();
|
||||
dirty = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readData(DataInputStream data) throws IOException {
|
||||
super.readData(data);
|
||||
for (int i = 0; i < ForgeDirection.VALID_DIRECTIONS.length; i++) {
|
||||
_blockIds[i] = data.readInt();
|
||||
_blockMetas[i] = data.readInt();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeData(DataOutputStream data) throws IOException {
|
||||
super.writeData(data);
|
||||
for (int i = 0; i < ForgeDirection.VALID_DIRECTIONS.length; i++) {
|
||||
data.writeInt(_blockIds[i]);
|
||||
data.writeInt(_blockMetas[i]);
|
||||
|
|
Loading…
Reference in a new issue