Search in sources :

Example 6 with Axis

use of net.minecraft.core.Direction.Axis in project Create by Creators-of-Create.

the class MountedContraption method capture.

@Override
protected Pair<StructureBlockInfo, BlockEntity> capture(Level world, BlockPos pos) {
    Pair<StructureBlockInfo, BlockEntity> pair = super.capture(world, pos);
    StructureBlockInfo capture = pair.getKey();
    if (!AllBlocks.CART_ASSEMBLER.has(capture.state))
        return pair;
    Pair<StructureBlockInfo, BlockEntity> anchorSwap = Pair.of(new StructureBlockInfo(pos, CartAssemblerBlock.createAnchor(capture.state), null), pair.getValue());
    if (pos.equals(anchor) || connectedCart != null)
        return anchorSwap;
    for (Axis axis : Iterate.axes) {
        if (axis.isVertical() || !VecHelper.onSameAxis(anchor, pos, axis))
            continue;
        for (AbstractMinecart abstractMinecartEntity : world.getEntitiesOfClass(AbstractMinecart.class, new AABB(pos))) {
            if (!CartAssemblerBlock.canAssembleTo(abstractMinecartEntity))
                break;
            connectedCart = abstractMinecartEntity;
            connectedCart.setPos(pos.getX() + .5, pos.getY(), pos.getZ() + .5f);
        }
    }
    return anchorSwap;
}
Also used : AbstractMinecart(net.minecraft.world.entity.vehicle.AbstractMinecart) StructureBlockInfo(net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo) Axis(net.minecraft.core.Direction.Axis) AABB(net.minecraft.world.phys.AABB) BlockEntity(net.minecraft.world.level.block.entity.BlockEntity)

Example 7 with Axis

use of net.minecraft.core.Direction.Axis in project Create by Creators-of-Create.

the class MountedContraption method assemble.

@Override
public boolean assemble(Level world, BlockPos pos) throws AssemblyException {
    BlockState state = world.getBlockState(pos);
    if (!state.hasProperty(RAIL_SHAPE))
        return false;
    if (!searchMovedStructure(world, pos, null))
        return false;
    Axis axis = state.getValue(RAIL_SHAPE) == RailShape.EAST_WEST ? Axis.X : Axis.Z;
    addBlock(pos, Pair.of(new StructureBlockInfo(pos, AllBlocks.MINECART_ANCHOR.getDefaultState().setValue(BlockStateProperties.HORIZONTAL_AXIS, axis), null), null));
    if (blocks.size() == 1)
        return false;
    return true;
}
Also used : BlockState(net.minecraft.world.level.block.state.BlockState) StructureBlockInfo(net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo) Axis(net.minecraft.core.Direction.Axis)

Example 8 with Axis

use of net.minecraft.core.Direction.Axis in project Create by Creators-of-Create.

the class MechanicalPistonTileEntity method getMovementModeSlot.

@Override
protected ValueBoxTransform getMovementModeSlot() {
    return new DirectionalExtenderScrollOptionSlot((state, d) -> {
        Axis axis = d.getAxis();
        Axis extensionAxis = state.getValue(MechanicalPistonBlock.FACING).getAxis();
        Axis shaftAxis = ((IRotate) state.getBlock()).getRotationAxis(state);
        return extensionAxis != axis && shaftAxis != axis;
    });
}
Also used : IRotate(com.simibubi.create.content.contraptions.base.IRotate) DirectionalExtenderScrollOptionSlot(com.simibubi.create.content.contraptions.components.structureMovement.DirectionalExtenderScrollOptionSlot) Axis(net.minecraft.core.Direction.Axis)

Example 9 with Axis

use of net.minecraft.core.Direction.Axis in project Create by Creators-of-Create.

the class SuperGlueRenderer method initQuads.

