refactor: 修改释放玩家接口及其调用,添加强制退出参数
This commit is contained in:
parent
ccb3146a0c
commit
6561ab393a
|
|
@ -88,7 +88,7 @@ public class DungeonDataSyncManager extends CachedSyncManager<UUID, AbstractPlay
|
|||
player.getCapability(EroticDungeonGameApi.PLAYER_DUNGEON_DATA_CAP).ifPresent(
|
||||
cap -> {
|
||||
if (cap.getDeviceMainBlockPos() != null && player.level().getBlockEntity(cap.getDeviceMainBlockPos()) instanceof BaseSeatBlockEntity seat) {
|
||||
((IEDGEntity)player).releaseEntityFromEDGDevice(seat.getLockCode());
|
||||
((IEDGEntity)player).releaseEntityFromEDGDevice(true);
|
||||
FurnitureHelper.setSeatOccupied(player.level(), cap.getDeviceMainBlockPos(), false);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@ public class SeatService {
|
|||
}
|
||||
}
|
||||
} else if (deviceMainBlockPos != null && player.level().getBlockEntity(cap.getDeviceMainBlockPos()) instanceof BaseSeatBlockEntity seat) {
|
||||
((IEDGEntity)player).releaseEntityFromEDGDevice(seat.getLockCode());
|
||||
((IEDGEntity)player).releaseEntityFromEDGDevice(true);
|
||||
try {
|
||||
if (bindPlayerToSeat(player, deviceMainBlockPos)) {
|
||||
return player.getVehicle();
|
||||
|
|
@ -262,7 +262,7 @@ public class SeatService {
|
|||
}
|
||||
isCancelled = EroticDungeon.EVENT_BUS.post(new UnRideDeviceEvent.Pre(playerByUUID, blockPos, blockState, be, seat));
|
||||
if (!isCancelled) {
|
||||
if(seat != null) ((IEDGEntity)(playerByUUID)).releaseEntityFromEDGDevice(be.getLockCode());
|
||||
if(seat != null) ((IEDGEntity)(playerByUUID)).releaseEntityFromEDGDevice(true);
|
||||
playerByUUID.getCapability(EroticDungeonGameApi.PLAYER_DUNGEON_DATA_CAP)
|
||||
.ifPresent(i -> i.clearDungeonData(playerByUUID));
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -105,11 +105,11 @@ public abstract class MixinEntity implements IEDGEntity {
|
|||
|
||||
@SuppressWarnings("AddedMixinMembersNamePattern")
|
||||
@Override
|
||||
public void releaseEntityFromEDGDevice(long lock) {
|
||||
public void releaseEntityFromEDGDevice(long lock, boolean forced) {
|
||||
Services.WORK_SPACE.tryToDoIfInDevice(Entity.class.cast(this),
|
||||
data -> {
|
||||
if (data.getDeviceMainBlockPos() != null && level.getBlockEntity(data.getDeviceMainBlockPos()) instanceof BaseSeatBlockEntity seatBe) {
|
||||
if ((Entity.class.cast(this) instanceof Player player && player.isCreative()) || (seatBe.hasLockCode() && Objects.equals(seatBe.getLockCode(), lock)) || !seatBe.hasLockCode()) {
|
||||
if ((Entity.class.cast(this) instanceof Player player && player.isCreative()) || forced || (seatBe.hasLockCode() && Objects.equals(seatBe.getLockCode(), lock)) || !seatBe.hasLockCode()) {
|
||||
removeVehicle();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,12 +76,12 @@ public abstract class MixinServerPlayer extends Player implements IEDGEntity {
|
|||
|
||||
@SuppressWarnings("AddedMixinMembersNamePattern")
|
||||
@Override
|
||||
public void releaseEntityFromEDGDevice(long lock) {
|
||||
public void releaseEntityFromEDGDevice(long lock, boolean forced) {
|
||||
ServerPlayer player = ServerPlayer.class.cast(this);
|
||||
Services.WORK_SPACE.tryToDoIfInDevice(player,
|
||||
data -> {
|
||||
if (data.getDeviceMainBlockPos() != null && level().getBlockEntity(data.getDeviceMainBlockPos()) instanceof BaseSeatBlockEntity seatBe) {
|
||||
if (isCreative() || (seatBe.hasLockCode() && Objects.equals(seatBe.getLockCode(), lock)) || !seatBe.hasLockCode()) {
|
||||
if (isCreative() || forced || (seatBe.hasLockCode() && Objects.equals(seatBe.getLockCode(), lock)) || !seatBe.hasLockCode()) {
|
||||
Entity entity = this.getVehicle();
|
||||
this.removeVehicle();
|
||||
if (entity != null && entity != this.getVehicle() && !this.level().isClientSide) {
|
||||
|
|
|
|||
|
|
@ -17,9 +17,16 @@
|
|||
package top.r3944realms.eroticdungeongame.util;
|
||||
|
||||
public interface IEDGEntity {
|
||||
void releaseEntityFromEDGDevice(long lock);
|
||||
default void releaseEntityFromEDGDevice(long lock) {
|
||||
releaseEntityFromEDGDevice(lock, false);
|
||||
}
|
||||
default void releaseEntityFromEDGDevice(boolean force) {
|
||||
releaseEntityFromEDGDevice(-1, force);
|
||||
}
|
||||
void releaseEntityFromEDGDevice(long lock, boolean force);
|
||||
|
||||
default void releaseEntityFromEDGDevice() {
|
||||
releaseEntityFromEDGDevice(-1);
|
||||
releaseEntityFromEDGDevice(false);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user