Added IC2 Teleporter support when target is inside ship
This commit is contained in:
parent
5e7c0cc300
commit
03d5da0928
3 changed files with 48 additions and 3 deletions
|
@ -13,6 +13,10 @@ public interface ITransformation {
|
|||
|
||||
float getRotationYaw();
|
||||
|
||||
boolean isInside(final double x, final double y, final double z);
|
||||
|
||||
boolean isInside(final int x, final int y, final int z);
|
||||
|
||||
Vec3 apply(final double sourceX, final double sourceY, final double sourceZ);
|
||||
|
||||
ChunkCoordinates apply(final int sourceX, final int sourceY, final int sourceZ);
|
||||
|
|
|
@ -8,6 +8,7 @@ import net.minecraft.block.Block;
|
|||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class CompatIndustrialCraft2 implements IBlockTransformer {
|
||||
|
@ -45,9 +46,23 @@ public class CompatIndustrialCraft2 implements IBlockTransformer {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int rotate(final Block block, final int metadata, NBTTagCompound nbtTileEntity, final ITransformation transformation) {
|
||||
byte rotationSteps = transformation.getRotationSteps();
|
||||
if (rotationSteps == 0 || !nbtTileEntity.hasKey("facing")) {
|
||||
public int rotate(final Block block, final int metadata, final NBTTagCompound nbtTileEntity, final ITransformation transformation) {
|
||||
final byte rotationSteps = transformation.getRotationSteps();
|
||||
|
||||
if (nbtTileEntity.getBoolean("targetSet")) {
|
||||
final int targetX = nbtTileEntity.getInteger("targetX");
|
||||
final int targetY = nbtTileEntity.getInteger("targetY");
|
||||
final int targetZ = nbtTileEntity.getInteger("targetZ");
|
||||
if (transformation.isInside(targetX, targetY, targetZ)) {
|
||||
final ChunkCoordinates chunkCoordinates = transformation.apply(targetX, targetY, targetZ);
|
||||
nbtTileEntity.setInteger("targetX", chunkCoordinates.posX);
|
||||
nbtTileEntity.setInteger("targetY", chunkCoordinates.posY);
|
||||
nbtTileEntity.setInteger("targetZ", chunkCoordinates.posZ);
|
||||
}
|
||||
}
|
||||
|
||||
if ( rotationSteps == 0
|
||||
|| !nbtTileEntity.hasKey("facing")) {
|
||||
return metadata;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,9 +14,21 @@ public class Transformation implements ITransformation {
|
|||
private final VectorI move;
|
||||
private final byte rotationSteps;
|
||||
private final World targetWorld;
|
||||
private final int minX;
|
||||
private final int minY;
|
||||
private final int minZ;
|
||||
private final int maxX;
|
||||
private final int maxY;
|
||||
private final int maxZ;
|
||||
|
||||
public Transformation(JumpShip ship, World targetWorld, int moveX, int moveY, int moveZ, byte rotationSteps) {
|
||||
sourceCore = new VectorI(ship.coreX, ship.coreY, ship.coreZ);
|
||||
minX = ship.minX;
|
||||
minY = ship.minY;
|
||||
minZ = ship.minZ;
|
||||
maxX = ship.maxX;
|
||||
maxY = ship.maxY;
|
||||
maxZ = ship.maxZ;
|
||||
this.targetWorld = targetWorld;
|
||||
move = new VectorI(moveX, moveY, moveZ);
|
||||
targetCore = sourceCore.add(move);
|
||||
|
@ -38,6 +50,20 @@ public class Transformation implements ITransformation {
|
|||
return 90.0F * rotationSteps;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInside(final double x, final double y, final double z) {
|
||||
return minX <= x && x <= maxX + 1.0D
|
||||
&& minY <= y && y <= maxY + 1.0D
|
||||
&& minZ <= z && z <= maxZ + 1.0D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInside(final int x, final int y, final int z) {
|
||||
return minX <= x && x <= maxX
|
||||
&& minY <= y && y <= maxY
|
||||
&& minZ <= z && z <= maxZ;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3 apply(final double sourceX, final double sourceY, final double sourceZ) {
|
||||
if (rotationSteps == 0) {
|
||||
|
|
Loading…
Add table
Reference in a new issue