private void initQuads() {
    Vec3 diff = Vec3.atLowerCornerOf(Direction.SOUTH.getNormal());
    Vec3 extension = diff.normalize().scale(1 / 32f - 1 / 128f);
    Vec3 plane = VecHelper.axisAlingedPlaneOf(diff);
    Axis axis = Direction.getNearest(diff.x, diff.y, diff.z).getAxis();
    Vec3 start = Vec3.ZERO.subtract(extension);
    Vec3 end = Vec3.ZERO.add(extension);
    plane = plane.scale(1 / 2f);
    Vec3 a1 = plane.add(start);
    Vec3 b1 = plane.add(end);
    plane = VecHelper.rotate(plane, -90, axis);
    Vec3 a2 = plane.add(start);
    Vec3 b2 = plane.add(end);
    plane = VecHelper.rotate(plane, -90, axis);
    Vec3 a3 = plane.add(start);
    Vec3 b3 = plane.add(end);
    plane = VecHelper.rotate(plane, -90, axis);
    Vec3 a4 = plane.add(start);
    Vec3 b4 = plane.add(end);
    insideQuad = new float[] { (float) a1.x, (float) a1.y, (float) a1.z, 1, 0, (float) a2.x, (float) a2.y, (float) a2.z, 1, 1, (float) a3.x, (float) a3.y, (float) a3.z, 0, 1, (float) a4.x, (float) a4.y, (float) a4.z, 0, 0 };
    outsideQuad = new float[] { (float) b4.x, (float) b4.y, (float) b4.z, 0, 0, (float) b3.x, (float) b3.y, (float) b3.z, 0, 1, (float) b2.x, (float) b2.y, (float) b2.z, 1, 1, (float) b1.x, (float) b1.y, (float) b1.z, 1, 0 };
}
Also used : Vec3(net.minecraft.world.phys.Vec3) Axis(net.minecraft.core.Direction.Axis)

Example 10 with Axis

use of net.minecraft.core.Direction.Axis in project Create by Creators-of-Create.

the class PistonExtensionPoleBlock method playerWillDestroy.

