Skip to content

Commit 0490380

Browse files
committed
improvements
1 parent 55169a0 commit 0490380

4 files changed

Lines changed: 33 additions & 11 deletions

File tree

src/main/java/org/vfast/backrooms/blocks/BackroomsPortalBlock.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public int getPortalTransitionTime(ServerLevel level, Entity entity) {
8383
assert entity.isAlive();
8484
this.prepareEntity(entity, true);
8585

86-
boolean fromLevel = currentLevel.dimension() == BackroomsLevels.LEVEL_0;
86+
boolean fromLevel = BackroomsLevels.isBackrooms(currentLevel.dimension());
8787
ResourceKey<Level> newDimension = fromLevel ? Level.OVERWORLD : BackroomsLevels.LEVEL_0;
8888
ServerLevel newLevel = currentLevel.getServer().getLevel(newDimension);
8989
if (newLevel != null) {

src/main/java/org/vfast/backrooms/blocks/FakeBlock.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import net.minecraft.world.level.block.state.BlockState;
2323
import net.minecraft.world.level.block.state.StateDefinition;
2424
import net.minecraft.world.level.block.state.properties.EnumProperty;
25+
import net.minecraft.world.level.pathfinder.PathComputationType;
2526
import net.minecraft.world.level.portal.TeleportTransition;
2627
import net.minecraft.world.phys.Vec3;
2728
import net.minecraft.world.phys.shapes.CollisionContext;
@@ -120,6 +121,11 @@ public BlockState suffocatingBlock(BlockState currentState) {
120121
return currentState.getValue(MIMIC).getBlock().defaultBlockState();
121122
}
122123

124+
@Override
125+
protected boolean isPathfindable(BlockState state, PathComputationType type) {
126+
return true;
127+
}
128+
123129
enum Mimic implements StringRepresentable {
124130
GRASS,
125131
SAND;

src/main/java/org/vfast/backrooms/mixins/ServerPlayerMixins.java

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,19 @@ public ServerPlayerMixins(Level level, GameProfile gameProfile) {
5454
@Inject(method = "tick", at = @At(value = "HEAD"))
5555
private void backroomsTick(CallbackInfo ci) {
5656
boolean fullyImmersed = this.level().getGameRules().get(BackroomsGameRules.FULL_IMMERSION);
57-
ResourceKey<Level> levelKey = this.level().dimension();
5857

59-
boolean canNoclip = !this.lookingForNoclip && this.tickCount >= this.lastNoclipTick + Noclippable.NOCLIP_TICKS && !this.getAbilities().invulnerable;
58+
if (fullyImmersed) {
59+
ResourceKey<Level> levelKey = this.level().dimension();
60+
61+
boolean canNoclip = !this.lookingForNoclip && this.tickCount >= this.lastNoclipTick + Noclippable.NOCLIP_TICKS && !this.getAbilities().invulnerable;
6062

61-
if (levelKey == BackroomsLevels.LEVEL_0 && fullyImmersed) {
62-
this.tickDarkness();
63-
this.tickFood();
64-
} else if (levelKey == Level.OVERWORLD && fullyImmersed && canNoclip) {
65-
this.lookingForNoclip = true;
66-
this.tickNoclip();
63+
this.tickFood(levelKey);
64+
if (levelKey == BackroomsLevels.LEVEL_0) {
65+
this.tickDarkness();
66+
} else if (levelKey == Level.OVERWORLD && canNoclip) {
67+
this.lookingForNoclip = true;
68+
this.tickNoclip();
69+
}
6770
}
6871
}
6972

@@ -148,8 +151,10 @@ private int getDarknessDuration() {
148151
}
149152

150153
@Unique
151-
private void tickFood() {
152-
this.foodData.setFoodLevel(20);
154+
private void tickFood(ResourceKey<Level> dimension) {
155+
if (BackroomsLevels.isBackrooms(dimension)) {
156+
this.foodData.setFoodLevel(20);
157+
}
153158
}
154159

155160
@Inject(method = "stopSleepInBed", at = @At(value = "HEAD"))

src/main/java/org/vfast/backrooms/world/BackroomsLevels.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@
66
import net.minecraft.world.level.Level;
77
import org.vfast.backrooms.BackroomsMod;
88

9+
import java.util.List;
10+
911
public class BackroomsLevels {
12+
private static final List<ResourceKey<Level>> BACKROOM_LEVELS;
1013
public static final ResourceKey<Level> LEVEL_0 = ResourceKey.create(Registries.DIMENSION, Identifier.fromNamespaceAndPath(BackroomsMod.ID, "level_0"));
14+
15+
public static boolean isBackrooms(ResourceKey<Level> level) {
16+
return BACKROOM_LEVELS.contains(level);
17+
}
18+
19+
static {
20+
BACKROOM_LEVELS = List.of(BackroomsLevels.LEVEL_0);
21+
}
1122
}

0 commit comments

Comments
 (0)