use of net.minecraft.tileentity.TileEntity in project LogisticsPipes by RS485.
the class LogisticsBlockGenericSubMultiBlock method getPickBlock.
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) {
DoubleCoordinates pos = new DoubleCoordinates(x, y, z);
TileEntity tile = pos.getTileEntity(world);
if (tile instanceof LogisticsTileGenericSubMultiBlock) {
List<LogisticsTileGenericPipe> mainPipeList = ((LogisticsTileGenericSubMultiBlock) tile).getMainPipe();
for (LogisticsTileGenericPipe mainPipe : mainPipeList) {
if (mainPipe != null && mainPipe.pipe != null && mainPipe.pipe.isMultiBlock()) {
if (LogisticsPipes.LogisticsPipeBlock.doRayTrace(world, mainPipe.xCoord, mainPipe.yCoord, mainPipe.zCoord, Minecraft.getMinecraft().thePlayer) != null) {
return LogisticsPipes.LogisticsPipeBlock.getPickBlock(target, world, mainPipe.xCoord, mainPipe.yCoord, mainPipe.zCoord, player);
}
}
}
}
return super.getPickBlock(target, world, x, y, z, player);
}
use of net.minecraft.tileentity.TileEntity in project LogisticsPipes by RS485.
the class LogisticsBlockGenericPipe method collisionRayTrace.
@Override
public MovingObjectPosition collisionRayTrace(World world, int x, int y, int z, Vec3 origin, Vec3 direction) {
TileEntity tile = world.getTileEntity(x, y, z);
if (tile instanceof LogisticsTileGenericPipe && ((LogisticsTileGenericPipe) tile).pipe instanceof PipeBlockRequestTable) {
setBlockBoundsBasedOnState(world, x, y, z);
origin = origin.addVector((-x), (-y), (-z));
direction = direction.addVector((-x), (-y), (-z));
this.setBlockBounds(0, 0, 0, 1, 1, 1);
Vec3 vec32 = origin.getIntermediateWithXValue(direction, minX);
Vec3 vec33 = origin.getIntermediateWithXValue(direction, maxX);
Vec3 vec34 = origin.getIntermediateWithYValue(direction, minY);
Vec3 vec35 = origin.getIntermediateWithYValue(direction, maxY);
Vec3 vec36 = origin.getIntermediateWithZValue(direction, minZ);
Vec3 vec37 = origin.getIntermediateWithZValue(direction, maxZ);
if (!isVecInsideYZBounds(vec32)) {
vec32 = null;
}
if (!isVecInsideYZBounds(vec33)) {
vec33 = null;
}
if (!isVecInsideXZBounds(vec34)) {
vec34 = null;
}
if (!isVecInsideXZBounds(vec35)) {
vec35 = null;
}
if (!isVecInsideXYBounds(vec36)) {
vec36 = null;
}
if (!isVecInsideXYBounds(vec37)) {
vec37 = null;
}
Vec3 vec38 = null;
if (vec32 != null && (vec38 == null || origin.squareDistanceTo(vec32) < origin.squareDistanceTo(vec38))) {
vec38 = vec32;
}
if (vec33 != null && (vec38 == null || origin.squareDistanceTo(vec33) < origin.squareDistanceTo(vec38))) {
vec38 = vec33;
}
if (vec34 != null && (vec38 == null || origin.squareDistanceTo(vec34) < origin.squareDistanceTo(vec38))) {
vec38 = vec34;
}
if (vec35 != null && (vec38 == null || origin.squareDistanceTo(vec35) < origin.squareDistanceTo(vec38))) {
vec38 = vec35;
}
if (vec36 != null && (vec38 == null || origin.squareDistanceTo(vec36) < origin.squareDistanceTo(vec38))) {
vec38 = vec36;
}
if (vec37 != null && (vec38 == null || origin.squareDistanceTo(vec37) < origin.squareDistanceTo(vec38))) {
vec38 = vec37;
}
if (vec38 == null) {
return null;
} else {
byte b0 = -1;
if (vec38 == vec32) {
b0 = 4;
}
if (vec38 == vec33) {
b0 = 5;
}
if (vec38 == vec34) {
b0 = 0;
}
if (vec38 == vec35) {
b0 = 1;
}
if (vec38 == vec36) {
b0 = 2;
}
if (vec38 == vec37) {
b0 = 3;
}
return new MovingObjectPosition(x, y, z, b0, vec38.addVector(x, y, z));
}
}
RaytraceResult raytraceResult = doRayTrace(world, x, y, z, origin, direction);
if (raytraceResult == null) {
return null;
} else {
return raytraceResult.movingObjectPosition;
}
}
use of net.minecraft.tileentity.TileEntity in project LogisticsPipes by RS485.
the class LogisticsBlockGenericPipe method cacheTileToPreventRemoval.
private static void cacheTileToPreventRemoval(CoreUnroutedPipe pipe) {
final World worldCache = pipe.getWorld();
final int xCache = pipe.getX();
final int yCache = pipe.getY();
final int zCache = pipe.getZ();
final TileEntity tileCache = pipe.container;
final CoreUnroutedPipe fPipe = pipe;
fPipe.setPreventRemove(true);
QueuedTasks.queueTask(() -> {
if (!fPipe.preventRemove()) {
return null;
}
boolean changed = false;
if (worldCache.getBlock(xCache, yCache, zCache) != LogisticsPipes.LogisticsPipeBlock) {
worldCache.setBlock(xCache, yCache, zCache, LogisticsPipes.LogisticsPipeBlock);
changed = true;
}
if (worldCache.getTileEntity(xCache, yCache, zCache) != tileCache) {
worldCache.setTileEntity(xCache, yCache, zCache, tileCache);
changed = true;
}
if (changed) {
worldCache.notifyBlockChange(xCache, yCache, zCache, LogisticsPipes.LogisticsPipeBlock);
}
fPipe.setPreventRemove(false);
return null;
});
}
use of net.minecraft.tileentity.TileEntity in project LogisticsPipes by RS485.
the class PipeLogisticsChassi method isValidOrientation.
private boolean isValidOrientation(ForgeDirection connection) {
if (connection == ForgeDirection.UNKNOWN) {
return false;
}
if (getRouter().isRoutedExit(connection)) {
return false;
}
DoubleCoordinates pos = CoordinateUtils.add(new DoubleCoordinates(this), connection);
TileEntity tile = pos.getTileEntity(getWorld());
if (tile == null) {
return false;
}
if (SimpleServiceLocator.pipeInformationManager.isItemPipe(tile)) {
return false;
}
return MainProxy.checkPipesConnections(container, tile, connection);
}
use of net.minecraft.tileentity.TileEntity in project LogisticsPipes by RS485.
the class LogisticsTileGenericPipe method initialize.
public void initialize(CoreUnroutedPipe pipe) {
blockType = getBlockType();
if (pipe == null) {
LogisticsPipes.log.log(Level.WARN, "Pipe failed to initialize at {0},{1},{2}, deleting", xCoord, yCoord, zCoord);
worldObj.setBlockToAir(xCoord, yCoord, zCoord);
return;
}
this.pipe = pipe;
for (ForgeDirection o : ForgeDirection.VALID_DIRECTIONS) {
TileEntity tile = getTile(o);
if (tile instanceof LogisticsTileGenericPipe) {
((LogisticsTileGenericPipe) tile).scheduleNeighborChange();
}
SimpleServiceLocator.buildCraftProxy.notifyOfChange(this, tile, o);
}
bindPipe();
computeConnections();
scheduleRenderUpdate();
if (pipe.needsInit()) {
pipe.initialize();
}
initialized = true;
}
Aggregations