Search in sources :

Example 11 with Contraption

use of com.simibubi.create.content.contraptions.components.structureMovement.Contraption in project Create by Creators-of-Create.

the class MinecartContraptionItem method addContraptionToMinecart.

public static void addContraptionToMinecart(Level world, ItemStack itemstack, AbstractMinecart cart, @Nullable Direction newFacing) {
    CompoundTag tag = itemstack.getOrCreateTag();
    if (tag.contains("Contraption")) {
        CompoundTag contraptionTag = tag.getCompound("Contraption");
        Direction intialOrientation = NBTHelper.readEnum(contraptionTag, "InitialOrientation", Direction.class);
        Contraption mountedContraption = Contraption.fromNBT(world, contraptionTag, false);
        OrientedContraptionEntity contraptionEntity = newFacing == null ? OrientedContraptionEntity.create(world, mountedContraption, intialOrientation) : OrientedContraptionEntity.createAtYaw(world, mountedContraption, intialOrientation, newFacing.toYRot());
        contraptionEntity.startRiding(cart);
        contraptionEntity.setPos(cart.getX(), cart.getY(), cart.getZ());
        world.addFreshEntity(contraptionEntity);
    }
}
Also used : OrientedContraptionEntity(com.simibubi.create.content.contraptions.components.structureMovement.OrientedContraptionEntity) Contraption(com.simibubi.create.content.contraptions.components.structureMovement.Contraption) Direction(net.minecraft.core.Direction) CompoundTag(net.minecraft.nbt.CompoundTag)

Aggregations

Contraption (com.simibubi.create.content.contraptions.components.structureMovement.Contraption)11 BlockPos (net.minecraft.util.math.BlockPos)5 Vector3d (net.minecraft.util.math.vector.Vector3d)4 BlockState (net.minecraft.block.BlockState)3 RaycastHelper (com.simibubi.create.foundation.utility.RaycastHelper)2 ISpeedContraption (com.teammoeg.frostedheart.util.ISpeedContraption)2 Minecraft (net.minecraft.client.Minecraft)2 ClientPlayerEntity (net.minecraft.client.entity.player.ClientPlayerEntity)2 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)2 BlockRayTraceResult (net.minecraft.util.math.BlockRayTraceResult)2 VoxelShape (net.minecraft.util.math.shapes.VoxelShape)2 Template (net.minecraft.world.gen.feature.template.Template)2 BlockState (net.minecraft.world.level.block.state.BlockState)2 SubscribeEvent (net.minecraftforge.eventbus.api.SubscribeEvent)2 MutableObject (org.apache.commons.lang3.mutable.MutableObject)2 AirshipContraption (com.eriksonn.createaeronautics.contraptions.AirshipContraption)1 AirshipContraptionEntity (com.eriksonn.createaeronautics.contraptions.AirshipContraptionEntity)1 AirshipWorld (com.eriksonn.createaeronautics.dimension.AirshipWorld)1 MatrixTransformStack (com.jozufozu.flywheel.util.transform.MatrixTransformStack)1 MatrixStack (com.mojang.blaze3d.matrix.MatrixStack)1