use of net.minecraft.tileentity.TileEntity in project LogisticsPipes by RS485.
the class RenderTickHandler method renderWorldLast.
//private static final ResourceLocation TEXTURE = new ResourceLocation("logisticspipes", "textures/blocks/pipes/White.png");
@SubscribeEvent
public void renderWorldLast(RenderWorldLastEvent worldEvent) {
if (LogisticsRenderPipe.config.isUseNewRenderer()) {
if (displayPipeGhost()) {
Minecraft mc = Minecraft.getMinecraft();
EntityPlayer player = mc.thePlayer;
MovingObjectPosition box = mc.objectMouseOver;
if (box != null && box.typeOfHit == MovingObjectType.BLOCK) {
ItemStack stack = FMLClientHandler.instance().getClient().thePlayer.inventory.mainInventory[FMLClientHandler.instance().getClient().thePlayer.inventory.currentItem];
CoreUnroutedPipe pipe = ((ItemLogisticsPipe) stack.getItem()).getDummyPipe();
int i = box.blockX;
int j = box.blockY;
int k = box.blockZ;
World world = player.getEntityWorld();
int side = box.sideHit;
Block worldBlock = world.getBlock(i, j, k);
if (worldBlock == Blocks.snow) {
side = 1;
} else if (worldBlock != Blocks.vine && worldBlock != Blocks.tallgrass && worldBlock != Blocks.deadbush && (worldBlock == null || !worldBlock.isReplaceable(world, i, j, k))) {
if (side == 0) {
j--;
}
if (side == 1) {
j++;
}
if (side == 2) {
k--;
}
if (side == 3) {
k++;
}
if (side == 4) {
i--;
}
if (side == 5) {
i++;
}
}
double xCoord = i;
double yCoord = j;
double zCoord = k;
boolean isFreeSpace = true;
ITubeOrientation orientation = null;
if (pipe instanceof CoreMultiBlockPipe) {
CoreMultiBlockPipe multipipe = (CoreMultiBlockPipe) pipe;
DoubleCoordinates placeAt = new DoubleCoordinates(xCoord, yCoord, zCoord);
LPPositionSet<DoubleCoordinatesType<CoreMultiBlockPipe.SubBlockTypeForShare>> globalPos = new LPPositionSet<>(DoubleCoordinatesType.class);
globalPos.add(new DoubleCoordinatesType<>(placeAt, CoreMultiBlockPipe.SubBlockTypeForShare.NON_SHARE));
LPPositionSet<DoubleCoordinatesType<CoreMultiBlockPipe.SubBlockTypeForShare>> positions = multipipe.getSubBlocks();
orientation = multipipe.getTubeOrientation(player, (int) xCoord, (int) zCoord);
if (orientation != null) {
orientation.rotatePositions(positions);
positions.stream().map(pos -> pos.add(placeAt)).forEach(globalPos::add);
globalPos.addToAll(orientation.getOffset());
for (DoubleCoordinatesType<CoreMultiBlockPipe.SubBlockTypeForShare> pos : globalPos) {
if (!player.getEntityWorld().canPlaceEntityOnSide(LogisticsPipes.LogisticsPipeBlock, pos.getXInt(), pos.getYInt(), pos.getZInt(), false, side, player, stack)) {
TileEntity tile = player.getEntityWorld().getTileEntity(pos.getXInt(), pos.getYInt(), pos.getZInt());
boolean canPlace = false;
if (tile instanceof LogisticsTileGenericSubMultiBlock) {
if (CoreMultiBlockPipe.canShare(((LogisticsTileGenericSubMultiBlock) tile).getSubTypes(), pos.getType())) {
canPlace = true;
}
}
if (!canPlace) {
isFreeSpace = false;
break;
}
}
}
} else {
return;
}
} else {
if (!player.getEntityWorld().canPlaceEntityOnSide(LogisticsPipes.LogisticsPipeBlock, i, j, k, false, side, player, stack)) {
isFreeSpace = false;
}
}
if (isFreeSpace) {
GL11.glPushMatrix();
double x;
double y;
double z;
if (orientation != null) {
x = xCoord + orientation.getOffset().getXInt() - player.prevPosX - ((player.posX - player.prevPosX) * worldEvent.partialTicks);
y = yCoord + orientation.getOffset().getYInt() - player.prevPosY - ((player.posY - player.prevPosY) * worldEvent.partialTicks);
z = zCoord + orientation.getOffset().getZInt() - player.prevPosZ - ((player.posZ - player.prevPosZ) * worldEvent.partialTicks);
} else {
x = xCoord - player.prevPosX - ((player.posX - player.prevPosX) * worldEvent.partialTicks);
y = yCoord - player.prevPosY - ((player.posY - player.prevPosY) * worldEvent.partialTicks);
z = zCoord - player.prevPosZ - ((player.posZ - player.prevPosZ) * worldEvent.partialTicks);
}
GL11.glTranslated(x + 0.001, y + 0.001, z + 0.001);
GL11.glEnable(GL11.GL_BLEND);
//GL11.glDepthMask(false);
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
mc.renderEngine.bindTexture(new ResourceLocation("logisticspipes", "textures/blocks/pipes/White.png"));
Tessellator tess = Tessellator.instance;
CCRenderState.reset();
CCRenderState.useNormals = true;
CCRenderState.alphaOverride = 0xff;
GL11.glEnable(GL11.GL_TEXTURE_2D);
CCRenderState.alphaOverride = 0x50;
CCRenderState.useNormals = true;
CCRenderState.hasBrightness = false;
CCRenderState.startDrawing();
pipe.getHighlightRenderer().renderHighlight(orientation);
tess.draw();
CCRenderState.alphaOverride = 0xff;
GL11.glDisable(GL11.GL_BLEND);
GL11.glDepthMask(true);
GL11.glPopMatrix();
}
}
}
}
}
use of net.minecraft.tileentity.TileEntity in project LogisticsPipes by RS485.
the class SideConfigDisplay method doTileEntityRenderPass.
private void doTileEntityRenderPass(List<DoubleCoordinates> blocks, int pass) {
RenderPassHelper.setEntityRenderPass(pass);
for (DoubleCoordinates bc : blocks) {
TileEntity tile = world.getTileEntity(bc.getXInt(), bc.getYInt(), bc.getZInt());
if (tile != null) {
Vector3d at = new Vector3d(eye.x, eye.y, eye.z);
at.x += bc.getXDouble() - origin.x;
at.y += bc.getYDouble() - origin.y;
at.z += bc.getZDouble() - origin.z;
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
TileEntityRendererDispatcher.instance.renderTileEntityAt(tile, at.x, at.y, at.z, 0);
GL11.glPopAttrib();
}
}
RenderPassHelper.clearEntityRenderPass();
}
use of net.minecraft.tileentity.TileEntity in project LogisticsPipes by RS485.
the class SideConfigDisplay method updateSelection.
private void updateSelection(Vector3d start, Vector3d end) {
start.add(origin);
end.add(origin);
List<MovingObjectPosition> hits = new ArrayList<>();
LogisticsBlockGenericPipe.ignoreSideRayTrace = true;
for (DoubleCoordinates bc : configurables) {
Block block = world.getBlock(bc.getXInt(), bc.getYInt(), bc.getZInt());
if (block != null) {
if (block instanceof LogisticsBlockGenericPipe) {
cachedLPBlockTrace = LogisticsPipes.LogisticsPipeBlock.doRayTrace(world, bc.getXInt(), bc.getYInt(), bc.getZInt(), Vec3.createVectorHelper(start.x, start.y, start.z), Vec3.createVectorHelper(end.x, end.y, end.z));
} else {
cachedLPBlockTrace = null;
}
MovingObjectPosition hit = block.collisionRayTrace(world, bc.getXInt(), bc.getYInt(), bc.getZInt(), Vec3.createVectorHelper(start.x, start.y, start.z), Vec3.createVectorHelper(end.x, end.y, end.z));
if (hit != null) {
hits.add(hit);
}
}
}
LogisticsBlockGenericPipe.ignoreSideRayTrace = false;
selection = null;
MovingObjectPosition hit = getClosestHit(Vec3.createVectorHelper(start.x, start.y, start.z), hits);
if (hit != null) {
TileEntity te = world.getTileEntity(hit.blockX, hit.blockY, hit.blockZ);
if (te != null) {
ForgeDirection face = ForgeDirection.getOrientation(hit.sideHit);
selection = new SelectedFace(te, face, hit);
}
}
}
use of net.minecraft.tileentity.TileEntity in project LogisticsPipes by RS485.
the class PipeTransportLogistics method resolveUnroutedDestination.
public ForgeDirection resolveUnroutedDestination(LPTravelingItemServer data) {
List<ForgeDirection> dirs = new ArrayList<>(Arrays.asList(ForgeDirection.VALID_DIRECTIONS));
dirs.remove(data.input.getOpposite());
Iterator<ForgeDirection> iter = dirs.iterator();
while (iter.hasNext()) {
ForgeDirection dir = iter.next();
DoubleCoordinates pos = CoordinateUtils.add(getPipe().getLPPosition(), dir);
TileEntity tile = pos.getTileEntity(getWorld());
if (!SimpleServiceLocator.pipeInformationManager.isItemPipe(tile)) {
iter.remove();
} else if (!canPipeConnect(tile, dir)) {
iter.remove();
} else if (tile instanceof LogisticsTileGenericPipe && !((LogisticsTileGenericPipe) tile).canConnect(container, dir.getOpposite(), false)) {
iter.remove();
}
}
if (dirs.isEmpty()) {
return ForgeDirection.UNKNOWN;
}
int num = new Random().nextInt(dirs.size());
return dirs.get(num);
}
use of net.minecraft.tileentity.TileEntity in project LogisticsPipes by RS485.
the class TEControl method handleBlockUpdate.
public static void handleBlockUpdate(final World world, final LPWorldInfo info, int x, int y, int z) {
if (info.getWorldTick() < 5) {
return;
}
final DoubleCoordinates pos = new DoubleCoordinates(x, y, z);
if (info.getUpdateQueued().contains(pos)) {
return;
}
if (!pos.blockExists(world)) {
return;
}
final TileEntity tile = pos.getTileEntity(world);
if (SimpleServiceLocator.enderIOProxy.isBundledPipe(tile)) {
QueuedTasks.queueTask(() -> {
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
DoubleCoordinates newPos = CoordinateUtils.sum(pos, dir);
if (!newPos.blockExists(world)) {
continue;
}
TileEntity nextTile = newPos.getTileEntity(world);
if (nextTile instanceof LogisticsTileGenericPipe) {
((LogisticsTileGenericPipe) nextTile).scheduleNeighborChange();
}
}
return null;
});
}
if (tile == null || ((ILPTEInformation) tile).getObject() == null) {
return;
}
if (SimpleServiceLocator.pipeInformationManager.isItemPipe(tile) || SimpleServiceLocator.specialtileconnection.isType(tile)) {
info.getUpdateQueued().add(pos);
QueuedTasks.queueTask(() -> {
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
DoubleCoordinates newPos = CoordinateUtils.sum(pos, dir);
if (!newPos.blockExists(world)) {
continue;
}
TileEntity nextTile = newPos.getTileEntity(world);
if (nextTile != null && ((ILPTEInformation) nextTile).getObject() != null) {
for (ITileEntityChangeListener listener : new ArrayList<>(((ILPTEInformation) nextTile).getObject().changeListeners)) {
listener.pipeModified(pos);
}
}
}
for (ITileEntityChangeListener listener : new ArrayList<>(((ILPTEInformation) tile).getObject().changeListeners)) {
listener.pipeModified(pos);
}
info.getUpdateQueued().remove(pos);
return null;
});
}
}
Aggregations