Search in sources :

Example 16 with PipeBlockRequestTable

use of logisticspipes.pipes.PipeBlockRequestTable in project LogisticsPipes by RS485.

the class LogisticsBlockGenericPipe method addCollisionBoxToList.

@Override
public void addCollisionBoxToList(IBlockState state, World world, @Nonnull BlockPos pos, @Nonnull AxisAlignedBB entityBox, @Nonnull List<AxisAlignedBB> collidingBoxes, @Nullable Entity entity, boolean isActualState) {
    TileEntity te = world.getTileEntity(pos);
    if (te instanceof LogisticsTileGenericPipe) {
        LogisticsTileGenericPipe tile = (LogisticsTileGenericPipe) te;
        CoreUnroutedPipe pipe = tile.pipe;
        if (pipe instanceof PipeBlockRequestTable) {
            addCollisionBoxToList(pos, entityBox, collidingBoxes, Block.FULL_BLOCK_AABB);
            return;
        }
        if (pipe != null && pipe.isMultiBlock()) {
            ((CoreMultiBlockPipe) pipe).addCollisionBoxesToList(collidingBoxes, entityBox);
            if (!pipe.actAsNormalPipe())
                return;
        }
        Arrays.stream(EnumFacing.VALUES).filter(tile::isPipeConnectedCached).map(f -> PIPE_CONN_BB.get(f.getIndex())).forEach(bb -> addCollisionBoxToList(pos, entityBox, collidingBoxes, bb));
    }
    addCollisionBoxToList(pos, entityBox, collidingBoxes, PIPE_CENTER_BB);
    mcmpBlockAccess.addCollisionBoxToList(state, world, pos, entityBox, collidingBoxes, entity, isActualState);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) Arrays(java.util.Arrays) IStringSerializable(net.minecraft.util.IStringSerializable) Item(net.minecraft.item.Item) LogisticsPipes(logisticspipes.LogisticsPipes) EnumHand(net.minecraft.util.EnumHand) PIPE_MAX_POS(logisticspipes.LPConstants.PIPE_MAX_POS) Random(java.util.Random) BlockStateContainer(net.minecraft.block.state.BlockStateContainer) MainProxy(logisticspipes.proxy.MainProxy) Configs(logisticspipes.config.Configs) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) Block(net.minecraft.block.Block) Vec3d(net.minecraft.util.math.Vec3d) Side(net.minecraftforge.fml.relauncher.Side) ClientConfiguration(network.rs485.logisticspipes.config.ClientConfiguration) Map(java.util.Map) PipeBlockRequestTable(logisticspipes.pipes.PipeBlockRequestTable) NonNullList(net.minecraft.util.NonNullList) BlockFaceShape(net.minecraft.block.state.BlockFaceShape) PropertyBool(net.minecraft.block.properties.PropertyBool) BlockAccessDelegate(network.rs485.logisticspipes.proxy.mcmp.BlockAccessDelegate) Collectors(java.util.stream.Collectors) IForgeRegistry(net.minecraftforge.registries.IForgeRegistry) LPPositionSet(logisticspipes.utils.LPPositionSet) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates) Objects(java.util.Objects) PropertyEnum(net.minecraft.block.properties.PropertyEnum) List(java.util.List) Stream(java.util.stream.Stream) EntityPlayer(net.minecraft.entity.player.EntityPlayer) PropertyCache(logisticspipes.renderer.newpipe.PropertyCache) EnumParticleTypes(net.minecraft.util.EnumParticleTypes) EnumBlockRenderType(net.minecraft.util.EnumBlockRenderType) ItemLogisticsPipe(logisticspipes.items.ItemLogisticsPipe) LogisticsNewRenderPipe(logisticspipes.renderer.newpipe.LogisticsNewRenderPipe) DoubleCoordinatesType(network.rs485.logisticspipes.world.DoubleCoordinatesType) IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState) AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) HashMap(java.util.HashMap) LPMicroblockBlock(logisticspipes.pipes.basic.ltgpmodcompat.LPMicroblockBlock) Function(java.util.function.Function) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack) RayTraceResult(net.minecraft.util.math.RayTraceResult) Minecraft(net.minecraft.client.Minecraft) QueuedTasks(logisticspipes.ticks.QueuedTasks) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) Nonnull(javax.annotation.Nonnull) PIPE_MIN_POS(logisticspipes.LPConstants.PIPE_MIN_POS) Nullable(javax.annotation.Nullable) IBlockAccess(net.minecraft.world.IBlockAccess) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) Entity(net.minecraft.entity.Entity) Items(net.minecraft.init.Items) World(net.minecraft.world.World) ITubeOrientation(logisticspipes.interfaces.ITubeOrientation) PropertyInteger(net.minecraft.block.properties.PropertyInteger) EnumFacing(net.minecraft.util.EnumFacing) BlockPos(net.minecraft.util.math.BlockPos) BlockRenderLayer(net.minecraft.util.BlockRenderLayer) IBlockState(net.minecraft.block.state.IBlockState) IRotationProvider(logisticspipes.interfaces.IRotationProvider) ParticleManager(net.minecraft.client.particle.ParticleManager) LPBlocks(logisticspipes.LPBlocks) Material(net.minecraft.block.material.Material) EntityLivingBase(net.minecraft.entity.EntityLivingBase) Data(lombok.Data) PropertyRenderList(logisticspipes.renderer.newpipe.PropertyRenderList) TileEntity(net.minecraft.tileentity.TileEntity) Particle(net.minecraft.client.particle.Particle) Comparator(java.util.Comparator) AllArgsConstructor(lombok.AllArgsConstructor) PipeBlockRequestTable(logisticspipes.pipes.PipeBlockRequestTable)

