use of mcjty.lib.varia.Coordinate in project RFTools by McJty.
the class ItemStackPlusScreenModule method setupCoordinateFromNBT.
@Override
protected void setupCoordinateFromNBT(NBTTagCompound tagCompound, int dim, int x, int y, int z) {
coordinate = Coordinate.INVALID;
if (tagCompound.hasKey("monitorx")) {
this.dim = tagCompound.getInteger("dim");
coordinate = new Coordinate(tagCompound.getInteger("monitorx"), tagCompound.getInteger("monitory"), tagCompound.getInteger("monitorz"));
}
}
use of mcjty.lib.varia.Coordinate in project RFTools by McJty.
the class ShieldBlockTileEntity method readFromNBT.
@Override
public void readFromNBT(NBTTagCompound tagCompound) {
super.readFromNBT(tagCompound);
camoId = tagCompound.getInteger("camoId");
hasTe = tagCompound.getInteger("hasTe");
if (camoId == -1) {
block = null;
} else {
block = Block.getBlockById(camoId);
}
damageBits = tagCompound.getInteger("damageBits");
collisionData = tagCompound.getInteger("collisionData");
shieldColor = tagCompound.getInteger("shieldColor");
if (shieldColor == 0) {
shieldColor = 0x96ffc8;
}
int sx = tagCompound.getInteger("shieldX");
int sy = tagCompound.getInteger("shieldY");
int sz = tagCompound.getInteger("shieldZ");
shieldBlock = new Coordinate(sx, sy, sz);
if (worldObj != null && worldObj.isRemote) {
// For some reason this is needed to force rendering on the client when apply is pressed.
worldObj.markBlockRangeForRenderUpdate(xCoord, yCoord, zCoord, xCoord, yCoord, zCoord);
}
}
use of mcjty.lib.varia.Coordinate in project RFTools by McJty.
the class AbstractShieldBlock method checkEntityCD.
private boolean checkEntityCD(World world, int x, int y, int z, String filterName) {
ShieldBlockTileEntity shieldBlockTileEntity = (ShieldBlockTileEntity) world.getTileEntity(x, y, z);
Coordinate shieldBlock = shieldBlockTileEntity.getShieldBlock();
if (shieldBlock != null) {
ShieldTEBase shieldTileEntity = (ShieldTEBase) world.getTileEntity(shieldBlock.getX(), shieldBlock.getY(), shieldBlock.getZ());
if (shieldTileEntity != null) {
List<ShieldFilter> filters = shieldTileEntity.getFilters();
for (ShieldFilter filter : filters) {
if (DefaultFilter.DEFAULT.equals(filter.getFilterName())) {
return (filter.getAction() & ShieldFilter.ACTION_SOLID) != 0;
} else if (filterName.equals(filter.getFilterName())) {
return (filter.getAction() & ShieldFilter.ACTION_SOLID) != 0;
}
}
}
}
return false;
}
use of mcjty.lib.varia.Coordinate in project RFTools by McJty.
the class ShieldTEBase method addToTodoCornered.
private void addToTodoCornered(Set<Coordinate> coordinateSet, Deque<Coordinate> todo, Coordinate coordinate, int meta) {
int x = coordinate.getX();
int y = coordinate.getY();
int z = coordinate.getZ();
for (int xx = x - 1; xx <= x + 1; xx++) {
for (int yy = y - 1; yy <= y + 1; yy++) {
for (int zz = z - 1; zz <= z + 1; zz++) {
if (xx != x || yy != y || zz != z) {
if (yy >= 0 && yy < worldObj.getHeight()) {
Coordinate c = new Coordinate(xx, yy, zz);
if (!coordinateSet.contains(c)) {
if (ShieldSetup.shieldTemplateBlock.equals(worldObj.getBlock(xx, yy, zz))) {
int m = worldObj.getBlockMetadata(xx, yy, zz);
if (m == meta) {
if (!todo.contains(c)) {
todo.addLast(c);
}
}
}
}
}
}
}
}
}
}
use of mcjty.lib.varia.Coordinate in project RFTools by McJty.
the class ShieldTEBase method selectBlock.
@Override
public void selectBlock(EntityPlayer player, int x, int y, int z) {
if (!shieldComposed) {
Logging.message(player, EnumChatFormatting.YELLOW + "Shield is not composed. Nothing happens!");
return;
}
float squaredDistance = getCoordinate().squaredDistance(x, y, z);
if (squaredDistance > ShieldConfiguration.maxDisjointShieldDistance * ShieldConfiguration.maxDisjointShieldDistance) {
Logging.message(player, EnumChatFormatting.YELLOW + "This template is too far to connect to the shield!");
return;
}
Block origBlock = worldObj.getBlock(x, y, z);
Coordinate c = new Coordinate(x, y, z);
if (origBlock == ShieldSetup.shieldTemplateBlock) {
if (isShapedShield()) {
Logging.message(player, EnumChatFormatting.YELLOW + "You cannot add template blocks to a shaped shield (using a shape card)!");
return;
}
Set<Coordinate> templateBlocks = new HashSet<Coordinate>();
findTemplateBlocks(templateBlocks, worldObj.getBlockMetadata(x, y, z), false, c);
int[] camoId = calculateCamoId();
int cddata = calculateShieldCollisionData();
int damageBits = calculateDamageBits();
Block block = calculateShieldBlock(damageBits);
for (Coordinate templateBlock : templateBlocks) {
RelCoordinate relc = new RelCoordinate(templateBlock.getX() - xCoord, templateBlock.getY() - yCoord, templateBlock.getZ() - zCoord);
shieldBlocks.add(relc);
updateShieldBlock(camoId, cddata, damageBits, block, relc);
}
} else if (origBlock instanceof AbstractShieldBlock) {
shieldBlocks.remove(new RelCoordinate(c.getX() - xCoord, c.getY() - yCoord, c.getZ() - zCoord));
if (isShapedShield()) {
worldObj.setBlockToAir(x, y, z);
} else {
worldObj.setBlock(x, y, z, ShieldSetup.shieldTemplateBlock, templateMeta, 2);
}
} else {
Logging.message(player, EnumChatFormatting.YELLOW + "The selected shield can't do anything with this block!");
return;
}
markDirty();
notifyBlockUpdate();
}
Aggregations