Search in sources :

Example 1 with CenteredSideValueBoxTransform

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

the class CreativeMotorTileEntity method addBehaviours.

@Override
public void addBehaviours(List<TileEntityBehaviour> behaviours) {
    super.addBehaviours(behaviours);
    Integer max = AllConfigs.SERVER.kinetics.maxMotorSpeed.get();
    CenteredSideValueBoxTransform slot = new CenteredSideValueBoxTransform((motor, side) -> motor.getValue(CreativeMotorBlock.FACING) == side.getOpposite());
    generatedSpeed = new ScrollValueBehaviour(Lang.translate("generic.speed"), this, slot);
    generatedSpeed.between(-max, max);
    generatedSpeed.value = DEFAULT_SPEED;
    generatedSpeed.scrollableValue = DEFAULT_SPEED;
    generatedSpeed.withUnit(i -> Lang.translate("generic.unit.rpm"));
    generatedSpeed.withCallback(i -> this.updateGeneratedRotation());
    generatedSpeed.withStepFunction(CreativeMotorTileEntity::step);
    behaviours.add(generatedSpeed);
}
Also used : CenteredSideValueBoxTransform(com.simibubi.create.foundation.tileEntity.behaviour.CenteredSideValueBoxTransform) ScrollValueBehaviour(com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.ScrollValueBehaviour)

Example 2 with CenteredSideValueBoxTransform

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

the class BrassTunnelTileEntity method addBehaviours.

@Override
public void addBehaviours(List<TileEntityBehaviour> behaviours) {
    super.addBehaviours(behaviours);
    behaviours.add(selectionMode = new ScrollOptionBehaviour<>(SelectionMode.class, Lang.translate("logistics.when_multiple_outputs_available"), this, new CenteredSideValueBoxTransform((state, d) -> d == Direction.UP)));
    selectionMode.requiresWrench();
    // Propagate settings across connected tunnels
    selectionMode.withCallback(setting -> {
        for (boolean side : Iterate.trueAndFalse) {
            if (!isConnected(side))
                continue;
            BrassTunnelTileEntity adjacent = getAdjacent(side);
            if (adjacent != null)
                adjacent.selectionMode.setValue(setting);
        }
    });
}
Also used : IItemHandler(net.minecraftforge.items.IItemHandler) Direction(net.minecraft.core.Direction) Random(java.util.Random) AxisDirection(net.minecraft.core.Direction.AxisDirection) Pair(org.apache.commons.lang3.tuple.Pair) ChatFormatting(net.minecraft.ChatFormatting) Map(java.util.Map) TranslatableComponent(net.minecraft.network.chat.TranslatableComponent) CenteredSideValueBoxTransform(com.simibubi.create.foundation.tileEntity.behaviour.CenteredSideValueBoxTransform) IdentityHashMap(java.util.IdentityHashMap) NbtUtils(net.minecraft.nbt.NbtUtils) Set(java.util.Set) BlockEntity(net.minecraft.world.level.block.entity.BlockEntity) Capability(net.minecraftforge.common.capabilities.Capability) BlockHelper(com.simibubi.create.foundation.utility.BlockHelper) List(java.util.List) CompoundTag(net.minecraft.nbt.CompoundTag) Couple(com.simibubi.create.foundation.utility.Couple) BlockPos(net.minecraft.core.BlockPos) ItemEntity(net.minecraft.world.entity.item.ItemEntity) BlockEntityType(net.minecraft.world.level.block.entity.BlockEntityType) CapabilityItemHandler(net.minecraftforge.items.CapabilityItemHandler) Entry(java.util.Map.Entry) ItemStack(net.minecraft.world.item.ItemStack) Tag(net.minecraft.nbt.Tag) BlockState(net.minecraft.world.level.block.state.BlockState) BeltHelper(com.simibubi.create.content.contraptions.relays.belt.BeltHelper) ScrollOptionBehaviour(com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.ScrollOptionBehaviour) AllIcons(com.simibubi.create.foundation.gui.AllIcons) FilteringBehaviour(com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBehaviour) ArrayList(java.util.ArrayList) LazyOptional(net.minecraftforge.common.util.LazyOptional) HashSet(java.util.HashSet) Axis(net.minecraft.core.Direction.Axis) SidedFilteringBehaviour(com.simibubi.create.foundation.tileEntity.behaviour.filtering.SidedFilteringBehaviour) ItemHandlerHelper(net.minecraftforge.items.ItemHandlerHelper) INamedIconOptions(com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.INamedIconOptions) Lang(com.simibubi.create.foundation.utility.Lang) AllBlocks(com.simibubi.create.AllBlocks) Nullable(javax.annotation.Nullable) Iterate(com.simibubi.create.foundation.utility.Iterate) TileEntityBehaviour(com.simibubi.create.foundation.tileEntity.TileEntityBehaviour) Component(net.minecraft.network.chat.Component) AllTriggers(com.simibubi.create.foundation.advancement.AllTriggers) BeltTileEntity(com.simibubi.create.content.contraptions.relays.belt.BeltTileEntity) IHaveGoggleInformation(com.simibubi.create.content.contraptions.goggles.IHaveGoggleInformation) Vec3(net.minecraft.world.phys.Vec3) NBTHelper(com.simibubi.create.foundation.utility.NBTHelper) DirectBeltInputBehaviour(com.simibubi.create.foundation.tileEntity.behaviour.belt.DirectBeltInputBehaviour) ScrollOptionBehaviour(com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.ScrollOptionBehaviour) CenteredSideValueBoxTransform(com.simibubi.create.foundation.tileEntity.behaviour.CenteredSideValueBoxTransform)