Example 17 with PipeBlockRequestTable

use of logisticspipes.pipes.PipeBlockRequestTable in project LogisticsPipes by RS485.

the class LogisticsNewRenderPipe method renderTileEntityAt.

public void renderTileEntityAt(LogisticsTileGenericPipe pipeTile, double x, double y, double z, float partialTickTime, double distance) {
    boolean inHand = false;
    if (pipeTile == null) {
    }
    if (pipeTile.pipe instanceof PipeBlockRequestTable) {
        return;
    }
    if (pipeTile.pipe == null) {
        return;
    }
    PipeRenderState renderState = pipeTile.renderState;
    if (renderState.renderLists != null && renderState.renderLists.values().stream().anyMatch(GLRenderList::isInvalid)) {
        renderState.renderLists = null;
    }
    if (renderState.renderLists == null) {
        renderState.renderLists = new HashMap<>();
    }
    if (distance > config.getRenderPipeDistance() * config.getRenderPipeDistance()) {
    /*if (config.isUseFallbackRenderer()) {
				renderState.forceRenderOldPipe = true;
			}*/
    } else {
        renderState.forceRenderOldPipe = false;
        boolean recalculateList = checkAndCalculateRenderCache(pipeTile);
        renderList(x, y, z, renderState.renderLists, renderState.cachedRenderer, recalculateList);
        if (recalculateList) {
            pipeTile.getWorld().markBlockRangeForRenderUpdate(pipeTile.getPos(), pipeTile.getPos());
        }
    }
}
Also used : PipeRenderState(logisticspipes.renderer.state.PipeRenderState) PipeBlockRequestTable(logisticspipes.pipes.PipeBlockRequestTable)

Example 18 with PipeBlockRequestTable

use of logisticspipes.pipes.PipeBlockRequestTable in project LogisticsPipes by RS485.

the class LogisticsNewPipeModel method generatePipeRenderList.

