}
@Override
- public void setSeed(long seed) {
+ protected void setSeed(long seed) {
super.setSeed(seed);
SlimeChunkProvider.setSeed(seed);
}
@Override
protected void setWorldSpawn(int spawnX, int spawnZ) {
super.setWorldSpawn(spawnX, spawnZ);
- WorldSpawnProvider.setWorldSpan(spawnX, spawnZ);
+ WorldSpawnProvider.setWorldSpawn(spawnX, spawnZ);
}
}
private static final Map<Class<? extends AbstractBoundingBox>, AbstractRenderer> boundingBoxRendererMap = new HashMap<>();
private static boolean active;
- private static Set<IBoundingBoxProvider> providers = new HashSet<>();
+ private static final Set<IBoundingBoxProvider> providers = new HashSet<>();
public static boolean getActive() {
return active;
import net.minecraft.util.text.TextComponentString;
public class SeedCommand {
+ private static final String COMMAND = "bbor:seed";
+ private static final String SEED = "seed";
+
public static void register(CommandDispatcher<ISuggestionProvider> commandDispatcher) {
- LiteralArgumentBuilder command = Commands.literal("bbor:seed")
- .then(Commands.argument("seed", StringArgumentType.string())
+ LiteralArgumentBuilder command = Commands.literal(COMMAND)
+ .then(Commands.argument(SEED, StringArgumentType.string())
.executes(context -> {
- String argument = StringArgumentType.getString(context, "seed");
+ String argument = StringArgumentType.getString(context, SEED);
handleSeedCommand(argument);
return 0;
}))
class IntSettingSlider extends AbstractSlider implements IRenderableControl {
private final String prefix;
- private Map<Integer, String> displayValues = new HashMap<>();
+ private final Map<Integer, String> displayValues = new HashMap<>();
final Setting<Integer> setting;
final int minValue;
public Key getKey() {
return key;
}
-}
\ No newline at end of file
+}
public class Key {
private int keyCode;
private KeyHandler onKeyPress;
- private Set<Key> subKeys = new HashSet<>();
+ private final Set<Key> subKeys = new HashSet<>();
private boolean triggeredSincePress;
Key(int keyCode) {
public class KeyListener {
private static final Minecraft minecraft = Minecraft.getInstance();
private static long mainWindowHandle;
- private static Set<Key> keys = new HashSet<>();
- private static Set<CustomKeyBinding> keyBindings = new HashSet<>();
+ private static final Set<Key> keys = new HashSet<>();
+ private static final Set<CustomKeyBinding> keyBindings = new HashSet<>();
public static final String Category = "Bounding Box Outline Reloaded";
public static void init() {
import java.util.concurrent.ConcurrentHashMap;
public class BeaconProvider implements IBoundingBoxProvider<BoundingBoxBeacon> {
- private static Map<Integer, Map<Coords, BoundingBoxBeacon>> dimensionsCache = buildBeaconsCache();
+ private static final Map<Integer, Map<Coords, BoundingBoxBeacon>> dimensionsCache = buildBeaconsCache();
private static Map<Integer, Map<Coords, BoundingBoxBeacon>> buildBeaconsCache() {
Map<Integer, Map<Coords, BoundingBoxBeacon>> map = new HashMap<>();
import java.util.concurrent.ConcurrentHashMap;
public class CustomBoxProvider implements IBoundingBoxProvider<BoundingBoxCuboid> {
- private static Map<Integer, Map<Integer, BoundingBoxCuboid>> dimensionCache = buildDimensionCache();
+ private static final Map<Integer, Map<Integer, BoundingBoxCuboid>> dimensionCache = buildDimensionCache();
private static Map<Integer, Map<Integer, BoundingBoxCuboid>> buildDimensionCache() {
Map<Integer, Map<Integer, BoundingBoxCuboid>> map = new HashMap<>();
}
};
}
- };
+ }
static <T extends AbstractBoundingBox> Iterable<T> empty() {
return new Empty<>();
return SpawningSphereHelper.findSpawnableSpaces(center, center.getCoords(), size, size, (x, y, z) -> true);
}
- private static Iterable<BoundingBoxSpawningSphere> iterable = Iterators.singleton(() -> spawningSphere);
+ private static final Iterable<BoundingBoxSpawningSphere> iterable = Iterators.singleton(() -> spawningSphere);
public Iterable<BoundingBoxSpawningSphere> get(int dimensionId) {
if(spawningSphere == null || SpawningSphereProvider.dimensionId != dimensionId) {
}
return iterable;
}
-}
\ No newline at end of file
+}
private static final double CHUNK_SIZE = 16d;
private static Set<BoundingBoxWorldSpawn> spawnChunks = new HashSet<>();
- public static void setWorldSpan(int spawnX, int spawnZ) {
+ public static void setWorldSpawn(int spawnX, int spawnZ) {
spawnChunks = getSpawnChunkBoundingBoxes(spawnX, spawnZ);
}
import java.util.Set;
public abstract class AbstractRenderer<T extends AbstractBoundingBox> {
- private static double TAU = 6.283185307179586D;
- private static double PI = TAU / 2D;
+ private static final double TAU = 6.283185307179586D;
+ private static final double PI = TAU / 2D;
public abstract void render(T boundingBox);
return new OffsetBox(min.offset(x, y, z), max.offset(x, y, z));
}
-
OffsetBox nudge() {
double growXZ = 0.001F;
if (min.getY() == max.getY()) {
return new Renderer(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);
}
- private Tessellator tessellator;
- private BufferBuilder bufferBuilder;
+ private final Tessellator tessellator;
+ private final BufferBuilder bufferBuilder;
private int red;
private int green;
Integer spawnableSpacesCount = boundingBox.getSpawnableSpacesCount();
if (spawnableSpacesCount != null) {
- renderText(sphereCenter, "Spawnable", spawnableSpacesCount == 0 ? "None" : String.format("%,d", (int) spawnableSpacesCount));
+ renderText(sphereCenter, "Spawnable", spawnableSpacesCount == 0 ? "None" : String.format("%,d", spawnableSpacesCount));
}
renderSphere(sphereCenter, BoundingBoxSpawningSphere.SAFE_RADIUS, Color.GREEN, 5, 5);
import java.util.concurrent.ConcurrentHashMap;
public class BoundingBoxCache {
- private Map<AbstractBoundingBox, Set<AbstractBoundingBox>> cache = new ConcurrentHashMap<>();
+ private final Map<AbstractBoundingBox, Set<AbstractBoundingBox>> cache = new ConcurrentHashMap<>();
public Map<AbstractBoundingBox, Set<AbstractBoundingBox>> getBoundingBoxes() {
return cache;
import java.util.Map;
public class BoundingBoxType {
- private final static Map<Integer, BoundingBoxType> structureTypeMap = new HashMap<>();
+ private static final Map<Integer, BoundingBoxType> structureTypeMap = new HashMap<>();
- public final static BoundingBoxType JungleTemple = register(Colors.DARK_GREEN, "Jungle_Pyramid", ConfigManager.drawJungleTemples);
- public final static BoundingBoxType DesertTemple = register(Color.ORANGE, "Desert_Pyramid", ConfigManager.drawDesertTemples);
- public final static BoundingBoxType WitchHut = register(Color.BLUE, "Swamp_Hut", ConfigManager.drawWitchHuts);
- public final static BoundingBoxType OceanMonument = register(Color.CYAN, "Monument", ConfigManager.drawOceanMonuments);
- public final static BoundingBoxType Shipwreck = register(Color.CYAN, "Shipwreck", ConfigManager.drawShipwrecks);
- public final static BoundingBoxType OceanRuin = register(Color.CYAN, "Ocean_Ruin", ConfigManager.drawOceanRuins);
- public final static BoundingBoxType BuriedTreasure = register(Color.CYAN, "Buried_Treasure", ConfigManager.drawBuriedTreasure);
- public final static BoundingBoxType Stronghold = register(Color.YELLOW, "Stronghold", ConfigManager.drawStrongholds);
- public final static BoundingBoxType MineShaft = register(Color.LIGHT_GRAY, "Mineshaft", ConfigManager.drawMineShafts);
- public final static BoundingBoxType NetherFortress = register(Color.RED, "Fortress", ConfigManager.drawNetherFortresses);
- public final static BoundingBoxType EndCity = register(Color.MAGENTA, "EndCity", ConfigManager.drawEndCities);
- public final static BoundingBoxType Mansion = register(Colors.BROWN, "Mansion", ConfigManager.drawMansions);
- public final static BoundingBoxType Igloo = register(Color.WHITE, "Igloo", ConfigManager.drawIgloos);
- public final static BoundingBoxType PillagerOutpost = register(Color.DARK_GRAY, "Pillager_Outpost", ConfigManager.drawPillagerOutposts);
- public final static BoundingBoxType WorldSpawn = register(Color.RED, "World_Spawn", ConfigManager.drawWorldSpawn);
- public final static BoundingBoxType SpawnChunks = register(Color.RED, "Spawn_Chunks", ConfigManager.drawWorldSpawn);
- public final static BoundingBoxType LazySpawnChunks = register(Color.RED, "Lazy_Chunks", ConfigManager.drawLazySpawnChunks);
- public final static BoundingBoxType MobSpawner = register(Color.GREEN, "Mob_Spawner", ConfigManager.drawMobSpawners);
- public final static BoundingBoxType SlimeChunks = register(Colors.DARK_GREEN, "Slime_Chunks", ConfigManager.drawSlimeChunks);
- public final static BoundingBoxType Village = register(Colors.PURPLE, "Village", ConfigManager.drawVillages);
- public final static BoundingBoxType VillageSpheres = register(null, "Village Sphere", ConfigManager.drawVillageSpheres);
- public final static BoundingBoxType AFKSphere = register(Color.RED, "AFK Sphere", ConfigManager.drawAFKSpheres);
- public final static BoundingBoxType BiomeBorder = register(Color.GREEN, "Biome Border", ConfigManager.drawBiomeBorders);
- public final static BoundingBoxType Beacon = register(Color.WHITE, "Beacon", ConfigManager.drawBeacons);
- public final static BoundingBoxType Custom = register(Color.WHITE, "Custom", ConfigManager.drawCustomBoxes);
+ public static final BoundingBoxType JungleTemple = register(Colors.DARK_GREEN, "Jungle_Pyramid", ConfigManager.drawJungleTemples);
+ public static final BoundingBoxType DesertTemple = register(Color.ORANGE, "Desert_Pyramid", ConfigManager.drawDesertTemples);
+ public static final BoundingBoxType WitchHut = register(Color.BLUE, "Swamp_Hut", ConfigManager.drawWitchHuts);
+ public static final BoundingBoxType OceanMonument = register(Color.CYAN, "Monument", ConfigManager.drawOceanMonuments);
+ public static final BoundingBoxType Shipwreck = register(Color.CYAN, "Shipwreck", ConfigManager.drawShipwrecks);
+ public static final BoundingBoxType OceanRuin = register(Color.CYAN, "Ocean_Ruin", ConfigManager.drawOceanRuins);
+ public static final BoundingBoxType BuriedTreasure = register(Color.CYAN, "Buried_Treasure", ConfigManager.drawBuriedTreasure);
+ public static final BoundingBoxType Stronghold = register(Color.YELLOW, "Stronghold", ConfigManager.drawStrongholds);
+ public static final BoundingBoxType MineShaft = register(Color.LIGHT_GRAY, "Mineshaft", ConfigManager.drawMineShafts);
+ public static final BoundingBoxType NetherFortress = register(Color.RED, "Fortress", ConfigManager.drawNetherFortresses);
+ public static final BoundingBoxType EndCity = register(Color.MAGENTA, "EndCity", ConfigManager.drawEndCities);
+ public static final BoundingBoxType Mansion = register(Colors.BROWN, "Mansion", ConfigManager.drawMansions);
+ public static final BoundingBoxType Igloo = register(Color.WHITE, "Igloo", ConfigManager.drawIgloos);
+ public static final BoundingBoxType PillagerOutpost = register(Color.DARK_GRAY, "Pillager_Outpost", ConfigManager.drawPillagerOutposts);
+ public static final BoundingBoxType WorldSpawn = register(Color.RED, "World_Spawn", ConfigManager.drawWorldSpawn);
+ public static final BoundingBoxType SpawnChunks = register(Color.RED, "Spawn_Chunks", ConfigManager.drawWorldSpawn);
+ public static final BoundingBoxType LazySpawnChunks = register(Color.RED, "Lazy_Chunks", ConfigManager.drawLazySpawnChunks);
+ public static final BoundingBoxType MobSpawner = register(Color.GREEN, "Mob_Spawner", ConfigManager.drawMobSpawners);
+ public static final BoundingBoxType SlimeChunks = register(Colors.DARK_GREEN, "Slime_Chunks", ConfigManager.drawSlimeChunks);
+ public static final BoundingBoxType Village = register(Colors.PURPLE, "Village", ConfigManager.drawVillages);
+ public static final BoundingBoxType VillageSpheres = register(null, "Village Sphere", ConfigManager.drawVillageSpheres);
+ public static final BoundingBoxType AFKSphere = register(Color.RED, "AFK Sphere", ConfigManager.drawAFKSpheres);
+ public static final BoundingBoxType BiomeBorder = register(Color.GREEN, "Biome Border", ConfigManager.drawBiomeBorders);
+ public static final BoundingBoxType Beacon = register(Color.WHITE, "Beacon", ConfigManager.drawBeacons);
+ public static final BoundingBoxType Custom = register(Color.WHITE, "Custom", ConfigManager.drawCustomBoxes);
private static BoundingBoxType register(Color color, String name, Setting<Boolean> shouldRenderSetting) {
return structureTypeMap.computeIfAbsent(name.hashCode(), k -> new BoundingBoxType(color, name, shouldRenderSetting));
import java.util.concurrent.ConcurrentHashMap;
public class CommonProxy {
- private Map<Integer, ServerPlayer> players = new ConcurrentHashMap<>();
- private Map<Integer, Set<AbstractBoundingBox>> playerBoundingBoxesCache = new HashMap<>();
- private Map<Integer, VillageProcessor> villageProcessors = new HashMap<>();
- private Map<Integer, AbstractChunkProcessor> chunkProcessors = new HashMap<>();
+ private final Map<Integer, ServerPlayer> players = new ConcurrentHashMap<>();
+ private final Map<Integer, Set<AbstractBoundingBox>> playerBoundingBoxesCache = new HashMap<>();
+ private final Map<Integer, VillageProcessor> villageProcessors = new HashMap<>();
+ private final Map<Integer, AbstractChunkProcessor> chunkProcessors = new HashMap<>();
private final Map<Integer, BoundingBoxCache> dimensionCache = new ConcurrentHashMap<>();
private Long seed = null;
private Integer spawnX = null;
import java.util.function.Consumer;
public class EventBus {
- private static Map<Class<?>, Consumer<?>> handlers = new HashMap<>();
+ private static final Map<Class<?>, Consumer<?>> handlers = new HashMap<>();
public static <evt> void publish(evt event) {
if (event == null) return;
if (typedValue == null) return;
consumer.accept(typedValue);
}
+
+ public static int combineHashCodes(int... hashCodes) {
+ final int prime = 31;
+ int result = 0;
+ for (int hashCode : hashCodes) {
+ result = prime * result + hashCode;
+ }
+ return result;
+ }
}
return Color.WHITE;
}
- private static Map<Integer, Color> villageColorCache = new HashMap<>();
+ private static final Map<Integer, Color> villageColorCache = new HashMap<>();
public static Color getColor(int villageId) {
return villageColorCache.computeIfAbsent(villageId, k -> getNextColor());
private final BoundingBoxCache boundingBoxCache;
private Map<Integer, BoundingBoxVillage> villageCache = new HashMap<>();
- private int dimensionId;
+ private final int dimensionId;
VillageProcessor(int dimensionId, BoundingBoxCache boundingBoxCache) {
this.dimensionId = dimensionId;
package com.irtimaled.bbor.common.events;
public class PlayerLoggedOut {
- private int playerId;
+ private final int playerId;
public PlayerLoggedOut(int playerId) {
this.playerId = playerId;
public class ServerWorldTick {
private final int dimensionId;
- private WorldServer world;
+ private final WorldServer world;
public ServerWorldTick(WorldServer world) {
this.world = world;
import java.util.function.BiFunction;
public class PayloadBuilder {
- private static Map<String, ResourceLocation> packetNames = new HashMap<>();
+ private static final Map<String, ResourceLocation> packetNames = new HashMap<>();
static PayloadBuilder clientBound(String name) {
return new PayloadBuilder(packetNames.computeIfAbsent(name, ResourceLocation::new), SPacketCustomPayload::new);
import net.minecraft.network.PacketBuffer;
public class PayloadReader {
- private PacketBuffer buffer;
+ private final PacketBuffer buffer;
public PayloadReader(PacketBuffer buffer) {
this.buffer = buffer;
@Override
public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + coords.hashCode();
- return result;
+ return coords.hashCode();
}
@Override
public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
BoundingBoxBeacon other = (BoundingBoxBeacon) obj;
return coords.equals(other.coords);
}
- @Override
- public String toString() {
- return "(" + coords.toString() + ")";
- }
-
public Coords getCoords() {
return coords;
}
package com.irtimaled.bbor.common.models;
import com.irtimaled.bbor.common.BoundingBoxType;
+import com.irtimaled.bbor.common.TypeHelper;
public class BoundingBoxCuboid extends AbstractBoundingBox {
private final Coords minCoords;
@Override
public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + minCoords.hashCode();
- result = prime * result + maxCoords.hashCode();
- return result;
+ return TypeHelper.combineHashCodes(minCoords.hashCode(), maxCoords.hashCode());
}
@Override
public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
BoundingBoxCuboid other = (BoundingBoxCuboid) obj;
return minCoords.equals(other.minCoords) && maxCoords.equals(other.maxCoords);
}
- @Override
- public String toString() {
- return "(" + minCoords.toString() + "; " + maxCoords.toString() + ")";
- }
-
public Coords getMinCoords() {
return minCoords;
}
return new BoundingBoxMobSpawner(coords, minCoords, maxCoords);
}
- @Override
- public String toString() {
- return "(" + coords.toString() + ")";
- }
-
public Coords getCoords() {
return coords;
}
private Integer spawnableCount;
public BoundingBoxSpawningSphere(Coords coords, double xOffset, double yOffset, double zOffset) {
- super(BoundingBoxType.AFKSphere, coords, 128);
+ super(coords, 128, BoundingBoxType.AFKSphere);
setCenterOffsets(xOffset, yOffset, zOffset);
}
private Double centerOffsetY = 0d;
private Double centerOffsetZ = 0d;
- protected BoundingBoxSphere(BoundingBoxType type, Coords center, Integer radius) {
+ protected BoundingBoxSphere(Coords center, Integer radius, BoundingBoxType type) {
super(type);
this.center = center;
this.radius = radius;
this.minZ <= maxZ;
}
- @Override
- public String toString() {
- return "(" + center.toString() + "; " + radius.toString() + ")";
- }
-
public Integer getRadius() {
return radius;
}
package com.irtimaled.bbor.common.models;
import com.irtimaled.bbor.common.BoundingBoxType;
+import com.irtimaled.bbor.common.TypeHelper;
import com.irtimaled.bbor.common.VillageColorCache;
import com.irtimaled.bbor.common.VillageHelper;
public class BoundingBoxVillage extends BoundingBoxSphere {
private final boolean spawnsIronGolems;
private final Color color;
- private Set<Coords> doors;
- private int villageHash;
+ private final Set<Coords> doors;
+ private final int villageHash;
private BoundingBoxVillage(Coords center, Integer radius, Color color, boolean spawnsIronGolems, Set<Coords> doors) {
- super(BoundingBoxType.VillageSpheres, center, radius);
+ super(center, radius, BoundingBoxType.VillageSpheres);
this.color = color;
this.spawnsIronGolems = spawnsIronGolems;
this.doors = doors;
@Override
public int hashCode() {
- return (super.hashCode() * 31) + villageHash;
+ return TypeHelper.combineHashCodes(super.hashCode(), villageHash);
}
public boolean getSpawnsIronGolems() {
import java.awt.*;
public class Colors {
- public final static Color DARK_ORANGE = new Color(255, 127, 0);
- public final static Color DARK_GREEN = new Color(0, 96, 0);
- public final static Color BROWN = new Color(139, 69, 19);
- public final static Color PURPLE = new Color(128, 0, 128);
+ public static final Color DARK_ORANGE = new Color(255, 127, 0);
+ public static final Color DARK_GREEN = new Color(0, 96, 0);
+ public static final Color BROWN = new Color(139, 69, 19);
+ public static final Color PURPLE = new Color(128, 0, 128);
}
}
@Override
- public boolean equals(Object other) {
- if (this == other) {
- return true;
- }
-
- Coords coords = TypeHelper.as(other, Coords.class);
- return coords != null &&
- this.getX() == coords.getX() &&
- this.getY() == coords.getY() &&
- this.getZ() == coords.getZ();
-
+ public int hashCode() {
+ return TypeHelper.combineHashCodes(z, y, x);
}
@Override
- public int hashCode() {
- return (this.getY() + this.getZ() * 31) * 31 + this.getX();
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ Coords other = (Coords) obj;
+ return getX() == other.getX() &&
+ getY() == other.getY() &&
+ getZ() == other.getZ();
+
}
}
import java.util.Set;
public class ConfigManager {
- private static Set<Setting<?>> settings = new HashSet<>();
+ private static final Set<Setting<?>> settings = new HashSet<>();
public static File configDir;
public static Setting<Boolean> fill;
import com.google.common.io.Files;
import java.io.*;
-import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.List;
}
}
- private Map<String, Map<String, Setting<?>>> settingsGroup = new HashMap<>();
+ private final Map<String, Map<String, Setting<?>>> settingsGroup = new HashMap<>();
void load() {
try {
- List<String> lines = Files.readLines(file, Charset.forName("utf-8"));
+ List<String> lines = Files.readLines(file, StandardCharsets.UTF_8);
String category = null;
String lastCommentLine = null;
for (String line : lines) {
}
Map<String, Setting<?>> settings = settingsGroup.get(category);
Setting<?> setting = settings.get(settingName);
- if (setting == null && category != FALLBACK_CATEGORY)
+ if (setting == null && !category.equals(FALLBACK_CATEGORY))
setting = getFallbackSetting(settingName, settings);
if (setting != null && setting.getType() != type) {
setting = null;
public class MixinSPacketCommandList {
@Inject(method = "processPacket", at= @At("RETURN"))
private void processPacket(INetHandlerPlayClient netHandlerPlayClient, CallbackInfo ci) {
- TypeHelper.doIfType(netHandlerPlayClient, NetHandlerPlayClient.class, handler -> {
- ClientInterop.registerClientCommands(handler.func_195515_i());
- });
+ TypeHelper.doIfType(netHandlerPlayClient, NetHandlerPlayClient.class, handler ->
+ ClientInterop.registerClientCommands(handler.func_195515_i()));
}
}