Skip to content

Commit

Permalink
Some Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Mgazul committed Nov 24, 2024
1 parent a9af28c commit b990fb8
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ private static double getDouble(String path, double def)
public static double WatchDogTimeOut;
public static String Watchdogtimetodo;
public static boolean spawnForChunk;
public static boolean spawnForNatural;
public static boolean NoRaining;
public static boolean SkyLight15;

public static boolean networkmanager_debug;
public static List<String> networkmanager_intercept;
Expand All @@ -164,6 +166,7 @@ private static void banner() {
server_thread = getInt("threadpriority.server_thread", 8);
nospawnEntity = getList("entity.nospawn", Collections.emptyList());
spawnForChunk = getBoolean("entity.spawnForChunk", true);
spawnForNatural = getBoolean("entity.spawnForNatural", true);
clear_item = getBoolean("entity.clear.item.enable", false);
clear_item__whitelist = getList("entity.clear.item.whitelist", Collections.emptyList());
clear_item__msg = getString("entity.clear.item.msg", "[Server] Cleaned up %size% drops");
Expand All @@ -178,5 +181,6 @@ private static void banner() {
networkmanager_debug = getBoolean("networkmanager.debug", false);
networkmanager_intercept = getList("networkmanager.intercept", Collections.emptyList());
Watchdogtimetodo = getString("Watchdogtimetodo", "restart");
SkyLight15 = getBoolean("SkyLight15", false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -375,12 +375,21 @@ public <T extends ParticleOptions> int sendParticles(T type, double posX, double
return this.sendParticles(type, posX, posY, posZ, particleCount, xOffset, yOffset, zOffset, speed);
}

@Inject(method = "addEntity", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/entity/PersistentEntitySectionManager;addNewEntity(Lnet/minecraft/world/level/entity/EntityAccess;)Z"))
private void banner$addEntityEvent(Entity entityIn, CallbackInfoReturnable<Boolean> cir) {
@Inject(method = "addEntity", cancellable = true, at = @At(value = "HEAD"))
private void banner$canAddEntity(Entity entityIn, CallbackInfoReturnable<Boolean> cir) {
CreatureSpawnEvent.SpawnReason reason = banner$reason.get() == null ? CreatureSpawnEvent.SpawnReason.DEFAULT : banner$reason.get();
if (!BannerConfig.spawnForChunk && (reason.equals(SpawnReason.NATURAL) || reason.equals(SpawnReason.CHUNK_GEN))) {
if (!BannerConfig.spawnForChunk && reason.equals(SpawnReason.CHUNK_GEN)) {
cir.setReturnValue(false);
}

if (!BannerConfig.spawnForNatural && reason.equals(SpawnReason.NATURAL)) {
cir.setReturnValue(false);
}
}

@Inject(method = "addEntity", cancellable = true, at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/entity/PersistentEntitySectionManager;addNewEntity(Lnet/minecraft/world/level/entity/EntityAccess;)Z"))
private void banner$addEntityEvent(Entity entityIn, CallbackInfoReturnable<Boolean> cir) {
CreatureSpawnEvent.SpawnReason reason = banner$reason.get() == null ? CreatureSpawnEvent.SpawnReason.DEFAULT : banner$reason.get();
banner$reason.set(null);
if (DistValidate.isValid((LevelAccessor) this) && !CraftEventFactory.doEntityAddEventCalling((ServerLevel) (Object) this, entityIn, reason)) {
cir.setReturnValue(false);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.mohistmc.banner.mixin.world.level.lighting;

import net.minecraft.world.level.lighting.SkyLightSectionStorage;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(SkyLightSectionStorage.class)
public class MixinSkyLightSectionStorage {

/**
* @author Mgazul
* @reason Mandatory 15
*/
@Inject(method = "getLightValue(JZ)I", cancellable = true, at = @At(value = "HEAD"))
protected void getLightValue(long packedPos, boolean updateAll, CallbackInfoReturnable<Integer> cir) {
cir.setReturnValue(15);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ public static void spawnForChunk(ServerLevel worldserver, LevelChunk chunk, Natu
*/
@Overwrite
public static void spawnCategoryForPosition(MobCategory category, ServerLevel level, ChunkAccess chunk, BlockPos pos, NaturalSpawner.SpawnPredicate filter, NaturalSpawner.AfterSpawnCallback callback) {
if (!BannerConfig.spawnForNatural) return;
StructureManager structuremanager = level.structureManager();
ChunkGenerator chunkgenerator = level.getChunkSource().getGenerator();
int i = pos.getY();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -908,6 +908,11 @@ public boolean teleport(Location location, PlayerTeleportEvent.TeleportCause cau
Preconditions.checkArgument(location.getWorld() != null, "location.world");
location.checkFinite();

// TODO Fix chunk loading
if (!location.getChunk().isLoaded()) {
location.getChunk().load();
}

ServerPlayer entity = getHandle();

if (getHealth() == 0 || entity.isRemoved()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,7 @@
"world.level.storage.loot.functions.MixinLootingEnchantFunction",
"world.level.storage.loot.parameters.LootParametersMixin",
"world.level.storage.loot.predicates.MixinExplosionCondition",
"world.level.storage.loot.predicates.MixinRandomChanceWithLootingCondition"
"world.level.storage.loot.predicates.MixinRandomChanceWithLootingCondition",
"world.level.lighting.MixinSkyLightSectionStorage"
]
}

0 comments on commit b990fb8

Please sign in to comment.