use of logisticspipes.pipes.basic.CoreMultiBlockPipe in project LogisticsPipes by RS485.
the class PipeMultiBlockTransportLogistics method handleTileReachedServer.
@Override
protected void handleTileReachedServer(LPTravelingItemServer arrivingItem, TileEntity tile, ForgeDirection dir) {
markChunkModified(tile);
if (tile instanceof LogisticsTileGenericPipe && ((LogisticsTileGenericPipe) tile).pipe instanceof CoreMultiBlockPipe) {
passToNextPipe(arrivingItem, tile);
return;
} else if (tile instanceof LogisticsTileGenericSubMultiBlock) {
List<LogisticsTileGenericPipe> masterTile = ((LogisticsTileGenericSubMultiBlock) tile).getMainPipe();
if (!masterTile.isEmpty()) {
if (masterTile.size() > 1) {
throw new UnsupportedOperationException();
}
passToNextPipe(arrivingItem, masterTile.get(0));
return;
}
}
Explosion explosion = new Explosion(this.getWorld(), null, this.getPipe().getX(), this.getPipe().getY(), this.getPipe().getZ(), 4.0F);
explosion.isFlaming = false;
explosion.isSmoking = true;
explosion.doExplosionB(true);
}
use of logisticspipes.pipes.basic.CoreMultiBlockPipe in project LogisticsPipes by RS485.
the class RenderTickHandler method renderWorldLast.
// private static final ResourceLocation TEXTURE = new ResourceLocation("logisticspipes", "textures/blocks/pipes/White.png");
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void renderWorldLast(RenderWorldLastEvent worldEvent) {
// if (LogisticsRenderPipe.config.isUseNewRenderer()) {
if (displayPipeGhost()) {
Minecraft mc = Minecraft.getMinecraft();
EntityPlayer player = mc.player;
RayTraceResult box = mc.objectMouseOver;
if (box != null && box.typeOfHit == RayTraceResult.Type.BLOCK) {
ItemStack stack = FMLClientHandler.instance().getClient().player.inventory.mainInventory.get(FMLClientHandler.instance().getClient().player.inventory.currentItem);
CoreUnroutedPipe pipe = ((ItemLogisticsPipe) stack.getItem()).getDummyPipe();
World world = player.getEntityWorld();
EnumFacing side = box.sideHit;
BlockPos bPos = box.getBlockPos();
Block block = world.getBlockState(bPos).getBlock();
if (block == Blocks.SNOW_LAYER && block.isReplaceable(world, bPos)) {
side = EnumFacing.UP;
} else if (!block.isReplaceable(world, bPos)) {
bPos = bPos.offset(side);
}
boolean isFreeSpace = true;
ITubeOrientation orientation = null;
if (pipe instanceof CoreMultiBlockPipe) {
CoreMultiBlockPipe multipipe = (CoreMultiBlockPipe) pipe;
DoubleCoordinates placeAt = new DoubleCoordinates(bPos);
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, bPos.getX(), bPos.getZ());
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().mayPlace(LPBlocks.pipe, pos.getBlockPos(), false, side, player)) {
TileEntity tile = player.getEntityWorld().getTileEntity(pos.getBlockPos());
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().mayPlace(LPBlocks.pipe, bPos, false, side, player)) {
isFreeSpace = false;
}
}
if (isFreeSpace) {
GlStateManager.pushMatrix();
double x;
double y;
double z;
if (orientation != null) {
x = bPos.getX() + orientation.getOffset().getXInt() - player.prevPosX - ((player.posX - player.prevPosX) * worldEvent.getPartialTicks());
y = bPos.getY() + orientation.getOffset().getYInt() - player.prevPosY - ((player.posY - player.prevPosY) * worldEvent.getPartialTicks());
z = bPos.getZ() + orientation.getOffset().getZInt() - player.prevPosZ - ((player.posZ - player.prevPosZ) * worldEvent.getPartialTicks());
} else {
x = bPos.getX() - player.prevPosX - ((player.posX - player.prevPosX) * worldEvent.getPartialTicks());
y = bPos.getY() - player.prevPosY - ((player.posY - player.prevPosY) * worldEvent.getPartialTicks());
z = bPos.getZ() - player.prevPosZ - ((player.posZ - player.prevPosZ) * worldEvent.getPartialTicks());
}
GL11.glTranslated(x + 0.001, y + 0.001, z + 0.001);
GlStateManager.enableBlend();
// GL11.glDepthMask(false);
GlStateManager.disableTexture2D();
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
mc.renderEngine.bindTexture(new ResourceLocation("logisticspipes", "textures/blocks/pipes/white.png"));
SimpleServiceLocator.cclProxy.getRenderState().reset();
SimpleServiceLocator.cclProxy.getRenderState().setAlphaOverride(0xff);
GlStateManager.enableTexture2D();
SimpleServiceLocator.cclProxy.getRenderState().setAlphaOverride(0x50);
SimpleServiceLocator.cclProxy.getRenderState().startDrawing(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
pipe.getHighlightRenderer().renderHighlight(orientation);
SimpleServiceLocator.cclProxy.getRenderState().draw();
SimpleServiceLocator.cclProxy.getRenderState().setAlphaOverride(0xff);
GlStateManager.disableBlend();
GlStateManager.depthMask(true);
GlStateManager.popMatrix();
}
}
}
// }
}
use of logisticspipes.pipes.basic.CoreMultiBlockPipe in project LogisticsPipes by RS485.
the class PipeMultiBlockTransportLogistics method handleTileReachedServer.
@Override
protected void handleTileReachedServer(LPTravelingItemServer arrivingItem, TileEntity tile, EnumFacing dir) {
markChunkModified(tile);
if (tile instanceof LogisticsTileGenericPipe && ((LogisticsTileGenericPipe) tile).pipe instanceof CoreMultiBlockPipe) {
passToNextPipe(arrivingItem, tile);
return;
} else if (tile instanceof LogisticsTileGenericSubMultiBlock) {
List<LogisticsTileGenericPipe> masterTile = ((LogisticsTileGenericSubMultiBlock) tile).getMainPipe();
if (!masterTile.isEmpty()) {
if (masterTile.size() > 1) {
throw new UnsupportedOperationException();
}
passToNextPipe(arrivingItem, masterTile.get(0));
return;
}
}
Explosion explosion = new Explosion(this.getWorld(), null, this.getPipe().getX(), this.getPipe().getY(), this.getPipe().getZ(), 4.0F, false, true);
explosion.doExplosionB(true);
}
use of logisticspipes.pipes.basic.CoreMultiBlockPipe in project LogisticsPipes by RS485.
the class PipeMultiBlockTransportLogistics method handleTileReachedClient.
@Override
protected void handleTileReachedClient(LPTravelingItemClient arrivingItem, TileEntity tile, ForgeDirection dir) {
if (tile instanceof LogisticsTileGenericPipe && ((LogisticsTileGenericPipe) tile).pipe instanceof CoreMultiBlockPipe) {
passToNextPipe(arrivingItem, tile);
return;
} else if (tile instanceof LogisticsTileGenericSubMultiBlock) {
List<LogisticsTileGenericPipe> masterTile = ((LogisticsTileGenericSubMultiBlock) tile).getMainPipe();
if (!masterTile.isEmpty()) {
if (masterTile.size() > 1) {
throw new UnsupportedOperationException();
}
passToNextPipe(arrivingItem, masterTile.get(0));
return;
}
}
Explosion explosion = new Explosion(this.getWorld(), null, this.getPipe().getX(), this.getPipe().getY(), this.getPipe().getZ(), 4.0F);
explosion.isFlaming = false;
explosion.isSmoking = true;
explosion.doExplosionB(true);
}
use of logisticspipes.pipes.basic.CoreMultiBlockPipe in project LogisticsPipes by RS485.
the class ItemLogisticsPipe method onItemUse.
@Override
public //TODO use own pipe handling
boolean onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int x, int y, int z, int sideI, float par8, float par9, float par10) {
int side = sideI;
Block block = LogisticsPipes.LogisticsPipeBlock;
int i = x;
int j = y;
int k = z;
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++;
}
}
if (itemstack.stackSize == 0) {
return false;
}
if (!dummyPipe.isMultiBlock()) {
if (world.canPlaceEntityOnSide(block, i, j, k, false, side, entityplayer, itemstack)) {
CoreUnroutedPipe pipe = LogisticsBlockGenericPipe.createPipe(this);
if (pipe == null) {
LogisticsPipes.log.log(Level.WARN, "Pipe failed to create during placement at {0},{1},{2}", new Object[] { i, j, k });
return true;
}
if (LogisticsBlockGenericPipe.placePipe(pipe, world, i, j, k, block, 0)) {
block.onBlockPlacedBy(world, i, j, k, entityplayer, itemstack);
itemstack.stackSize--;
}
return true;
} else {
return false;
}
} else {
CoreMultiBlockPipe multiPipe = (CoreMultiBlockPipe) dummyPipe;
boolean isFreeSpace = true;
DoubleCoordinates placeAt = new DoubleCoordinates(i, j, k);
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();
ITubeOrientation orientation = multiPipe.getTubeOrientation(entityplayer, i, k);
if (orientation == null) {
return false;
}
orientation.rotatePositions(positions);
positions.stream().map(pos -> pos.add(placeAt)).forEach(globalPos::add);
globalPos.addToAll(orientation.getOffset());
placeAt.add(orientation.getOffset());
for (DoubleCoordinatesType<CoreMultiBlockPipe.SubBlockTypeForShare> pos : globalPos) {
if (!world.canPlaceEntityOnSide(block, pos.getXInt(), pos.getYInt(), pos.getZInt(), false, side, entityplayer, itemstack)) {
TileEntity tile = world.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;
}
}
}
if (isFreeSpace) {
CoreUnroutedPipe pipe = LogisticsBlockGenericPipe.createPipe(this);
if (pipe == null) {
LogisticsPipes.log.log(Level.WARN, "Pipe failed to create during placement at {0},{1},{2}", new Object[] { i, j, k });
return true;
}
if (LogisticsBlockGenericPipe.placePipe(pipe, world, placeAt.getXInt(), placeAt.getYInt(), placeAt.getZInt(), block, 0, orientation)) {
//TODO
block.onBlockPlacedBy(world, i, j, k, entityplayer, itemstack);
itemstack.stackSize--;
}
return true;
} else {
return false;
}
}
}
Aggregations