Search in sources :

Example 1 with ItemValueBox

use of com.simibubi.create.foundation.tileEntity.behaviour.ValueBox.ItemValueBox in project Create by Creators-of-Create.

the class FilteringRenderer method tick.

public static void tick() {
    Minecraft mc = Minecraft.getInstance();
    HitResult target = mc.hitResult;
    if (target == null || !(target instanceof BlockHitResult))
        return;
    BlockHitResult result = (BlockHitResult) target;
    ClientLevel world = mc.level;
    BlockPos pos = result.getBlockPos();
    BlockState state = world.getBlockState(pos);
    FilteringBehaviour behaviour = TileEntityBehaviour.get(world, pos, FilteringBehaviour.TYPE);
    if (mc.player.isShiftKeyDown())
        return;
    if (behaviour == null)
        return;
    if (behaviour instanceof SidedFilteringBehaviour) {
        behaviour = ((SidedFilteringBehaviour) behaviour).get(result.getDirection());
        if (behaviour == null)
            return;
    }
    if (!behaviour.isActive())
        return;
    if (behaviour.slotPositioning instanceof ValueBoxTransform.Sided)
        ((Sided) behaviour.slotPositioning).fromSide(result.getDirection());
    if (!behaviour.slotPositioning.shouldRender(state))
        return;
    ItemStack filter = behaviour.getFilter();
    boolean isFilterSlotted = filter.getItem() instanceof FilterItem;
    boolean showCount = behaviour.isCountVisible();
    boolean fluids = behaviour.fluidFilter;
    Component label = isFilterSlotted ? TextComponent.EMPTY : Lang.translate(behaviour.recipeFilter ? "logistics.recipe_filter" : fluids ? "logistics.fluid_filter" : "logistics.filter");
    boolean hit = behaviour.slotPositioning.testHit(state, target.getLocation().subtract(Vec3.atLowerCornerOf(pos)));
    AABB emptyBB = new AABB(Vec3.ZERO, Vec3.ZERO);
    AABB bb = isFilterSlotted ? emptyBB.inflate(.45f, .31f, .2f) : emptyBB.inflate(.25f);
    ValueBox box = showCount ? new ItemValueBox(label, bb, pos, filter, behaviour.scrollableValue) : new ValueBox(label, bb, pos);
    box.offsetLabel(behaviour.textShift).withColors(fluids ? 0x407088 : 0x7A6A2C, fluids ? 0x70adb5 : 0xB79D64).scrollTooltip(showCount && !isFilterSlotted ? new TextComponent("[").append(Lang.translate("action.scroll")).append("]") : TextComponent.EMPTY).passive(!hit);
    CreateClient.OUTLINER.showValueBox(Pair.of("filter", pos), box.transform(behaviour.slotPositioning)).lineWidth(1 / 64f).withFaceTexture(hit ? AllSpecialTextures.THIN_CHECKERED : null).highlightFace(result.getDirection());
}
Also used : TextComponent(net.minecraft.network.chat.TextComponent) ClientLevel(net.minecraft.client.multiplayer.ClientLevel) Minecraft(net.minecraft.client.Minecraft) Sided(com.simibubi.create.foundation.tileEntity.behaviour.ValueBoxTransform.Sided) BlockHitResult(net.minecraft.world.phys.BlockHitResult) HitResult(net.minecraft.world.phys.HitResult) FilterItem(com.simibubi.create.content.logistics.item.filter.FilterItem) BlockState(net.minecraft.world.level.block.state.BlockState) ValueBox(com.simibubi.create.foundation.tileEntity.behaviour.ValueBox) ItemValueBox(com.simibubi.create.foundation.tileEntity.behaviour.ValueBox.ItemValueBox) BlockPos(net.minecraft.core.BlockPos) BlockHitResult(net.minecraft.world.phys.BlockHitResult) ItemStack(net.minecraft.world.item.ItemStack) Component(net.minecraft.network.chat.Component) TextComponent(net.minecraft.network.chat.TextComponent) AABB(net.minecraft.world.phys.AABB) ItemValueBox(com.simibubi.create.foundation.tileEntity.behaviour.ValueBox.ItemValueBox)

Aggregations

FilterItem (com.simibubi.create.content.logistics.item.filter.FilterItem)1 ValueBox (com.simibubi.create.foundation.tileEntity.behaviour.ValueBox)1 ItemValueBox (com.simibubi.create.foundation.tileEntity.behaviour.ValueBox.ItemValueBox)1 Sided (com.simibubi.create.foundation.tileEntity.behaviour.ValueBoxTransform.Sided)1 Minecraft (net.minecraft.client.Minecraft)1 ClientLevel (net.minecraft.client.multiplayer.ClientLevel)1 BlockPos (net.minecraft.core.BlockPos)1 Component (net.minecraft.network.chat.Component)1 TextComponent (net.minecraft.network.chat.TextComponent)1 ItemStack (net.minecraft.world.item.ItemStack)1 BlockState (net.minecraft.world.level.block.state.BlockState)1 AABB (net.minecraft.world.phys.AABB)1 BlockHitResult (net.minecraft.world.phys.BlockHitResult)1 HitResult (net.minecraft.world.phys.HitResult)1