-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
528 additions
and
171 deletions.
There are no files selected for viewing
48 changes: 24 additions & 24 deletions
48
src/main/java/net/gensokyoreimagined/nitori/common/world/chunk/ChunkStatusTracker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,26 @@ | ||
package net.gensokyoreimagined.nitori.common.world.chunk; | ||
|
||
import net.minecraft.server.level.FullChunkStatus; | ||
import net.minecraft.server.level.ServerLevel; | ||
import net.minecraft.world.level.ChunkPos; | ||
|
||
import java.util.ArrayList; | ||
import java.util.function.BiConsumer; | ||
|
||
public class ChunkStatusTracker { | ||
|
||
//Add other callback types in the future when needed | ||
private static final ArrayList<BiConsumer<ServerLevel, ChunkPos>> UNLOAD_CALLBACKS = new ArrayList<>(); | ||
public static void onChunkStatusChange(ServerLevel serverWorld, ChunkPos pos, FullChunkStatus levelType) { | ||
boolean loaded = levelType.isOrAfter(FullChunkStatus.FULL); | ||
if (!loaded) { | ||
for (int i = 0; i < UNLOAD_CALLBACKS.size(); i++) { | ||
UNLOAD_CALLBACKS.get(i).accept(serverWorld, pos); | ||
} | ||
} | ||
} | ||
|
||
public static void registerUnloadCallback(BiConsumer<ServerLevel, ChunkPos> callback) { | ||
UNLOAD_CALLBACKS.add(callback); | ||
} | ||
} | ||
//import net.minecraft.server.level.FullChunkStatus; | ||
//import net.minecraft.server.level.ServerLevel; | ||
//import net.minecraft.world.level.ChunkPos; | ||
// | ||
//import java.util.ArrayList; | ||
//import java.util.function.BiConsumer; | ||
// | ||
//public class ChunkStatusTracker { | ||
// | ||
// //Add other callback types in the future when needed | ||
// private static final ArrayList<BiConsumer<ServerLevel, ChunkPos>> UNLOAD_CALLBACKS = new ArrayList<>(); | ||
// public static void onChunkStatusChange(ServerLevel serverWorld, ChunkPos pos, FullChunkStatus levelType) { | ||
// boolean loaded = levelType.isOrAfter(FullChunkStatus.FULL); | ||
// if (!loaded) { | ||
// for (int i = 0; i < UNLOAD_CALLBACKS.size(); i++) { | ||
// UNLOAD_CALLBACKS.get(i).accept(serverWorld, pos); | ||
// } | ||
// } | ||
// } | ||
// | ||
// public static void registerUnloadCallback(BiConsumer<ServerLevel, ChunkPos> callback) { | ||
// UNLOAD_CALLBACKS.add(callback); | ||
// } | ||
//} |
48 changes: 48 additions & 0 deletions
48
...in/java/net/gensokyoreimagined/nitori/common/world/listeners/WorldBorderListenerOnce.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package net.gensokyoreimagined.nitori.common.world.listeners; | ||
|
||
import net.minecraft.world.level.border.WorldBorder; | ||
import net.minecraft.world.level.border.BorderChangeListener; | ||
|
||
public interface WorldBorderListenerOnce extends BorderChangeListener { | ||
|
||
void lithium$onWorldBorderShapeChange(WorldBorder worldBorder); | ||
|
||
default void onAreaReplaced(WorldBorder border) { | ||
this.lithium$onWorldBorderShapeChange(border); | ||
} | ||
|
||
@Override | ||
default void onBorderSizeSet(WorldBorder border, double size) { | ||
this.lithium$onWorldBorderShapeChange(border); | ||
} | ||
|
||
@Override | ||
default void onBorderSizeLerping(WorldBorder border, double fromSize, double toSize, long time) { | ||
this.lithium$onWorldBorderShapeChange(border); | ||
} | ||
|
||
@Override | ||
default void onBorderCenterSet(WorldBorder border, double centerX, double centerZ) { | ||
this.lithium$onWorldBorderShapeChange(border); | ||
} | ||
|
||
@Override | ||
default void onBorderSetWarningTime(WorldBorder border, int warningTime) { | ||
|
||
} | ||
|
||
@Override | ||
default void onBorderSetWarningBlocks(WorldBorder border, int warningBlockDistance) { | ||
|
||
} | ||
|
||
@Override | ||
default void onBorderSetDamagePerBlock(WorldBorder border, double damagePerBlock) { | ||
|
||
} | ||
|
||
@Override | ||
default void onBorderSetDamageSafeZOne(WorldBorder border, double safeZoneRadius) { | ||
|
||
} | ||
} |
66 changes: 0 additions & 66 deletions
66
...et/gensokyoreimagined/nitori/mixin/entity/inactive_navigations/EntityNavigationMixin.java
This file was deleted.
Oops, something went wrong.
76 changes: 0 additions & 76 deletions
76
.../java/net/gensokyoreimagined/nitori/mixin/entity/inactive_navigations/MobEntityMixin.java
This file was deleted.
Oops, something went wrong.
66 changes: 66 additions & 0 deletions
66
...kyoreimagined/nitori/mixin/removed/entity/inactive_navigations/EntityNavigationMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package net.gensokyoreimagined.nitori.mixin.removed.entity.inactive_navigations; | ||
|
||
//import net.gensokyoreimagined.nitori.common.entity.NavigatingEntity; | ||
//import net.gensokyoreimagined.nitori.common.world.ServerWorldExtended; | ||
//import net.minecraft.world.entity.ai.navigation.PathNavigation; | ||
//import net.minecraft.world.level.pathfinder.Path; | ||
//import net.minecraft.world.entity.Mob; | ||
//import net.minecraft.world.level.Level; | ||
//import org.spongepowered.asm.mixin.Final; | ||
//import org.spongepowered.asm.mixin.Mixin; | ||
//import org.spongepowered.asm.mixin.Shadow; | ||
//import org.spongepowered.asm.mixin.injection.At; | ||
//import org.spongepowered.asm.mixin.injection.Inject; | ||
//import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
//import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
// | ||
//@Mixin(PathNavigation.class) | ||
//public abstract class EntityNavigationMixin { | ||
// | ||
// @Shadow | ||
// @Final | ||
// protected Level level; | ||
// | ||
// @Shadow | ||
// protected Path path; | ||
// | ||
// @Shadow | ||
// @Final | ||
// protected Mob mob; | ||
// | ||
// @Inject( | ||
// method = "recomputePath", | ||
// at = @At( | ||
// value = "INVOKE_ASSIGN", | ||
// target = "Lnet/minecraft/world/entity/ai/navigation/PathNavigation;createPath(Lnet/minecraft/core/BlockPos;I)Lnet/minecraft/world/level/pathfinder/Path;", | ||
// shift = At.Shift.AFTER | ||
// ) | ||
// ) | ||
// private void updateListeningState(CallbackInfo ci) { | ||
// if (((NavigatingEntity) this.mob).lithium$isRegisteredToWorld()) { | ||
// if (this.path == null) { | ||
// ((ServerWorldExtended) this.level).lithium$setNavigationInactive(this.mob); | ||
// } else { | ||
// ((ServerWorldExtended) this.level).lithium$setNavigationActive(this.mob); | ||
// } | ||
// } | ||
// } | ||
// | ||
// @Inject(method = "moveTo(Lnet/minecraft/world/level/pathfinder/Path;D)Z", at = @At(value = "RETURN")) | ||
// private void updateListeningState2(Path path, double speed, CallbackInfoReturnable<Boolean> cir) { | ||
// if (((NavigatingEntity) this.mob).lithium$isRegisteredToWorld()) { | ||
// if (this.path == null) { | ||
// ((ServerWorldExtended) this.level).lithium$setNavigationInactive(this.mob); | ||
// } else { | ||
// ((ServerWorldExtended) this.level).lithium$setNavigationActive(this.mob); | ||
// } | ||
// } | ||
// } | ||
// | ||
// @Inject(method = "stop", at = @At(value = "RETURN")) | ||
// private void stopListening(CallbackInfo ci) { | ||
// if (((NavigatingEntity) this.mob).lithium$isRegisteredToWorld()) { | ||
// ((ServerWorldExtended) this.level).lithium$setNavigationInactive(this.mob); | ||
// } | ||
// } | ||
//} |
76 changes: 76 additions & 0 deletions
76
...t/gensokyoreimagined/nitori/mixin/removed/entity/inactive_navigations/MobEntityMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package net.gensokyoreimagined.nitori.mixin.removed.entity.inactive_navigations; | ||
|
||
//import net.gensokyoreimagined.nitori.common.entity.NavigatingEntity; | ||
//import net.gensokyoreimagined.nitori.common.world.ServerWorldExtended; | ||
//import net.minecraft.world.entity.Entity; | ||
//import net.minecraft.world.entity.EntityType; | ||
//import net.minecraft.world.entity.ai.navigation.PathNavigation; | ||
//import net.minecraft.world.entity.Mob; | ||
//import net.minecraft.world.level.Level; | ||
//import org.spongepowered.asm.mixin.Intrinsic; | ||
//import org.spongepowered.asm.mixin.Mixin; | ||
//import org.spongepowered.asm.mixin.Shadow; | ||
//import org.spongepowered.asm.mixin.injection.At; | ||
//import org.spongepowered.asm.mixin.injection.Inject; | ||
//import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
//import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
// | ||
//@Mixin(Mob.class) | ||
//public abstract class MobEntityMixin extends Entity implements NavigatingEntity { | ||
// private PathNavigation nitori$registeredNavigation; | ||
// | ||
// public MobEntityMixin(EntityType<?> type, Level world) { | ||
// super(type, world); | ||
// } | ||
// | ||
// @Shadow | ||
// public abstract PathNavigation getNavigation(); | ||
// | ||
// @Override | ||
// public boolean lithium$isRegisteredToWorld() { | ||
// return this.nitori$registeredNavigation != null; | ||
// } | ||
// | ||
// @Override | ||
// public void lithium$setRegisteredToWorld(PathNavigation navigation) { | ||
// this.nitori$registeredNavigation = navigation; | ||
// } | ||
// | ||
// @Override | ||
// public PathNavigation lithium$getRegisteredNavigation() { | ||
// return this.nitori$registeredNavigation; | ||
// } | ||
// | ||
// @Inject(method = "startRiding", at = @At("RETURN")) | ||
// private void onNavigationReplacement(Entity entity, boolean force, CallbackInfoReturnable<Boolean> cir) { | ||
// this.lithium$updateNavigationRegistration(); | ||
// } | ||
// | ||
// @Override | ||
// @Intrinsic | ||
// public void stopRiding() { | ||
// super.stopRiding(); | ||
// } | ||
// | ||
// @SuppressWarnings({"MixinAnnotationTarget", "UnresolvedMixinReference"}) | ||
// @Inject(method = "stopRiding()V", at = @At("RETURN")) | ||
// private void updateOnStopRiding(CallbackInfo ci) { | ||
// this.lithium$updateNavigationRegistration(); | ||
// } | ||
// | ||
// @Override | ||
// public void lithium$updateNavigationRegistration() { | ||
// if (this.lithium$isRegisteredToWorld()) { | ||
// PathNavigation navigation = this.getNavigation(); | ||
// if (this.nitori$registeredNavigation != navigation) { | ||
// ((ServerWorldExtended) this.level()).lithium$setNavigationInactive((Mob) (Object) this); | ||
// this.nitori$registeredNavigation = navigation; | ||
// | ||
// if (navigation.getPath() != null) { | ||
// ((ServerWorldExtended) this.level()).lithium$setNavigationActive((Mob) (Object) this); | ||
// } | ||
// } | ||
// } | ||
// } | ||
// | ||
//} |
Oops, something went wrong.