Search in sources :

Example 1 with LogisticalTransporterBase

use of mekanism.common.content.network.transmitter.LogisticalTransporterBase in project Mekanism by mekanism.

the class RenderLogisticalTransporter method render.

@Override
protected void render(TileEntityLogisticalTransporterBase tile, float partialTick, MatrixStack matrix, IRenderTypeBuffer renderer, int light, int overlayLight, IProfiler profiler) {
    LogisticalTransporterBase transporter = tile.getTransmitter();
    Collection<TransporterStack> inTransit = transporter.getTransit();
    BlockPos pos = tile.getBlockPos();
    if (!inTransit.isEmpty()) {
        matrix.pushPose();
        itemRenderer.init(tile.getLevel(), pos);
        float partial = partialTick * transporter.tier.getSpeed();
        Collection<TransporterStack> reducedTransit = getReducedTransit(inTransit);
        for (TransporterStack stack : reducedTransit) {
            float[] stackPos = TransporterUtils.getStackPosition(transporter, stack, partial);
            matrix.pushPose();
            matrix.translate(stackPos[0], stackPos[1], stackPos[2]);
            matrix.scale(0.75F, 0.75F, 0.75F);
            itemRenderer.renderAsStack(matrix, renderer, stack.itemStack);
            matrix.popPose();
            if (stack.color != null) {
                modelBox.render(matrix, renderer, MekanismRenderer.FULL_LIGHT, overlayLight, stackPos[0], stackPos[1], stackPos[2], stack.color);
            }
        }
        matrix.popPose();
    }
    if (transporter instanceof DiversionTransporter) {
        PlayerEntity player = Minecraft.getInstance().player;
        ItemStack itemStack = player.inventory.getSelected();
        if (!itemStack.isEmpty() && itemStack.getItem() instanceof ItemConfigurator) {
            BlockRayTraceResult rayTraceResult = MekanismUtils.rayTrace(player);
            if (!rayTraceResult.getType().equals(Type.MISS) && rayTraceResult.getBlockPos().equals(pos)) {
                Direction side = tile.getSideLookingAt(player, rayTraceResult.getDirection());
                matrix.pushPose();
                matrix.scale(0.5F, 0.5F, 0.5F);
                matrix.translate(0.5, 0.5, 0.5);
                MekanismRenderer.renderObject(getOverlayModel((DiversionTransporter) transporter, side), matrix, renderer.getBuffer(Atlases.translucentCullBlockSheet()), MekanismRenderer.getColorARGB(255, 255, 255, 0.8F), MekanismRenderer.FULL_LIGHT, overlayLight, FaceDisplay.FRONT);
                matrix.popPose();
            }
        }
    }
}
Also used : TransporterStack(mekanism.common.content.transporter.TransporterStack) ItemConfigurator(mekanism.common.item.ItemConfigurator) BlockPos(net.minecraft.util.math.BlockPos) BlockRayTraceResult(net.minecraft.util.math.BlockRayTraceResult) LogisticalTransporterBase(mekanism.common.content.network.transmitter.LogisticalTransporterBase) TileEntityLogisticalTransporterBase(mekanism.common.tile.transmitter.TileEntityLogisticalTransporterBase) DiversionTransporter(mekanism.common.content.network.transmitter.DiversionTransporter) ItemStack(net.minecraft.item.ItemStack) Direction(net.minecraft.util.Direction) PlayerEntity(net.minecraft.entity.player.PlayerEntity)

Example 2 with LogisticalTransporterBase

use of mekanism.common.content.network.transmitter.LogisticalTransporterBase in project Mekanism by mekanism.

the class TransporterPathfinder method checkPath.

private static boolean checkPath(InventoryNetwork network, List<BlockPos> path, TransporterStack stack) {
    for (int i = path.size() - 1; i > 0; i--) {
        LogisticalTransporterBase transmitter = network.getTransmitter(path.get(i));
        if (transmitter == null) {
            return false;
        }
        EnumColor color = transmitter.getColor();
        if (color != null && color != stack.color) {
            return false;
        }
    }
    return true;
}
Also used : EnumColor(mekanism.api.text.EnumColor) LogisticalTransporterBase(mekanism.common.content.network.transmitter.LogisticalTransporterBase)

Example 3 with LogisticalTransporterBase

use of mekanism.common.content.network.transmitter.LogisticalTransporterBase in project Mekanism by mekanism.

the class InventoryNetwork method removePositionedTransmitter.

private void removePositionedTransmitter(LogisticalTransporterBase transmitter) {
    BlockPos pos = transmitter.getTilePos();
    LogisticalTransporterBase currentTransmitter = positionedTransmitters.get(pos);
    if (currentTransmitter != null) {
        // This shouldn't be null but if it is, don't bother attempting to remove
        if (currentTransmitter != transmitter) {
            World world = this.world;
            if (world == null) {
                // If the world is null, grab it from the transmitter
                world = transmitter.getTileWorld();
            }
            if (world != null && world.isClientSide()) {
                // - The old one unloads which causes this removedPositionedTransmitter call to take place
                return;
            }
            Mekanism.logger.warn("Removed transmitter at position: {} in {} was different than expected.", pos, world == null ? null : world.dimension().location());
        }
        positionedTransmitters.remove(pos);
    }
}
Also used : BlockPos(net.minecraft.util.math.BlockPos) LogisticalTransporterBase(mekanism.common.content.network.transmitter.LogisticalTransporterBase) World(net.minecraft.world.World)

Example 4 with LogisticalTransporterBase

use of mekanism.common.content.network.transmitter.LogisticalTransporterBase in project Mekanism by mekanism.

the class InventoryNetwork method removeInvalid.

@Override
protected void removeInvalid(@Nullable LogisticalTransporterBase triggerTransmitter) {
    // Remove invalid transmitters first for share calculations
    Iterator<LogisticalTransporterBase> iterator = transmitters.iterator();
    while (iterator.hasNext()) {
        LogisticalTransporterBase transmitter = iterator.next();
        if (!transmitter.isValid()) {
            iterator.remove();
            removePositionedTransmitter(transmitter);
        }
    }
}
Also used : LogisticalTransporterBase(mekanism.common.content.network.transmitter.LogisticalTransporterBase)

Aggregations

LogisticalTransporterBase (mekanism.common.content.network.transmitter.LogisticalTransporterBase)4 BlockPos (net.minecraft.util.math.BlockPos)2 EnumColor (mekanism.api.text.EnumColor)1 DiversionTransporter (mekanism.common.content.network.transmitter.DiversionTransporter)1 TransporterStack (mekanism.common.content.transporter.TransporterStack)1 ItemConfigurator (mekanism.common.item.ItemConfigurator)1 TileEntityLogisticalTransporterBase (mekanism.common.tile.transmitter.TileEntityLogisticalTransporterBase)1 PlayerEntity (net.minecraft.entity.player.PlayerEntity)1 ItemStack (net.minecraft.item.ItemStack)1 Direction (net.minecraft.util.Direction)1 BlockRayTraceResult (net.minecraft.util.math.BlockRayTraceResult)1 World (net.minecraft.world.World)1