use of logisticspipes.pipes.basic.CoreUnroutedPipe in project LogisticsPipes by RS485.
the class LogisticsPipes method createPipe.
protected Item createPipe(Class<? extends CoreUnroutedPipe> clas, String descr, Side side) {
final ItemLogisticsPipe res = LogisticsBlockGenericPipe.registerPipe(clas);
res.setCreativeTab(LogisticsPipes.LPCreativeTab);
res.setUnlocalizedName(clas.getSimpleName());
final CoreUnroutedPipe pipe = LogisticsBlockGenericPipe.createPipe(res);
if (pipe instanceof CoreRoutedPipe) {
postInitRun.add(() -> res.setPipeIconIndex(((CoreRoutedPipe) pipe).getTextureType(ForgeDirection.UNKNOWN).normal, ((CoreRoutedPipe) pipe).getTextureType(ForgeDirection.UNKNOWN).newTexture));
}
if (side.isClient()) {
if (pipe instanceof PipeBlockRequestTable) {
MinecraftForgeClient.registerItemRenderer(res, new LogisticsPipeItemRenderer(true));
} else {
MinecraftForgeClient.registerItemRenderer(res, MainProxy.proxy.getPipeItemRenderer());
}
}
if (clas != PipeItemsBasicLogistics.class && CoreRoutedPipe.class.isAssignableFrom(clas)) {
if (clas != PipeFluidBasic.class && PipeFluidBasic.class.isAssignableFrom(clas)) {
registerShapelessResetRecipe(res, 0, LogisticsPipes.LogisticsFluidBasicPipe, 0);
} else {
registerShapelessResetRecipe(res, 0, LogisticsPipes.LogisticsBasicPipe, 0);
}
}
return res;
}
use of logisticspipes.pipes.basic.CoreUnroutedPipe in project LogisticsPipes by RS485.
the class RemoteOrderer method getPipe.
public static PipeItemsRemoteOrdererLogistics getPipe(@Nonnull ItemStack stack) {
if (stack.isEmpty() || !stack.hasTagCompound()) {
return null;
}
final NBTTagCompound tag = Objects.requireNonNull(stack.getTagCompound());
if (!tag.hasKey("connectedPipe-x") || !tag.hasKey("connectedPipe-y") || !tag.hasKey("connectedPipe-z")) {
return null;
}
if (!tag.hasKey("connectedPipe-world-dim")) {
return null;
}
int dim = tag.getInteger("connectedPipe-world-dim");
World world = DimensionManager.getWorld(dim);
if (world == null) {
return null;
}
TileEntity tile = world.getTileEntity(new BlockPos(tag.getInteger("connectedPipe-x"), tag.getInteger("connectedPipe-y"), tag.getInteger("connectedPipe-z")));
if (!(tile instanceof LogisticsTileGenericPipe)) {
return null;
}
CoreUnroutedPipe pipe = ((LogisticsTileGenericPipe) tile).pipe;
if (pipe instanceof PipeItemsRemoteOrdererLogistics) {
return (PipeItemsRemoteOrdererLogistics) pipe;
}
return null;
}
use of logisticspipes.pipes.basic.CoreUnroutedPipe in project LogisticsPipes by RS485.
the class ItemModule method onItemUse.
@Override
@Nonnull
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
if (MainProxy.isServer(player.world)) {
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof LogisticsTileGenericPipe) {
if (player.getDisplayName().getUnformattedText().equals("ComputerCraft")) {
// Allow turtle to place modules in pipes.
CoreUnroutedPipe pipe = LogisticsBlockGenericPipe.getPipe(world, pos);
if (LogisticsBlockGenericPipe.isValid(pipe)) {
pipe.blockActivated(player);
}
}
return EnumActionResult.PASS;
}
openConfigGui(player.inventory.getCurrentItem(), player, world);
}
return EnumActionResult.PASS;
}
use of logisticspipes.pipes.basic.CoreUnroutedPipe 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.CoreUnroutedPipe in project LogisticsPipes by RS485.
the class LogisticsPipes method registerPipe.
protected void registerPipe(IForgeRegistry<Item> registry, String name, Function<Item, ? extends CoreUnroutedPipe> constructor) {
final ItemLogisticsPipe res = LogisticsBlockGenericPipe.registerPipe(registry, name, constructor);
final CoreUnroutedPipe pipe = Objects.requireNonNull(LogisticsBlockGenericPipe.createPipe(res), "created a null pipe from " + res.toString());
if (pipe instanceof CoreRoutedPipe) {
postInitRun.add(() -> res.setPipeIconIndex(((CoreRoutedPipe) pipe).getTextureType(null).normal, ((CoreRoutedPipe) pipe).getTextureType(null).newTexture));
}
if (pipe.getClass() != PipeItemsBasicLogistics.class && CoreRoutedPipe.class.isAssignableFrom(pipe.getClass())) {
if (pipe.getClass() != PipeFluidBasic.class && PipeFluidBasic.class.isAssignableFrom(pipe.getClass())) {
resetRecipeList.add(() -> new Pair<>(res, LPItems.pipeFluidBasic));
} else if (pipe.getClass() != PipeBlockRequestTable.class) {
resetRecipeList.add(() -> new Pair<>(res, LPItems.pipeBasic));
}
}
}
Aggregations