use of com.simibubi.create.content.contraptions.components.structureMovement.mounted.MountedContraption in project LittleContraptions by EDToaster.
the class BargeAssemblerBlockEntity method assemble.
protected void assemble(Level world, BlockPos pos, ContraptionBargeEntity barge) {
if (!barge.getPassengers().isEmpty())
return;
CartAssemblerTileEntity.CartMovementMode mode = CartAssemblerTileEntity.CartMovementMode.ROTATE;
MountedContraption contraption = new MountedContraption(mode);
try {
if (!contraption.assemble(world, pos)) {
return;
}
lastException = null;
} catch (AssemblyException e) {
lastException = e;
e.printStackTrace();
return;
}
Direction initialOrientation = BargeAssemblerBlock.getHorizontalDirection(getBlockState());
contraption.removeBlocksFromWorld(world, BlockPos.ZERO);
contraption.startMoving(world);
contraption.expandBoundsAroundAxis(Direction.Axis.Y);
OrientedContraptionEntity entity = OrientedContraptionEntity.create(world, contraption, initialOrientation);
entity.setPos(pos.getX(), pos.getY(), pos.getZ());
world.addFreshEntity(entity);
entity.startRiding(barge);
}
use of com.simibubi.create.content.contraptions.components.structureMovement.mounted.MountedContraption in project Create by Creators-of-Create.
the class OrientedContraptionEntity method tickContraption.
@Override
protected void tickContraption() {
Entity e = getVehicle();
if (e == null)
return;
boolean rotationLock = false;
boolean pauseWhileRotating = false;
boolean wasStalled = isStalled();
if (contraption instanceof MountedContraption) {
MountedContraption mountedContraption = (MountedContraption) contraption;
rotationLock = mountedContraption.rotationMode == CartMovementMode.ROTATION_LOCKED;
pauseWhileRotating = mountedContraption.rotationMode == CartMovementMode.ROTATE_PAUSED;
}
Entity riding = e;
while (riding.getVehicle() != null && !(contraption instanceof StabilizedContraption)) riding = riding.getVehicle();
boolean isOnCoupling = false;
UUID couplingId = getCouplingId();
isOnCoupling = couplingId != null && riding instanceof AbstractMinecart;
if (!attachedExtraInventories) {
attachInventoriesFromRidingCarts(riding, isOnCoupling, couplingId);
attachedExtraInventories = true;
}
boolean rotating = updateOrientation(rotationLock, wasStalled, riding, isOnCoupling);
if (!rotating || !pauseWhileRotating)
tickActors();
boolean isStalled = isStalled();
LazyOptional<MinecartController> capability = riding.getCapability(CapabilityMinecartController.MINECART_CONTROLLER_CAPABILITY);
if (capability.isPresent()) {
if (!level.isClientSide())
capability.orElse(null).setStalledExternally(isStalled);
} else {
if (isStalled) {
if (!wasStalled)
motionBeforeStall = riding.getDeltaMovement();
riding.setDeltaMovement(0, 0, 0);
}
if (wasStalled && !isStalled) {
riding.setDeltaMovement(motionBeforeStall);
motionBeforeStall = Vec3.ZERO;
}
}
if (level.isClientSide)
return;
if (!isStalled()) {
if (isOnCoupling) {
Couple<MinecartController> coupledCarts = getCoupledCartsIfPresent();
if (coupledCarts == null)
return;
coupledCarts.map(MinecartController::cart).forEach(this::powerFurnaceCartWithFuelFromStorage);
return;
}
powerFurnaceCartWithFuelFromStorage(riding);
}
}
Aggregations