Flying Windmills

- Active windmill bearings can now be moved by contraptions, returning to their running state after the new contraption disassembled
This commit is contained in:
simibubi 2022-06-07 20:11:49 +02:00
parent 8c444f1476
commit d969adb233
3 changed files with 30 additions and 6 deletions

View file

@ -207,11 +207,6 @@ public class BlockMovementChecks {
if (te instanceof MechanicalBearingTileEntity)
return !((MechanicalBearingTileEntity) te).isRunning();
}
if (block instanceof WindmillBearingBlock) {
BlockEntity te = world.getBlockEntity(pos);
if (te instanceof WindmillBearingTileEntity)
return !((WindmillBearingTileEntity) te).isRunning();
}
if (block instanceof ClockworkBearingBlock) {
BlockEntity te = world.getBlockEntity(pos);
if (te instanceof ClockworkBearingTileEntity)

View file

@ -36,6 +36,7 @@ import com.simibubi.create.content.contraptions.components.steam.PoweredShaftTil
import com.simibubi.create.content.contraptions.components.structureMovement.bearing.MechanicalBearingBlock;
import com.simibubi.create.content.contraptions.components.structureMovement.bearing.StabilizedContraption;
import com.simibubi.create.content.contraptions.components.structureMovement.bearing.WindmillBearingBlock;
import com.simibubi.create.content.contraptions.components.structureMovement.bearing.WindmillBearingTileEntity;
import com.simibubi.create.content.contraptions.components.structureMovement.chassis.AbstractChassisBlock;
import com.simibubi.create.content.contraptions.components.structureMovement.chassis.ChassisTileEntity;
import com.simibubi.create.content.contraptions.components.structureMovement.chassis.StickerBlock;
@ -305,6 +306,10 @@ public abstract class Contraption {
if (AllBlocks.BELT.has(state))
moveBelt(pos, frontier, visited, state);
if (AllBlocks.WINDMILL_BEARING.has(state)
&& world.getBlockEntity(pos) instanceof WindmillBearingTileEntity wbte)
wbte.disassembleForMovement();
if (AllBlocks.GANTRY_CARRIAGE.has(state))
moveGantryPinion(world, pos, frontier, visited, state);

View file

@ -20,6 +20,8 @@ public class WindmillBearingTileEntity extends MechanicalBearingTileEntity {
protected ScrollOptionBehaviour<RotationDirection> movementDirection;
protected float lastGeneratedSpeed;
protected boolean queuedReassembly;
public WindmillBearingTileEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
super(type, pos, state);
}
@ -28,6 +30,7 @@ public class WindmillBearingTileEntity extends MechanicalBearingTileEntity {
public void updateGeneratedRotation() {
super.updateGeneratedRotation();
lastGeneratedSpeed = getGeneratedSpeed();
queuedReassembly = false;
}
@Override
@ -37,6 +40,25 @@ public class WindmillBearingTileEntity extends MechanicalBearingTileEntity {
assembleNextTick = cancelAssembly;
}
@Override
public void tick() {
super.tick();
if (level.isClientSide())
return;
if (!queuedReassembly)
return;
queuedReassembly = false;
if (!running)
assembleNextTick = true;
}
public void disassembleForMovement() {
if (!running)
return;
disassemble();
queuedReassembly = true;
}
@Override
public float getGeneratedSpeed() {
if (!running)
@ -44,7 +66,7 @@ public class WindmillBearingTileEntity extends MechanicalBearingTileEntity {
if (movedContraption == null)
return lastGeneratedSpeed;
int sails = ((BearingContraption) movedContraption.getContraption()).getSailBlocks()
/ AllConfigs.SERVER.kinetics.windmillSailsPerRPM.get();
/ AllConfigs.SERVER.kinetics.windmillSailsPerRPM.get();
return Mth.clamp(sails, 1, 16) * getAngleSpeedDirection();
}
@ -61,6 +83,7 @@ public class WindmillBearingTileEntity extends MechanicalBearingTileEntity {
@Override
public void write(CompoundTag compound, boolean clientPacket) {
compound.putFloat("LastGenerated", lastGeneratedSpeed);
compound.putBoolean("QueueAssembly", queuedReassembly);
super.write(compound, clientPacket);
}
@ -68,6 +91,7 @@ public class WindmillBearingTileEntity extends MechanicalBearingTileEntity {
protected void read(CompoundTag compound, boolean clientPacket) {
if (!wasMoved)
lastGeneratedSpeed = compound.getFloat("LastGenerated");
queuedReassembly = compound.getBoolean("QueueAssembly");
super.read(compound, clientPacket);
}