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) if (te instanceof MechanicalBearingTileEntity)
return !((MechanicalBearingTileEntity) te).isRunning(); 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) { if (block instanceof ClockworkBearingBlock) {
BlockEntity te = world.getBlockEntity(pos); BlockEntity te = world.getBlockEntity(pos);
if (te instanceof ClockworkBearingTileEntity) 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.MechanicalBearingBlock;
import com.simibubi.create.content.contraptions.components.structureMovement.bearing.StabilizedContraption; 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.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.AbstractChassisBlock;
import com.simibubi.create.content.contraptions.components.structureMovement.chassis.ChassisTileEntity; import com.simibubi.create.content.contraptions.components.structureMovement.chassis.ChassisTileEntity;
import com.simibubi.create.content.contraptions.components.structureMovement.chassis.StickerBlock; import com.simibubi.create.content.contraptions.components.structureMovement.chassis.StickerBlock;
@ -305,6 +306,10 @@ public abstract class Contraption {
if (AllBlocks.BELT.has(state)) if (AllBlocks.BELT.has(state))
moveBelt(pos, frontier, visited, 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)) if (AllBlocks.GANTRY_CARRIAGE.has(state))
moveGantryPinion(world, pos, frontier, visited, state); moveGantryPinion(world, pos, frontier, visited, state);

View file

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