-
-
Notifications
You must be signed in to change notification settings - Fork 104
/
WorldHelperImpl.java
29 lines (24 loc) · 1.11 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
package com.denizenscript.denizen.nms.v1_15.helpers;
import com.denizenscript.denizen.nms.interfaces.WorldHelper;
import com.denizenscript.denizencore.utilities.ReflectionHelper;
import net.minecraft.server.v1_15_R1.*;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_15_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) {
WorldServer worldServer = ((CraftWorld) world).getHandle();
ReflectionHelper.setFieldValue(net.minecraft.server.v1_15_R1.World.class, "isClientSide", worldServer, isStatic);
}
@Override
public float getLocalDifficulty(Location location) {
BlockPosition pos = new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ());
DifficultyDamageScaler scaler = ((CraftWorld) location.getWorld()).getHandle().getDamageScaler(pos);
return scaler.b();
}
}