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);
}
}
Aggregations