API changes

*Renamed BlockWrapper to BlockVector.
*Moved BlockVector to API.
This commit is contained in:
Aidan Brady 2013-04-19 16:49:34 -04:00
parent 670990ea57
commit d5f5f21040
5 changed files with 38 additions and 39 deletions

View file

@ -1,18 +1,18 @@
package mekanism.common;
package mekanism.api;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
public class BlockWrapper
public class BlockVector
{
public int xCoord;
public int yCoord;
public int zCoord;
public int dimensionId;
public BlockWrapper(int x, int y, int z)
public BlockVector(int x, int y, int z)
{
xCoord = x;
yCoord = y;
@ -20,7 +20,7 @@ public class BlockWrapper
dimensionId = 0;
}
public BlockWrapper(int x, int y, int z, int dimension)
public BlockVector(int x, int y, int z, int dimension)
{
xCoord = x;
yCoord = y;
@ -41,29 +41,29 @@ public class BlockWrapper
nbtTags.setInteger("dimensionId", dimensionId);
}
public BlockWrapper getFromSide(ForgeDirection side)
public BlockVector getFromSide(ForgeDirection side)
{
return new BlockWrapper(xCoord+side.offsetX, yCoord+side.offsetY, zCoord+side.offsetZ, dimensionId);
return new BlockVector(xCoord+side.offsetX, yCoord+side.offsetY, zCoord+side.offsetZ, dimensionId);
}
public static BlockWrapper get(TileEntity tileEntity)
public static BlockVector get(TileEntity tileEntity)
{
return new BlockWrapper(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord, tileEntity.worldObj.provider.dimensionId);
return new BlockVector(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord, tileEntity.worldObj.provider.dimensionId);
}
public static BlockWrapper read(NBTTagCompound nbtTags)
public static BlockVector read(NBTTagCompound nbtTags)
{
return new BlockWrapper(nbtTags.getInteger("x"), nbtTags.getInteger("y"), nbtTags.getInteger("z"), nbtTags.getInteger("dimensionId"));
return new BlockVector(nbtTags.getInteger("x"), nbtTags.getInteger("y"), nbtTags.getInteger("z"), nbtTags.getInteger("dimensionId"));
}
@Override
public boolean equals(Object obj)
{
return obj instanceof BlockWrapper &&
((BlockWrapper)obj).xCoord == xCoord &&
((BlockWrapper)obj).yCoord == yCoord &&
((BlockWrapper)obj).zCoord == zCoord &&
((BlockWrapper)obj).dimensionId == dimensionId;
return obj instanceof BlockVector &&
((BlockVector)obj).xCoord == xCoord &&
((BlockVector)obj).yCoord == yCoord &&
((BlockVector)obj).zCoord == zCoord &&
((BlockVector)obj).dimensionId == dimensionId;
}
@Override

View file

@ -2,8 +2,6 @@ package mekanism.api;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import universalelectricity.core.vector.Vector3;
import universalelectricity.core.vector.VectorHelper;
/**
* A handy class containing several utilities for efficient gas transfer.
@ -23,7 +21,7 @@ public final class GasTransmission
for(ForgeDirection orientation : ForgeDirection.VALID_DIRECTIONS)
{
TileEntity tube = VectorHelper.getTileEntityFromSide(tileEntity.worldObj, new Vector3(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord), orientation);
TileEntity tube = BlockVector.get(tileEntity).getFromSide(orientation).getTileEntity(tileEntity.worldObj);
if(tube instanceof IPressurizedTube && ((IPressurizedTube)tube).canTransferGas(tileEntity))
{
@ -45,7 +43,7 @@ public final class GasTransmission
for(ForgeDirection orientation : ForgeDirection.VALID_DIRECTIONS)
{
TileEntity acceptor = VectorHelper.getTileEntityFromSide(tileEntity.worldObj, new Vector3(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord), orientation);
TileEntity acceptor = BlockVector.get(tileEntity).getFromSide(orientation).getTileEntity(tileEntity.worldObj);
if(acceptor instanceof IGasAcceptor)
{
@ -67,7 +65,7 @@ public final class GasTransmission
for(ForgeDirection orientation : ForgeDirection.VALID_DIRECTIONS)
{
TileEntity connection = VectorHelper.getTileEntityFromSide(tileEntity.worldObj, new Vector3(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord), orientation);
TileEntity connection = BlockVector.get(tileEntity).getFromSide(orientation).getTileEntity(tileEntity.worldObj);
if(connection instanceof ITubeConnection)
{
@ -88,7 +86,7 @@ public final class GasTransmission
*/
public static int emitGasToNetwork(EnumGas type, int amount, TileEntity sender, ForgeDirection facing)
{
TileEntity pointer = VectorHelper.getTileEntityFromSide(sender.worldObj, new Vector3(sender.xCoord, sender.yCoord, sender.zCoord), facing);
TileEntity pointer = BlockVector.get(sender).getFromSide(facing).getTileEntity(sender.worldObj);
if(pointer instanceof IPressurizedTube)
{

View file

@ -1,6 +1,5 @@
package mekanism.api;
public class SideData
{
/** The color of this SideData */

View file

@ -10,6 +10,7 @@ import java.net.URL;
import java.util.ArrayList;
import java.util.Map;
import mekanism.api.BlockVector;
import mekanism.api.EnumColor;
import mekanism.api.IConfigurable;
import mekanism.api.InfuseObject;
@ -715,7 +716,7 @@ public final class MekanismUtils
* @param blockTwo - second block
* @return distance between the two blocks
*/
public static int getDistance(BlockWrapper blockOne, BlockWrapper blockTwo)
public static int getDistance(BlockVector blockOne, BlockVector blockTwo)
{
int subX = blockOne.xCoord - blockTwo.xCoord;
int subY = blockOne.yCoord - blockTwo.yCoord;

View file

@ -20,6 +20,7 @@ import universalelectricity.core.item.ElectricItemHelper;
import universalelectricity.core.item.IItemElectric;
import universalelectricity.core.vector.Vector3;
import universalelectricity.core.vector.VectorHelper;
import mekanism.api.BlockVector;
import mekanism.api.IStrictEnergyAcceptor;
import mekanism.api.InfusionType;
import net.minecraft.block.Block;
@ -41,10 +42,10 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I
public LiquidTank liquidTank;
/** The nodes that have full sources near them or in them */
public Set<BlockWrapper> recurringNodes = new HashSet<BlockWrapper>();
public Set<BlockVector> recurringNodes = new HashSet<BlockVector>();
/** The nodes that have already been sucked up, but are held on to in order to remove dead blocks */
public Set<BlockWrapper> cleaningNodes = new HashSet<BlockWrapper>();
public Set<BlockVector> cleaningNodes = new HashSet<BlockVector>();
/** Random for this pump */
public Random random = new Random();
@ -137,12 +138,12 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I
public boolean suck(boolean take)
{
List<BlockWrapper> tempPumpList = Arrays.asList(recurringNodes.toArray(new BlockWrapper[recurringNodes.size()]));
List<BlockVector> tempPumpList = Arrays.asList(recurringNodes.toArray(new BlockVector[recurringNodes.size()]));
Collections.shuffle(tempPumpList);
for(ForgeDirection orientation : ForgeDirection.VALID_DIRECTIONS)
{
BlockWrapper wrapper = BlockWrapper.get(this).getFromSide(orientation);
BlockVector wrapper = BlockVector.get(this).getFromSide(orientation);
if(MekanismUtils.isLiquid(worldObj, wrapper.xCoord, wrapper.yCoord, wrapper.zCoord))
{
@ -151,7 +152,7 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I
if(take)
{
setJoules(electricityStored - 100);
recurringNodes.add(new BlockWrapper(wrapper.xCoord, wrapper.yCoord, wrapper.zCoord));
recurringNodes.add(new BlockVector(wrapper.xCoord, wrapper.yCoord, wrapper.zCoord));
liquidTank.fill(MekanismUtils.getLiquid(worldObj, wrapper.xCoord, wrapper.yCoord, wrapper.zCoord), true);
worldObj.setBlockToAir(wrapper.xCoord, wrapper.yCoord, wrapper.zCoord);
}
@ -161,7 +162,7 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I
}
}
for(BlockWrapper wrapper : cleaningNodes)
for(BlockVector wrapper : cleaningNodes)
{
if(MekanismUtils.isLiquid(worldObj, wrapper.xCoord, wrapper.yCoord, wrapper.zCoord))
{
@ -179,7 +180,7 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I
}
}
for(BlockWrapper wrapper : tempPumpList)
for(BlockVector wrapper : tempPumpList)
{
if(MekanismUtils.isLiquid(worldObj, wrapper.xCoord, wrapper.yCoord, wrapper.zCoord))
{
@ -198,9 +199,9 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I
for(ForgeDirection orientation : ForgeDirection.VALID_DIRECTIONS)
{
BlockWrapper side = wrapper.getFromSide(orientation);
BlockVector side = wrapper.getFromSide(orientation);
if(MekanismUtils.getDistance(BlockWrapper.get(this), side) <= 80)
if(MekanismUtils.getDistance(BlockVector.get(this), side) <= 80)
{
if(MekanismUtils.isLiquid(worldObj, side.xCoord, side.yCoord, side.zCoord))
{
@ -232,7 +233,7 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I
boolean took = false;
if(!worldObj.isRemote)
{
for(BlockWrapper wrapper : cleaningNodes)
for(BlockVector wrapper : cleaningNodes)
{
if(MekanismUtils.isDeadLiquid(worldObj, wrapper.xCoord, wrapper.yCoord, wrapper.zCoord))
{
@ -247,7 +248,7 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I
}
}
for(BlockWrapper wrapper : recurringNodes)
for(BlockVector wrapper : recurringNodes)
{
if(MekanismUtils.isDeadLiquid(worldObj, wrapper.xCoord, wrapper.yCoord, wrapper.zCoord))
{
@ -264,7 +265,7 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I
for(ForgeDirection orientation : ForgeDirection.VALID_DIRECTIONS)
{
BlockWrapper wrapper = BlockWrapper.get(this).getFromSide(orientation);
BlockVector wrapper = BlockVector.get(this).getFromSide(orientation);
if(MekanismUtils.isDeadLiquid(worldObj, wrapper.xCoord, wrapper.yCoord, wrapper.zCoord))
{
@ -344,7 +345,7 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I
NBTTagList recurringList = new NBTTagList();
for(BlockWrapper wrapper : recurringNodes)
for(BlockVector wrapper : recurringNodes)
{
NBTTagCompound tagCompound = new NBTTagCompound();
wrapper.write(tagCompound);
@ -358,7 +359,7 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I
NBTTagList cleaningList = new NBTTagList();
for(BlockWrapper wrapper : cleaningNodes)
for(BlockVector wrapper : cleaningNodes)
{
NBTTagCompound tagCompound = new NBTTagCompound();
wrapper.write(tagCompound);
@ -387,7 +388,7 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I
for(int i = 0; i < tagList.tagCount(); i++)
{
recurringNodes.add(BlockWrapper.read((NBTTagCompound)tagList.tagAt(i)));
recurringNodes.add(BlockVector.read((NBTTagCompound)tagList.tagAt(i)));
}
}
@ -397,7 +398,7 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I
for(int i = 0; i < tagList.tagCount(); i++)
{
cleaningNodes.add(BlockWrapper.read((NBTTagCompound)tagList.tagAt(i)));
cleaningNodes.add(BlockVector.read((NBTTagCompound)tagList.tagAt(i)));
}
}
}