-
-
Notifications
You must be signed in to change notification settings - Fork 103
/
WorldHelperImpl.java
31 lines (26 loc) · 1.21 KB
/
WorldHelperImpl.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package com.denizenscript.denizen.nms.v1_17.helpers;
import com.denizenscript.denizen.nms.interfaces.WorldHelper;
import com.denizenscript.denizencore.utilities.ReflectionHelper;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.DifficultyInstance;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_17_R1.CraftWorld;
public class WorldHelperImpl implements WorldHelper {
@Override
public boolean isStatic(World world) {
return ((CraftWorld) world).getHandle().isClientSide;
}
@Override
public void setStatic(World world, boolean isStatic) {
ServerLevel worldServer = ((CraftWorld) world).getHandle();
ReflectionHelper.setFieldValue(net.minecraft.world.level.Level.class, "isClientSide", worldServer, isStatic);
}
@Override
public float getLocalDifficulty(Location location) {
BlockPos pos = new BlockPos(location.getBlockX(), location.getBlockY(), location.getBlockZ());
DifficultyInstance scaler = ((CraftWorld) location.getWorld()).getHandle().getCurrentDifficultyAt(pos);
return scaler.getEffectiveDifficulty();
}
}