Search in sources :

Example 1 with ValueBoxTransform

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

the class LinkRenderer 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();
    LinkBehaviour behaviour = TileEntityBehaviour.get(world, pos, LinkBehaviour.TYPE);
    if (behaviour == null)
        return;
    Component freq1 = Lang.translate("logistics.firstFrequency");
    Component freq2 = Lang.translate("logistics.secondFrequency");
    for (boolean first : Iterate.trueAndFalse) {
        AABB bb = new AABB(Vec3.ZERO, Vec3.ZERO).inflate(.25f);
        Component label = first ? freq1 : freq2;
        boolean hit = behaviour.testHit(first, target.getLocation());
        ValueBoxTransform transform = first ? behaviour.firstSlot : behaviour.secondSlot;
        ValueBox box = new ValueBox(label, bb, pos).withColors(0x601F18, 0xB73C2D).offsetLabel(behaviour.textShift).passive(!hit);
        CreateClient.OUTLINER.showValueBox(Pair.of(Boolean.valueOf(first), pos), box.transform(transform)).lineWidth(1 / 64f).withFaceTexture(hit ? AllSpecialTextures.THIN_CHECKERED : null).highlightFace(result.getDirection());
    }
}
Also used : BlockHitResult(net.minecraft.world.phys.BlockHitResult) HitResult(net.minecraft.world.phys.HitResult) ClientLevel(net.minecraft.client.multiplayer.ClientLevel) ValueBox(com.simibubi.create.foundation.tileEntity.behaviour.ValueBox) BlockPos(net.minecraft.core.BlockPos) ValueBoxTransform(com.simibubi.create.foundation.tileEntity.behaviour.ValueBoxTransform) BlockHitResult(net.minecraft.world.phys.BlockHitResult) Component(net.minecraft.network.chat.Component) Minecraft(net.minecraft.client.Minecraft) AABB(net.minecraft.world.phys.AABB)

Example 2 with ValueBoxTransform

use of com.simibubi.create.foundation.tileEntity.behaviour.ValueBoxTransform in project Create_Aeronautics by Eriksonnaren.

the class TorsionSpringTileEntity method addBehaviours.

@Override
public void addBehaviours(List<TileEntityBehaviour> behaviours) {
    super.addBehaviours(behaviours);
    // Integer max = AllConfigs.SERVER.kinetics.maxRotationSpeed.get();
    maxAngle = new ScrollValueBehaviour(new StringTextComponent("Angle"), this, new TorsionSpringValueBoxTransform());
    maxAngle.between(1, 360);
    maxAngle.value = 90;
    maxAngle.withStepFunction(TorsionSpringTileEntity::step);
    behaviours.add(maxAngle);
    movementMode = new ScrollOptionBehaviour<>(MovementMode.class, Lang.translate("contraptions.movement_mode"), this, new TorsionSpringValueBoxTransform2());
    // behaviours.add(movementMode);
    Pair<ValueBoxTransform, ValueBoxTransform> slots = ValueBoxTransform.Dual.makeSlots(RedstoneLinkFrequencySlot::new);
    SpringBehaviour b = new SpringBehaviour(this, slots);
// behaviours.add(b);
}
Also used : RedstoneLinkFrequencySlot(com.simibubi.create.content.logistics.block.redstone.RedstoneLinkFrequencySlot) ValueBoxTransform(com.simibubi.create.foundation.tileEntity.behaviour.ValueBoxTransform) ScrollValueBehaviour(com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.ScrollValueBehaviour)

Example 3 with ValueBoxTransform

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

the class FilteringRenderer method renderOnTileEntity.

