Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Roelymole committed Dec 19, 2024
2 parents b7eb6b4 + 197f77e commit 39cc52d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@

public interface CryogenicAccessor {

default void beginCyroSleep() {
default void beginCryoSleep() {
throw new RuntimeException("This should be overridden by mixin!");
}

default void endCyroSleep() {
default void endCryoSleep() {
throw new RuntimeException("This should be overridden by mixin!");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,12 @@ public InteractionResult multiBlockUseWithoutItem(BlockState baseState, Level le
if (level.isClientSide()) return InteractionResult.CONSUME;

if(player.getCryogenicChamberCooldown() == 0) {
player.beginCyroSleep();
player.beginCryoSleep();

player.startSleepInBed(basePos).ifLeft(problem -> {
if (problem.getMessage() != null) player.displayClientMessage(problem.getMessage(), true);

player.endCyroSleep();
player.endCryoSleep();
});
} else {
player.displayClientMessage(Component.literal("The chamber is way to hot right now! It needs " + player.getCryogenicChamberCooldown() + " seconds to cool down before I sleep again."), false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public static InteractionResult canCryoSleep(Player player, BlockPos sleepingPos

public static void onWakeFromCryoSleep(LivingEntity entity, BlockPos sleepingPos) {
if (!entity.level().isClientSide() && entity.isInCryoSleep()) {
entity.endCyroSleep();
entity.endCryoSleep();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.Vec3;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
Expand All @@ -57,12 +58,12 @@ public LivingEntityMixin(EntityType<?> entityType, Level level) {
}

@Override
public void beginCyroSleep() {
public void beginCryoSleep() {
this.entityData.set(IS_IN_CRYO_SLEEP_ID, true);
}

@Override
public void endCyroSleep() {
public void endCryoSleep() {
this.entityData.set(IS_IN_CRYO_SLEEP_ID, false);
}

Expand Down Expand Up @@ -106,7 +107,8 @@ public void setCryogenicChamberCooldown(int cryogenicChamberCooldown) {
@Inject(method = "setPosToBed", at = @At("HEAD"), cancellable = true)
private void gc$setCryoSleepPos(BlockPos blockPos, CallbackInfo ci) {
if (isInCryoSleep()) {
this.setPos(blockPos.getX(), blockPos.getY() + 1F, blockPos.getZ());
Vec3 pos = blockPos.getBottomCenter();
this.setPos(pos.x, pos.y + 1F, pos.z);
ci.cancel();
}
}
Expand Down

0 comments on commit 39cc52d

Please sign in to comment.