Example 3 with CenteredSideValueBoxTransform

use of com.simibubi.create.foundation.tileEntity.behaviour.CenteredSideValueBoxTransform in project createaddition by mrh0.

the class ElectricMotorTileEntity method addBehaviours.

@Override
public void addBehaviours(List<TileEntityBehaviour> behaviours) {
    super.addBehaviours(behaviours);
    CenteredSideValueBoxTransform slot = new CenteredSideValueBoxTransform((motor, side) -> motor.getValue(ElectricMotorBlock.FACING) == side.getOpposite());
    generatedSpeed = new ScrollValueBehaviour(Lang.translate("generic.speed"), this, slot);
    generatedSpeed.between(-RPM_RANGE, RPM_RANGE);
    generatedSpeed.value = DEFAULT_SPEED;
    generatedSpeed.scrollableValue = DEFAULT_SPEED;
    generatedSpeed.withUnit(i -> Lang.translate("generic.unit.rpm"));
    generatedSpeed.withCallback(i -> this.updateGeneratedRotation(i));
    generatedSpeed.withStepFunction(ElectricMotorTileEntity::step);
    behaviours.add(generatedSpeed);
}
Also used : CenteredSideValueBoxTransform(com.simibubi.create.foundation.tileEntity.behaviour.CenteredSideValueBoxTransform) ScrollValueBehaviour(com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.ScrollValueBehaviour)

Example 4 with CenteredSideValueBoxTransform

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

the class ChassisTileEntity method addBehaviours.

@Override
public void addBehaviours(List<TileEntityBehaviour> behaviours) {
    int max = AllConfigs.SERVER.kinetics.maxChassisRange.get();
    range = new BulkScrollValueBehaviour(Lang.translate("generic.range"), this, new CenteredSideValueBoxTransform(), te -> ((ChassisTileEntity) te).collectChassisGroup());
    range.requiresWrench();
    range.between(1, max);
    range.withClientCallback(i -> DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> ChassisRangeDisplay.display(this)));
    range.value = max / 2;
    behaviours.add(range);
}
Also used : Direction(net.minecraft.core.Direction) BlockState(net.minecraft.world.level.block.state.BlockState) ArrayList(java.util.ArrayList) Dist(net.minecraftforge.api.distmarker.Dist) HashSet(java.util.HashSet) SmartTileEntity(com.simibubi.create.foundation.tileEntity.SmartTileEntity) Axis(net.minecraft.core.Direction.Axis) AxisDirection(net.minecraft.core.Direction.AxisDirection) AllConfigs(com.simibubi.create.foundation.config.AllConfigs) Lang(com.simibubi.create.foundation.utility.Lang) LinkedList(java.util.LinkedList) AllBlocks(com.simibubi.create.AllBlocks) CenteredSideValueBoxTransform(com.simibubi.create.foundation.tileEntity.behaviour.CenteredSideValueBoxTransform) BlockMovementChecks(com.simibubi.create.content.contraptions.components.structureMovement.BlockMovementChecks) BlockStateProperties(net.minecraft.world.level.block.state.properties.BlockStateProperties) Iterate(com.simibubi.create.foundation.utility.Iterate) TileEntityBehaviour(com.simibubi.create.foundation.tileEntity.TileEntityBehaviour) BulkScrollValueBehaviour(com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.BulkScrollValueBehaviour) Set(java.util.Set) BlockEntity(net.minecraft.world.level.block.entity.BlockEntity) DistExecutor(net.minecraftforge.fml.DistExecutor) List(java.util.List) BlockPos(net.minecraft.core.BlockPos) BlockEntityType(net.minecraft.world.level.block.entity.BlockEntityType) Queue(java.util.Queue) ScrollValueBehaviour(com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.ScrollValueBehaviour) Collections(java.util.Collections) BulkScrollValueBehaviour(com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.BulkScrollValueBehaviour) CenteredSideValueBoxTransform(com.simibubi.create.foundation.tileEntity.behaviour.CenteredSideValueBoxTransform)

Aggregations

CenteredSideValueBoxTransform (com.simibubi.create.foundation.tileEntity.behaviour.CenteredSideValueBoxTransform)4 ScrollValueBehaviour (com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.ScrollValueBehaviour)3 AllBlocks (com.simibubi.create.AllBlocks)2 TileEntityBehaviour (com.simibubi.create.foundation.tileEntity.TileEntityBehaviour)2 Iterate (com.simibubi.create.foundation.utility.Iterate)2 Lang (com.simibubi.create.foundation.utility.Lang)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 List (java.util.List)2 Set (java.util.Set)2 BlockPos (net.minecraft.core.BlockPos)2 Direction (net.minecraft.core.Direction)2 Axis (net.minecraft.core.Direction.Axis)2 AxisDirection (net.minecraft.core.Direction.AxisDirection)2 BlockMovementChecks (com.simibubi.create.content.contraptions.components.structureMovement.BlockMovementChecks)1 IHaveGoggleInformation (com.simibubi.create.content.contraptions.goggles.IHaveGoggleInformation)1 BeltHelper (com.simibubi.create.content.contraptions.relays.belt.BeltHelper)1 BeltTileEntity (com.simibubi.create.content.contraptions.relays.belt.BeltTileEntity)1 AllTriggers (com.simibubi.create.foundation.advancement.AllTriggers)1 AllConfigs (com.simibubi.create.foundation.config.AllConfigs)1