public static void renderOnTileEntity(SmartTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) {
    if (te == null || te.isRemoved())
        return;
    Entity cameraEntity = Minecraft.getInstance().cameraEntity;
    float max = AllConfigs.CLIENT.filterItemRenderDistance.getF();
    if (!te.isVirtual() && cameraEntity != null && cameraEntity.position().distanceToSqr(VecHelper.getCenterOf(te.getBlockPos())) > (max * max))
        return;
    FilteringBehaviour behaviour = te.getBehaviour(FilteringBehaviour.TYPE);
    if (behaviour == null)
        return;
    if (!behaviour.isActive())
        return;
    if (behaviour.getFilter().isEmpty() && !(behaviour instanceof SidedFilteringBehaviour))
        return;
    ValueBoxTransform slotPositioning = behaviour.slotPositioning;
    BlockState blockState = te.getBlockState();
    if (slotPositioning instanceof ValueBoxTransform.Sided) {
        ValueBoxTransform.Sided sided = (ValueBoxTransform.Sided) slotPositioning;
        Direction side = sided.getSide();
        for (Direction d : Iterate.directions) {
            ItemStack filter = behaviour.getFilter(d);
            if (filter.isEmpty())
                continue;
            sided.fromSide(d);
            if (!slotPositioning.shouldRender(blockState))
                continue;
            ms.pushPose();
            slotPositioning.transform(blockState, ms);
            ValueBoxRenderer.renderItemIntoValueBox(filter, ms, buffer, light, overlay);
            ms.popPose();
        }
        sided.fromSide(side);
        return;
    } else if (slotPositioning.shouldRender(blockState)) {
        ms.pushPose();
        slotPositioning.transform(blockState, ms);
        ValueBoxRenderer.renderItemIntoValueBox(behaviour.getFilter(), ms, buffer, light, overlay);
        ms.popPose();
    }
}
Also used : SmartTileEntity(com.simibubi.create.foundation.tileEntity.SmartTileEntity) Entity(net.minecraft.world.entity.Entity) BlockState(net.minecraft.world.level.block.state.BlockState) Sided(com.simibubi.create.foundation.tileEntity.behaviour.ValueBoxTransform.Sided) ValueBoxTransform(com.simibubi.create.foundation.tileEntity.behaviour.ValueBoxTransform) ItemStack(net.minecraft.world.item.ItemStack) Direction(net.minecraft.core.Direction) Sided(com.simibubi.create.foundation.tileEntity.behaviour.ValueBoxTransform.Sided)

Example 4 with ValueBoxTransform

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

the class LinkRenderer method renderOnTileEntity.

public static void renderOnTileEntity(SmartTileEntity te, float partialTicks, PoseStack ms, MultiBufferSource buffer, int light, int overlay) {
    if (te == null || te.isRemoved())
        return;
    Entity cameraEntity = Minecraft.getInstance().cameraEntity;
    float max = AllConfigs.CLIENT.filterItemRenderDistance.getF();
    if (!te.isVirtual() && cameraEntity != null && cameraEntity.position().distanceToSqr(VecHelper.getCenterOf(te.getBlockPos())) > (max * max))
        return;
    LinkBehaviour behaviour = te.getBehaviour(LinkBehaviour.TYPE);
    if (behaviour == null)
        return;
    for (boolean first : Iterate.trueAndFalse) {
        ValueBoxTransform transform = first ? behaviour.firstSlot : behaviour.secondSlot;
        ItemStack stack = first ? behaviour.frequencyFirst.getStack() : behaviour.frequencyLast.getStack();
        ms.pushPose();
        transform.transform(te.getBlockState(), ms);
        ValueBoxRenderer.renderItemIntoValueBox(stack, ms, buffer, light, overlay);
        ms.popPose();
    }
}
Also used : SmartTileEntity(com.simibubi.create.foundation.tileEntity.SmartTileEntity) Entity(net.minecraft.world.entity.Entity) ValueBoxTransform(com.simibubi.create.foundation.tileEntity.behaviour.ValueBoxTransform) ItemStack(net.minecraft.world.item.ItemStack)

Aggregations

ValueBoxTransform (com.simibubi.create.foundation.tileEntity.behaviour.ValueBoxTransform)4 SmartTileEntity (com.simibubi.create.foundation.tileEntity.SmartTileEntity)2 Entity (net.minecraft.world.entity.Entity)2 ItemStack (net.minecraft.world.item.ItemStack)2 RedstoneLinkFrequencySlot (com.simibubi.create.content.logistics.block.redstone.RedstoneLinkFrequencySlot)1 ValueBox (com.simibubi.create.foundation.tileEntity.behaviour.ValueBox)1 Sided (com.simibubi.create.foundation.tileEntity.behaviour.ValueBoxTransform.Sided)1 ScrollValueBehaviour (com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.ScrollValueBehaviour)1 Minecraft (net.minecraft.client.Minecraft)1 ClientLevel (net.minecraft.client.multiplayer.ClientLevel)1 BlockPos (net.minecraft.core.BlockPos)1 Direction (net.minecraft.core.Direction)1 Component (net.minecraft.network.chat.Component)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