use of logisticspipes.items.ItemLogisticsPipe 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.items.ItemLogisticsPipe in project LogisticsPipes by RS485.
the class LogisticsNewPipeItemRenderer method renderPipeItem.
private void renderPipeItem(RenderBlocks render, ItemStack item, float translateX, float translateY, float translateZ) {
GL11.glPushMatrix();
// don't break other mods' guis when holding a pipe
GL11.glPushAttrib(GL11.GL_COLOR_BUFFER_BIT);
// force transparency
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glEnable(GL11.GL_BLEND);
// GL11.glBindTexture(GL11.GL_TEXTURE_2D, 10);
Tessellator tessellator = Tessellator.instance;
GL11.glTranslatef(translateX, translateY, translateZ);
Block block = LogisticsPipes.LogisticsPipeBlock;
if (item.getItem() instanceof ItemLogisticsPipe) {
ItemLogisticsPipe lItem = (ItemLogisticsPipe) item.getItem();
int renderList = lItem.getNewPipeRenderList();
if (renderList == -1) {
lItem.setNewPipeRenderList(GL11.glGenLists(1));
renderList = lItem.getNewPipeRenderList();
GL11.glNewList(renderList, GL11.GL_COMPILE);
tessellator.startDrawingQuads();
generatePipeRenderList(lItem.getNewPipeIconIndex());
tessellator.draw();
GL11.glEndList();
}
GL11.glCallList(renderList);
}
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
GL11.glPopAttrib();
GL11.glPopMatrix();
}
use of logisticspipes.items.ItemLogisticsPipe 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 logisticspipes.items.ItemLogisticsPipe in project LogisticsPipes by RS485.
the class LogisticsBlockGenericPipe method registerPipe.
/* Registration ******************************************************** */
public static ItemLogisticsPipe registerPipe(Class<? extends CoreUnroutedPipe> clas) {
ItemLogisticsPipe item = new ItemLogisticsPipe();
item.setUnlocalizedName(clas.getSimpleName());
GameRegistry.registerItem(item, item.getUnlocalizedName());
LogisticsBlockGenericPipe.pipes.put(item, clas);
CoreUnroutedPipe dummyPipe = LogisticsBlockGenericPipe.createPipe(item);
if (dummyPipe != null) {
item.setPipeIconIndex(dummyPipe.getIconIndexForItem(), dummyPipe.getTextureIndex());
MainProxy.proxy.setIconProviderFromPipe(item, dummyPipe);
item.setDummyPipe(dummyPipe);
}
return item;
}
use of logisticspipes.items.ItemLogisticsPipe in project LogisticsPipes by RS485.
the class LogisticsBlockGenericPipe method onBlockActivated.
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float xOffset, float yOffset, float zOffset) {
super.onBlockActivated(world, x, y, z, player, side, xOffset, yOffset, zOffset);
world.notifyBlocksOfNeighborChange(x, y, z, LogisticsPipes.LogisticsPipeBlock);
CoreUnroutedPipe pipe = LogisticsBlockGenericPipe.getPipe(world, x, y, z);
if (LogisticsBlockGenericPipe.isValid(pipe)) {
ItemStack currentItem = player.getCurrentEquippedItem();
if (currentItem == null) {
// Fall through the end of the test
} else if (currentItem.getItem() == Items.sign) {
// Sign will be placed anyway, so lets show the sign gui
return false;
} else if (currentItem.getItem() instanceof ItemLogisticsPipe) {
return false;
} else if (SimpleServiceLocator.toolWrenchHandler.isWrench(currentItem.getItem())) {
// interface callbacks for the individual pipe/logic calls
return pipe.blockActivated(player);
}
if (pipe.canHoldBCParts()) {
IBCClickResult result = SimpleServiceLocator.buildCraftProxy.handleBCClickOnPipe(world, x, y, z, player, side, xOffset, yOffset, zOffset, pipe);
if (result.handled()) {
return true;
}
if (result.blocked()) {
return false;
}
}
return pipe.blockActivated(player);
}
return false;
}
Aggregations