Skip to content

Commit

Permalink
compilability fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Oct 23, 2019
1 parent 6681e07 commit 37ba7b0
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 12 deletions.
Expand Up @@ -2,8 +2,10 @@

import com.denizenscript.denizen.nms.NMSHandler;
import com.denizenscript.denizen.nms.abstracts.BlockLight;
import com.denizenscript.denizen.utilities.blocks.ChunkCoordinate;
import com.denizenscript.denizencore.utilities.debugging.Debug;
import net.minecraft.server.v1_12_R1.*;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
Expand Down Expand Up @@ -47,9 +49,13 @@ public class BlockLightImpl extends BlockLight {
bukkitTask = new BukkitRunnable() {
@Override
public void run() {
for (Map.Entry<org.bukkit.Chunk, List<BlockLight>> entry : lightsByChunk.entrySet()) {
org.bukkit.Chunk chunk = entry.getKey();
if (chunk.isLoaded()) {
for (Map.Entry<ChunkCoordinate, List<BlockLight>> entry : lightsByChunk.entrySet()) {
ChunkCoordinate coord = entry.getKey();
World world = Bukkit.getWorld(coord.worldName);
if (world == null) {
continue;
}
if (world.isChunkLoaded(coord.x, coord.z)) {
List<BlockLight> blockLights = entry.getValue();
if (blockLights.isEmpty()) {
continue;
Expand All @@ -58,6 +64,7 @@ public void run() {
for (BlockLight light : blockLights) {
light.reset(false);
}
org.bukkit.Chunk chunk = world.getChunkAt(coord.x, coord.z);
updateChunk(chunk, playerChunkMap);
for (BlockLight light : blockLights) {
light.update(light.cachedLight, false);
Expand Down Expand Up @@ -100,10 +107,10 @@ public static BlockLight createLight(Location location, int lightLevel, long tic
else {
blockLight = new BlockLightImpl(location, ticks);
lightsByLocation.put(location, blockLight);
if (!lightsByChunk.containsKey(blockLight.chunk)) {
lightsByChunk.put(blockLight.chunk, new ArrayList<>());
if (!lightsByChunk.containsKey(blockLight.chunkCoord)) {
lightsByChunk.put(blockLight.chunkCoord, new ArrayList<>());
}
lightsByChunk.get(blockLight.chunk).add(blockLight);
lightsByChunk.get(blockLight.chunkCoord).add(blockLight);
}
blockLight.update(lightLevel, true);
return blockLight;
Expand Down
Expand Up @@ -2,8 +2,10 @@

import com.denizenscript.denizen.nms.NMSHandler;
import com.denizenscript.denizen.nms.abstracts.BlockLight;
import com.denizenscript.denizen.utilities.blocks.ChunkCoordinate;
import com.denizenscript.denizencore.utilities.debugging.Debug;
import net.minecraft.server.v1_13_R2.*;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
Expand Down Expand Up @@ -48,9 +50,13 @@ public class BlockLightImpl extends BlockLight {
bukkitTask = new BukkitRunnable() {
@Override
public void run() {
for (Map.Entry<org.bukkit.Chunk, List<BlockLight>> entry : lightsByChunk.entrySet()) {
org.bukkit.Chunk chunk = entry.getKey();
if (chunk.isLoaded()) {
for (Map.Entry<ChunkCoordinate, List<BlockLight>> entry : lightsByChunk.entrySet()) {
ChunkCoordinate coord = entry.getKey();
World world = Bukkit.getWorld(coord.worldName);
if (world == null) {
continue;
}
if (world.isChunkLoaded(coord.x, coord.z)) {
List<BlockLight> blockLights = entry.getValue();
if (blockLights.isEmpty()) {
continue;
Expand All @@ -59,6 +65,7 @@ public void run() {
for (BlockLight light : blockLights) {
light.reset(false);
}
org.bukkit.Chunk chunk = world.getChunkAt(coord.x, coord.z);
updateChunk(chunk, playerChunkMap);
for (BlockLight light : blockLights) {
light.update(light.cachedLight, false);
Expand Down Expand Up @@ -101,10 +108,10 @@ public static BlockLight createLight(Location location, int lightLevel, long tic
else {
blockLight = new BlockLightImpl(location, ticks);
lightsByLocation.put(location, blockLight);
if (!lightsByChunk.containsKey(blockLight.chunk)) {
lightsByChunk.put(blockLight.chunk, new ArrayList<>());
if (!lightsByChunk.containsKey(blockLight.chunkCoord)) {
lightsByChunk.put(blockLight.chunkCoord, new ArrayList<>());
}
lightsByChunk.get(blockLight.chunk).add(blockLight);
lightsByChunk.get(blockLight.chunkCoord).add(blockLight);
}
blockLight.update(lightLevel, true);
return blockLight;
Expand Down
Expand Up @@ -83,6 +83,7 @@ public static int getWidthFor(int value) {

public static void handleMapChunkPacket(PacketPlayOutMapChunk packet, List<FakeBlock> blocks) {
try {
// TODO: properly update HeightMap and BlockEntities?
int bitmask = BITMASK_MAPCHUNK.getInt(packet);
byte[] data = (byte[]) DATA_MAPCHUNK.get(packet);
PacketDataSerializer serial = new PacketDataSerializer(Unpooled.wrappedBuffer(data));
Expand Down

0 comments on commit 37ba7b0

Please sign in to comment.