@Override
public void playerWillDestroy(Level worldIn, BlockPos pos, BlockState state, Player player) {
    Axis axis = state.getValue(FACING).getAxis();
    Direction direction = Direction.get(AxisDirection.POSITIVE, axis);
    BlockPos pistonHead = null;
    BlockPos pistonBase = null;
    for (int modifier : new int[] { 1, -1 }) {
        for (int offset = modifier; modifier * offset < MechanicalPistonBlock.maxAllowedPistonPoles(); offset += modifier) {
            BlockPos currentPos = pos.relative(direction, offset);
            BlockState block = worldIn.getBlockState(currentPos);
            if (isExtensionPole(block) && axis == block.getValue(FACING).getAxis())
                continue;
            if (isPiston(block) && block.getValue(BlockStateProperties.FACING).getAxis() == axis)
                pistonBase = currentPos;
            if (isPistonHead(block) && block.getValue(BlockStateProperties.FACING).getAxis() == axis)
                pistonHead = currentPos;
            break;
        }
    }
    if (pistonHead != null && pistonBase != null && worldIn.getBlockState(pistonHead).getValue(BlockStateProperties.FACING) == worldIn.getBlockState(pistonBase).getValue(BlockStateProperties.FACING)) {
        final BlockPos basePos = pistonBase;
        BlockPos.betweenClosedStream(pistonBase, pistonHead).filter(p -> !p.equals(pos) && !p.equals(basePos)).forEach(p -> worldIn.destroyBlock(p, !player.isCreative()));
        worldIn.setBlockAndUpdate(basePos, worldIn.getBlockState(basePos).setValue(MechanicalPistonBlock.STATE, PistonState.RETRACTED));
        BlockEntity te = worldIn.getBlockEntity(basePos);
        if (te instanceof MechanicalPistonTileEntity) {
            MechanicalPistonTileEntity baseTE = (MechanicalPistonTileEntity) te;
            baseTE.offset = 0;
            baseTE.onLengthBroken();
        }
    }
    super.playerWillDestroy(worldIn, pos, state, player);
}
Also used : CollisionContext(net.minecraft.world.phys.shapes.CollisionContext) IWrenchable(com.simibubi.create.content.contraptions.wrench.IWrenchable) Direction(net.minecraft.core.Direction) BlockState(net.minecraft.world.level.block.state.BlockState) Builder(net.minecraft.world.level.block.state.StateDefinition.Builder) Axis(net.minecraft.core.Direction.Axis) AxisDirection(net.minecraft.core.Direction.AxisDirection) BlockGetter(net.minecraft.world.level.BlockGetter) PushReaction(net.minecraft.world.level.material.PushReaction) MethodsReturnNonnullByDefault(net.minecraft.MethodsReturnNonnullByDefault) PlacementHelpers(com.simibubi.create.foundation.utility.placement.PlacementHelpers) IPlacementHelper(com.simibubi.create.foundation.utility.placement.IPlacementHelper) Fluids(net.minecraft.world.level.material.Fluids) AllBlocks(com.simibubi.create.AllBlocks) PoleHelper(com.simibubi.create.foundation.utility.placement.util.PoleHelper) BlockStateProperties(net.minecraft.world.level.block.state.properties.BlockStateProperties) BlockItem(net.minecraft.world.item.BlockItem) Predicate(java.util.function.Predicate) MechanicalPistonBlock.isPiston(com.simibubi.create.content.contraptions.components.structureMovement.piston.MechanicalPistonBlock.isPiston) MechanicalPistonBlock.isPistonHead(com.simibubi.create.content.contraptions.components.structureMovement.piston.MechanicalPistonBlock.isPistonHead) SimpleWaterloggedBlock(net.minecraft.world.level.block.SimpleWaterloggedBlock) BlockHitResult(net.minecraft.world.phys.BlockHitResult) InteractionResult(net.minecraft.world.InteractionResult) AllShapes(com.simibubi.create.AllShapes) BlockEntity(net.minecraft.world.level.block.entity.BlockEntity) PistonState(com.simibubi.create.content.contraptions.components.structureMovement.piston.MechanicalPistonBlock.PistonState) WrenchableDirectionalBlock(com.simibubi.create.foundation.block.WrenchableDirectionalBlock) Player(net.minecraft.world.entity.player.Player) MechanicalPistonBlock.isExtensionPole(com.simibubi.create.content.contraptions.components.structureMovement.piston.MechanicalPistonBlock.isExtensionPole) PathComputationType(net.minecraft.world.level.pathfinder.PathComputationType) BlockPos(net.minecraft.core.BlockPos) FluidState(net.minecraft.world.level.material.FluidState) BlockPlaceContext(net.minecraft.world.item.context.BlockPlaceContext) LevelAccessor(net.minecraft.world.level.LevelAccessor) Block(net.minecraft.world.level.block.Block) InteractionHand(net.minecraft.world.InteractionHand) ItemStack(net.minecraft.world.item.ItemStack) Level(net.minecraft.world.level.Level) VoxelShape(net.minecraft.world.phys.shapes.VoxelShape) BlockState(net.minecraft.world.level.block.state.BlockState) BlockPos(net.minecraft.core.BlockPos) Direction(net.minecraft.core.Direction) AxisDirection(net.minecraft.core.Direction.AxisDirection) Axis(net.minecraft.core.Direction.Axis) BlockEntity(net.minecraft.world.level.block.entity.BlockEntity)

Aggregations

Axis (net.minecraft.core.Direction.Axis)85 Direction (net.minecraft.core.Direction)43 BlockPos (net.minecraft.core.BlockPos)39 BlockState (net.minecraft.world.level.block.state.BlockState)35 AxisDirection (net.minecraft.core.Direction.AxisDirection)24 Vec3 (net.minecraft.world.phys.Vec3)14 Level (net.minecraft.world.level.Level)13 IRotate (com.simibubi.create.content.contraptions.base.IRotate)9 SuperByteBuffer (com.simibubi.create.foundation.render.SuperByteBuffer)7 Block (net.minecraft.world.level.block.Block)7 BlockEntity (net.minecraft.world.level.block.entity.BlockEntity)6 VertexConsumer (com.mojang.blaze3d.vertex.VertexConsumer)5 Player (net.minecraft.world.entity.player.Player)5 HashSet (java.util.HashSet)4 ItemStack (net.minecraft.world.item.ItemStack)4 KineticTileEntity (com.simibubi.create.content.contraptions.base.KineticTileEntity)3 Part (com.simibubi.create.content.contraptions.relays.encased.EncasedBeltBlock.Part)3 ArrayList (java.util.ArrayList)3 ServerLevel (net.minecraft.server.level.ServerLevel)3 StructureBlockInfo (net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo)3