Temporary solution to LightEngine ArrayIndexOutOfBounds error

This commit is contained in:
LOOHP 2021-03-16 20:44:26 +08:00
parent 5be44b597a
commit e8a7d68e3b
6 changed files with 29 additions and 26 deletions

View File

@ -3,8 +3,9 @@ package com.loohp.limbo.Entity;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import com.loohp.limbo.Utils.NamespacedKey;
import com.loohp.limbo.Player.Player; import com.loohp.limbo.Player.Player;
import com.loohp.limbo.Utils.NamespacedKey;
import com.loohp.limbo.World.World;
public enum EntityType { public enum EntityType {

View File

@ -7,12 +7,12 @@ import com.loohp.limbo.World.World;
public class Location implements Cloneable { public class Location implements Cloneable {
World world; private World world;
double x; private double x;
double y; private double y;
double z; private double z;
float yaw; private float yaw;
float pitch; private float pitch;
public Location(World world, double x, double y, double z, float yaw, float pitch) { public Location(World world, double x, double y, double z, float yaw, float pitch) {
this.world = world; this.world = world;

View File

@ -16,9 +16,9 @@ import com.loohp.limbo.Location.Location;
import com.loohp.limbo.Server.ClientConnection; import com.loohp.limbo.Server.ClientConnection;
import com.loohp.limbo.Server.Packets.PacketPlayOutChat; import com.loohp.limbo.Server.Packets.PacketPlayOutChat;
import com.loohp.limbo.Server.Packets.PacketPlayOutGameState; import com.loohp.limbo.Server.Packets.PacketPlayOutGameState;
import com.loohp.limbo.Server.Packets.PacketPlayOutHeldItemChange;
import com.loohp.limbo.Server.Packets.PacketPlayOutPositionAndLook; import com.loohp.limbo.Server.Packets.PacketPlayOutPositionAndLook;
import com.loohp.limbo.Server.Packets.PacketPlayOutRespawn; import com.loohp.limbo.Server.Packets.PacketPlayOutRespawn;
import com.loohp.limbo.Server.Packets.PacketPlayOutHeldItemChange;
import com.loohp.limbo.Utils.GameMode; import com.loohp.limbo.Utils.GameMode;
import net.md_5.bungee.api.chat.BaseComponent; import net.md_5.bungee.api.chat.BaseComponent;

View File

@ -22,8 +22,8 @@ import com.loohp.limbo.Events.PlayerJoinEvent;
import com.loohp.limbo.Events.PlayerLoginEvent; import com.loohp.limbo.Events.PlayerLoginEvent;
import com.loohp.limbo.Events.PlayerMoveEvent; import com.loohp.limbo.Events.PlayerMoveEvent;
import com.loohp.limbo.Events.PlayerQuitEvent; import com.loohp.limbo.Events.PlayerQuitEvent;
import com.loohp.limbo.Events.StatusPingEvent;
import com.loohp.limbo.Events.PlayerSelectedSlotChangeEvent; import com.loohp.limbo.Events.PlayerSelectedSlotChangeEvent;
import com.loohp.limbo.Events.StatusPingEvent;
import com.loohp.limbo.File.ServerProperties; import com.loohp.limbo.File.ServerProperties;
import com.loohp.limbo.Location.Location; import com.loohp.limbo.Location.Location;
import com.loohp.limbo.Player.Player; import com.loohp.limbo.Player.Player;
@ -35,6 +35,7 @@ import com.loohp.limbo.Server.Packets.PacketLoginOutDisconnect;
import com.loohp.limbo.Server.Packets.PacketLoginOutLoginSuccess; import com.loohp.limbo.Server.Packets.PacketLoginOutLoginSuccess;
import com.loohp.limbo.Server.Packets.PacketOut; import com.loohp.limbo.Server.Packets.PacketOut;
import com.loohp.limbo.Server.Packets.PacketPlayInChat; import com.loohp.limbo.Server.Packets.PacketPlayInChat;
import com.loohp.limbo.Server.Packets.PacketPlayInHeldItemChange;
import com.loohp.limbo.Server.Packets.PacketPlayInKeepAlive; import com.loohp.limbo.Server.Packets.PacketPlayInKeepAlive;
import com.loohp.limbo.Server.Packets.PacketPlayInPosition; import com.loohp.limbo.Server.Packets.PacketPlayInPosition;
import com.loohp.limbo.Server.Packets.PacketPlayInPositionAndLook; import com.loohp.limbo.Server.Packets.PacketPlayInPositionAndLook;
@ -43,6 +44,7 @@ import com.loohp.limbo.Server.Packets.PacketPlayInTabComplete;
import com.loohp.limbo.Server.Packets.PacketPlayOutDeclareCommands; import com.loohp.limbo.Server.Packets.PacketPlayOutDeclareCommands;
import com.loohp.limbo.Server.Packets.PacketPlayOutDisconnect; import com.loohp.limbo.Server.Packets.PacketPlayOutDisconnect;
import com.loohp.limbo.Server.Packets.PacketPlayOutEntityMetadata; import com.loohp.limbo.Server.Packets.PacketPlayOutEntityMetadata;
import com.loohp.limbo.Server.Packets.PacketPlayOutHeldItemChange;
import com.loohp.limbo.Server.Packets.PacketPlayOutLogin; import com.loohp.limbo.Server.Packets.PacketPlayOutLogin;
import com.loohp.limbo.Server.Packets.PacketPlayOutPlayerAbilities; import com.loohp.limbo.Server.Packets.PacketPlayOutPlayerAbilities;
import com.loohp.limbo.Server.Packets.PacketPlayOutPlayerAbilities.PlayerAbilityFlags; import com.loohp.limbo.Server.Packets.PacketPlayOutPlayerAbilities.PlayerAbilityFlags;
@ -59,8 +61,6 @@ import com.loohp.limbo.Server.Packets.PacketStatusInPing;
import com.loohp.limbo.Server.Packets.PacketStatusInRequest; import com.loohp.limbo.Server.Packets.PacketStatusInRequest;
import com.loohp.limbo.Server.Packets.PacketStatusOutPong; import com.loohp.limbo.Server.Packets.PacketStatusOutPong;
import com.loohp.limbo.Server.Packets.PacketStatusOutResponse; import com.loohp.limbo.Server.Packets.PacketStatusOutResponse;
import com.loohp.limbo.Server.Packets.PacketPlayInHeldItemChange;
import com.loohp.limbo.Server.Packets.PacketPlayOutHeldItemChange;
import com.loohp.limbo.Utils.CustomStringUtils; import com.loohp.limbo.Utils.CustomStringUtils;
import com.loohp.limbo.Utils.DataTypeIO; import com.loohp.limbo.Utils.DataTypeIO;
import com.loohp.limbo.Utils.GameMode; import com.loohp.limbo.Utils.GameMode;

View File

@ -34,17 +34,19 @@ public class LightEngineBlock extends LightEngine {
} }
private void propergate(int level, int x, int y, int z) { private void propergate(int level, int x, int y, int z) {
if (blockLightArray[x][y + 16][z] < level) { try {
blockLightArray[x][y + 16][z] = (byte) level; if (blockLightArray[x][y + 16][z] < level) {
if (level > 1) { blockLightArray[x][y + 16][z] = (byte) level;
propergate(level - 1, x + 1, y, z); if (level > 1) {
propergate(level - 1, x - 1, y, z); try {propergate(level - 1, x + 1, y, z);} catch (ArrayIndexOutOfBoundsException e) {}
propergate(level - 1, x, y + 1, z); try {propergate(level - 1, x - 1, y, z);} catch (ArrayIndexOutOfBoundsException e) {}
propergate(level - 1, x, y - 1, z); try {propergate(level - 1, x, y + 1, z);} catch (ArrayIndexOutOfBoundsException e) {}
propergate(level - 1, x, y, z + 1); try {propergate(level - 1, x, y - 1, z);} catch (ArrayIndexOutOfBoundsException e) {}
propergate(level - 1, x, y, z - 1); try {propergate(level - 1, x, y, z + 1);} catch (ArrayIndexOutOfBoundsException e) {}
try {propergate(level - 1, x, y, z - 1);} catch (ArrayIndexOutOfBoundsException e) {}
}
} }
} } catch (ArrayIndexOutOfBoundsException e) {}
} }
public List<Byte[]> getBlockLightBitMask(int chunkX, int chunkZ) { public List<Byte[]> getBlockLightBitMask(int chunkX, int chunkZ) {

View File

@ -49,11 +49,11 @@ public class LightEngineSky extends LightEngine {
if (skyLightArray[x][y + 16][z] < level) { if (skyLightArray[x][y + 16][z] < level) {
skyLightArray[x][y + 16][z] = (byte) level; skyLightArray[x][y + 16][z] = (byte) level;
if (level > 1) { if (level > 1) {
propergate(level - 1, x + 1, y, z); try {propergate(level - 1, x + 1, y, z);} catch (ArrayIndexOutOfBoundsException e) {}
propergate(level - 1, x - 1, y, z); try {propergate(level - 1, x - 1, y, z);} catch (ArrayIndexOutOfBoundsException e) {}
propergate(level - 1, x, y + 1, z); try {propergate(level - 1, x, y + 1, z);} catch (ArrayIndexOutOfBoundsException e) {}
propergate(level - 1, x, y, z + 1); try {propergate(level - 1, x, y, z + 1);} catch (ArrayIndexOutOfBoundsException e) {}
propergate(level - 1, x, y, z - 1); try {propergate(level - 1, x, y, z - 1);} catch (ArrayIndexOutOfBoundsException e) {}
} }
} }
} catch (ArrayIndexOutOfBoundsException e) {} } catch (ArrayIndexOutOfBoundsException e) {}