private List<RenderEntry> generatePipeRenderList() {
    ArrayList<RenderEntry> objectsToRender = new ArrayList<>();
    if (getPipe() == null) {
        System.out.println("'" + key + "' does not result in pipe");
    } else if (getPipe() instanceof PipeBlockRequestTable) {
        TextureTransformation icon = SimpleServiceLocator.cclProxy.createIconTransformer((TextureAtlasSprite) Textures.LOGISTICS_REQUEST_TABLE_NEW);
        LogisticsNewSolidBlockWorldRenderer.BlockRotation rotation = LogisticsNewSolidBlockWorldRenderer.BlockRotation.ZERO;
        // Draw
        objectsToRender.add(new RenderEntry(LogisticsNewSolidBlockWorldRenderer.block.get(rotation), icon));
        for (LogisticsNewSolidBlockWorldRenderer.CoverSides side : LogisticsNewSolidBlockWorldRenderer.CoverSides.values()) {
            objectsToRender.add(new RenderEntry(LogisticsNewSolidBlockWorldRenderer.texturePlate_Outer.get(side).get(rotation), icon));
        }
    } else if (getPipe().getSpecialRenderer() != null) {
        getPipe().getSpecialRenderer().renderToList(null, objectsToRender);
        AxisAlignedBB[] bb = new AxisAlignedBB[1];
        bb[0] = new AxisAlignedBB(0.5, 0.5, 0.5, 0.5, 0.5, 0.5);
        objectsToRender.forEach(it -> bb[0] = bb[0].union(it.getModel().bounds().toAABB()));
        double size = Math.max(Math.max(bb[0].maxX - bb[0].minX, bb[0].maxY - bb[0].minY), bb[0].maxZ - bb[0].minZ);
        objectsToRender.replaceAll(it -> {
            RenderEntry content = it.clone(new I3DOperation[] { new LPUVTransformationList(BASE_TEXTURE_TRANSFORM) });
            content.getModel().apply(new LPScale(0.95 / size));
            return content;
        });
        bb[0] = new AxisAlignedBB(0.5, 0.5, 0.5, 0.5, 0.5, 0.5);
        objectsToRender.forEach(it -> bb[0] = bb[0].union(it.getModel().bounds().toAABB()));
        objectsToRender.forEach(it -> it.getModel().apply(new LPTranslation(0.5 - (bb[0].maxX + bb[0].minX) / 2, 0.5 - (bb[0].maxY + bb[0].minY) / 2, 0.5 - (bb[0].maxZ + bb[0].minZ) / 2)));
    } else {
        if (getPipe() instanceof CoreRoutedPipe) {
            int red = 0;
            boolean toggle = Math.random() < 0.5;
            for (LogisticsNewRenderPipe.Corner corner : LogisticsNewRenderPipe.Corner.values()) {
                final int fred = red;
                final boolean ftoggle = toggle;
                LogisticsNewRenderPipe.corners_M.get(corner).stream().map(model -> new RenderEntry(model, ftoggle && (fred % 4 == 0 || fred % 4 == 3) || !ftoggle && (fred % 4 == 1 || fred % 4 == 2) ? LogisticsNewRenderPipe.inactiveTexture : LogisticsNewRenderPipe.basicPipeTexture)).forEach(objectsToRender::add);
                red++;
                if (red > 3) {
                    red -= 4;
                    toggle = !toggle;
                }
            }
        } else {
            Arrays.stream(LogisticsNewRenderPipe.Corner.values()).flatMap(corner -> LogisticsNewRenderPipe.corners_M.get(corner).stream().map(model -> new RenderEntry(model, LogisticsNewRenderPipe.basicPipeTexture))).forEach(objectsToRender::add);
        }
        for (LogisticsNewRenderPipe.Edge edge : LogisticsNewRenderPipe.Edge.values()) {
            objectsToRender.add(new RenderEntry(LogisticsNewRenderPipe.edges.get(edge), LogisticsNewRenderPipe.basicPipeTexture));
        }
        // ArrayList<Pair<CCModel, IconTransformation>> objectsToRender2 = new ArrayList<Pair<CCModel, IconTransformation>>();
        for (EnumFacing dir : EnumFacing.VALUES) {
            for (IModel3D model : LogisticsNewRenderPipe.texturePlate_Outer.get(dir)) {
                TextureTransformation icon = Textures.LPnewPipeIconProvider.getIcon(getPipe().getTextureIndex());
                if (icon != null) {
                    objectsToRender.add(new RenderEntry(model, new LPUVTransformationList(new LPUVScale(12f / 16, 12f / 16), icon)));
                }
            }
        }
    }
    return objectsToRender;
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) Arrays(java.util.Arrays) Textures(logisticspipes.textures.Textures) Item(net.minecraft.item.Item) ItemOverrideList(net.minecraft.client.renderer.block.model.ItemOverrideList) Matrix4f(javax.vecmath.Matrix4f) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) MinecraftForgeClient(net.minecraftforge.client.MinecraftForgeClient) Side(net.minecraftforge.fml.relauncher.Side) Map(java.util.Map) CoreUnroutedPipe(logisticspipes.pipes.basic.CoreUnroutedPipe) LogisticsRenderPipe(logisticspipes.renderer.LogisticsRenderPipe) ItemCameraTransforms(net.minecraft.client.renderer.block.model.ItemCameraTransforms) PipeBlockRequestTable(logisticspipes.pipes.PipeBlockRequestTable) I3DOperation(logisticspipes.proxy.object3d.interfaces.I3DOperation) VertexFormat(net.minecraft.client.renderer.vertex.VertexFormat) LogisticsBlockGenericPipe(logisticspipes.pipes.basic.LogisticsBlockGenericPipe) Collection(java.util.Collection) IModelState(net.minecraftforge.common.model.IModelState) BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) IModel(net.minecraftforge.client.model.IModel) List(java.util.List) SimpleServiceLocator(logisticspipes.proxy.SimpleServiceLocator) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe) PipeRenderState(logisticspipes.renderer.state.PipeRenderState) ItemLogisticsPipe(logisticspipes.items.ItemLogisticsPipe) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) IModel3D(logisticspipes.proxy.object3d.interfaces.IModel3D) IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState) LPTranslation(logisticspipes.proxy.object3d.operation.LPTranslation) AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) LPUVTransformationList(logisticspipes.proxy.object3d.operation.LPUVTransformationList) Function(java.util.function.Function) ArrayList(java.util.ArrayList) ICustomModelLoader(net.minecraftforge.client.model.ICustomModelLoader) Lists(com.google.common.collect.Lists) IResourceManager(net.minecraft.client.resources.IResourceManager) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) Nonnull(javax.annotation.Nonnull) Nullable(javax.annotation.Nullable) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) PerspectiveMapWrapper(net.minecraftforge.client.model.PerspectiveMapWrapper) TextureMap(net.minecraft.client.renderer.texture.TextureMap) EnumFacing(net.minecraft.util.EnumFacing) LPUVScale(logisticspipes.proxy.object3d.operation.LPUVScale) Maps(com.google.common.collect.Maps) BlockRenderLayer(net.minecraft.util.BlockRenderLayer) IBlockState(net.minecraft.block.state.IBlockState) LPBlocks(logisticspipes.LPBlocks) ForgeRegistries(net.minecraftforge.fml.common.registry.ForgeRegistries) ResourceLocation(net.minecraft.util.ResourceLocation) TextureTransformation(logisticspipes.proxy.object3d.interfaces.TextureTransformation) LPScale(logisticspipes.proxy.object3d.operation.LPScale) Cache(com.google.common.cache.Cache) Collections(java.util.Collections) IModel3D(logisticspipes.proxy.object3d.interfaces.IModel3D) LPUVScale(logisticspipes.proxy.object3d.operation.LPUVScale) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) EnumFacing(net.minecraft.util.EnumFacing) ArrayList(java.util.ArrayList) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe) LPUVTransformationList(logisticspipes.proxy.object3d.operation.LPUVTransformationList) LPTranslation(logisticspipes.proxy.object3d.operation.LPTranslation) PipeBlockRequestTable(logisticspipes.pipes.PipeBlockRequestTable) TextureTransformation(logisticspipes.proxy.object3d.interfaces.TextureTransformation) LPScale(logisticspipes.proxy.object3d.operation.LPScale)

Aggregations

PipeBlockRequestTable (logisticspipes.pipes.PipeBlockRequestTable)18 TileEntity (net.minecraft.tileentity.TileEntity)11 LogisticsTileGenericPipe (logisticspipes.pipes.basic.LogisticsTileGenericPipe)7 Nonnull (javax.annotation.Nonnull)4 CoreRoutedPipe (logisticspipes.pipes.basic.CoreRoutedPipe)4 PipeRenderState (logisticspipes.renderer.state.PipeRenderState)4 EnumFacing (net.minecraft.util.EnumFacing)4 ArrayList (java.util.ArrayList)3 ItemLogisticsPipe (logisticspipes.items.ItemLogisticsPipe)3 PipeFluidBasic (logisticspipes.pipes.PipeFluidBasic)3 PipeItemsRequestLogisticsMk2 (logisticspipes.pipes.PipeItemsRequestLogisticsMk2)3 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)3 BlockPos (net.minecraft.util.math.BlockPos)3 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)3 Arrays (java.util.Arrays)2 List (java.util.List)2 Map (java.util.Map)2 Function (java.util.function.Function)2 Nullable (javax.annotation.Nullable)2 LPBlocks (logisticspipes.LPBlocks)2