Search in sources :

Example 1 with RotatingData

use of com.simibubi.create.content.contraptions.base.flwdata.RotatingData in project Create by Creators-of-Create.

the class EncasedCogInstance method init.

@Override
public void init() {
    rotatingModel = setup(getCogModel().createInstance());
    Block block = blockState.getBlock();
    if (!(block instanceof IRotate))
        return;
    IRotate def = (IRotate) block;
    rotatingTopShaft = Optional.empty();
    rotatingBottomShaft = Optional.empty();
    for (Direction d : Iterate.directionsInAxis(axis)) {
        if (!def.hasShaftTowards(blockEntity.getLevel(), blockEntity.getBlockPos(), blockState, d))
            continue;
        RotatingData data = setup(getRotatingMaterial().getModel(AllBlockPartials.SHAFT_HALF, blockState, d).createInstance());
        if (d.getAxisDirection() == AxisDirection.POSITIVE)
            rotatingTopShaft = Optional.of(data);
        else
            rotatingBottomShaft = Optional.of(data);
    }
}
Also used : IRotate(com.simibubi.create.content.contraptions.base.IRotate) Block(net.minecraft.world.level.block.Block) Direction(net.minecraft.core.Direction) AxisDirection(net.minecraft.core.Direction.AxisDirection) RotatingData(com.simibubi.create.content.contraptions.base.flwdata.RotatingData)

Example 2 with RotatingData

use of com.simibubi.create.content.contraptions.base.flwdata.RotatingData in project Create by Creators-of-Create.

the class GearboxInstance method update.

@Override
public void update() {
    updateSourceFacing();
    for (Map.Entry<Direction, RotatingData> key : keys.entrySet()) {
        Direction direction = key.getKey();
        Direction.Axis axis = direction.getAxis();
        updateRotation(key.getValue(), axis, getSpeed(direction));
    }
}
Also used : EnumMap(java.util.EnumMap) Map(java.util.Map) Direction(net.minecraft.core.Direction) RotatingData(com.simibubi.create.content.contraptions.base.flwdata.RotatingData)

Example 3 with RotatingData

use of com.simibubi.create.content.contraptions.base.flwdata.RotatingData in project Create by Creators-of-Create.

the class BracketedKineticTileInstance method init.

@Override
public void init() {
    super.init();
    if (!ICogWheel.isLargeCog(blockEntity.getBlockState()))
        return;
    // Large cogs sometimes have to offset their teeth by 11.25 degrees in order to
    // mesh properly
    float speed = blockEntity.getSpeed();
    Axis axis = KineticTileEntityRenderer.getRotationAxisOf(blockEntity);
    BlockPos pos = blockEntity.getBlockPos();
    float offset = BracketedKineticTileRenderer.getShaftAngleOffset(axis, pos);
    Direction facing = Direction.fromAxisAndDirection(axis, AxisDirection.POSITIVE);
    Instancer<RotatingData> half = getRotatingMaterial().getModel(AllBlockPartials.COGWHEEL_SHAFT, blockState, facing, () -> this.rotateToAxis(axis));
    additionalShaft = setup(half.createInstance(), speed);
    additionalShaft.setRotationOffset(offset);
}
Also used : BlockPos(net.minecraft.core.BlockPos) Direction(net.minecraft.core.Direction) AxisDirection(net.minecraft.core.Direction.AxisDirection) Axis(net.minecraft.core.Direction.Axis) RotatingData(com.simibubi.create.content.contraptions.base.flwdata.RotatingData)

Aggregations

RotatingData (com.simibubi.create.content.contraptions.base.flwdata.RotatingData)3 Direction (net.minecraft.core.Direction)3 AxisDirection (net.minecraft.core.Direction.AxisDirection)2 IRotate (com.simibubi.create.content.contraptions.base.IRotate)1 EnumMap (java.util.EnumMap)1 Map (java.util.Map)1 BlockPos (net.minecraft.core.BlockPos)1 Axis (net.minecraft.core.Direction.Axis)1 Block (net.minecraft.world.level.block.Block)1