Fix NPE in prod
This commit is contained in:
parent
9aae18a623
commit
47abdac5ce
18 changed files with 34 additions and 36 deletions
|
@ -43,8 +43,6 @@ import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
|||
public class DimensionalDoorsInitializer implements ModInitializer {
|
||||
public static final Identifier MONOLITH_PARTICLE_PACKET = new Identifier("dimdoors", "monolith_particle_packet");
|
||||
public static ConfigHolder<ModConfig> CONFIG_MANAGER;
|
||||
public static ModConfig CONFIG;
|
||||
|
||||
private static Map<UUID, ServerPlayNetworkHandler> UUID_SERVER_PLAY_NETWORK_HANDLER_MAP = new HashMap<>();
|
||||
private static MinecraftServer server;
|
||||
|
||||
|
@ -60,7 +58,11 @@ public class DimensionalDoorsInitializer implements ModInitializer {
|
|||
return getServer().getWorld(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public static ModConfig getConfig() {
|
||||
return CONFIG_MANAGER.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
ServerLifecycleEvents.SERVER_STARTING.register((minecraftServer) -> {
|
||||
server = minecraftServer;
|
||||
|
|
|
@ -46,7 +46,7 @@ public class DetachedRiftBlockEntity extends RiftBlockEntity {
|
|||
return;
|
||||
}
|
||||
|
||||
if (!world.isClient() && random.nextDouble() < DimensionalDoorsInitializer.CONFIG.getGeneralConfig().endermanSpawnChance) {
|
||||
if (!world.isClient() && random.nextDouble() < DimensionalDoorsInitializer.getConfig().getGeneralConfig().endermanSpawnChance) {
|
||||
EndermanEntity enderman = EntityType.ENDERMAN.spawn(
|
||||
(ServerWorld) world,
|
||||
null,
|
||||
|
@ -58,7 +58,7 @@ public class DetachedRiftBlockEntity extends RiftBlockEntity {
|
|||
false
|
||||
);
|
||||
|
||||
if (random.nextDouble() < DimensionalDoorsInitializer.CONFIG.getGeneralConfig().endermanAggressiveChance) {
|
||||
if (random.nextDouble() < DimensionalDoorsInitializer.getConfig().getGeneralConfig().endermanAggressiveChance) {
|
||||
if (enderman != null) {
|
||||
enderman.setTarget(world.getClosestPlayer(enderman, 50));
|
||||
}
|
||||
|
@ -67,12 +67,12 @@ public class DetachedRiftBlockEntity extends RiftBlockEntity {
|
|||
|
||||
if (blockEntity.closing) {
|
||||
if (blockEntity.size > 0) {
|
||||
blockEntity.size -= DimensionalDoorsInitializer.CONFIG.getGeneralConfig().riftCloseSpeed;
|
||||
blockEntity.size -= DimensionalDoorsInitializer.getConfig().getGeneralConfig().riftCloseSpeed;
|
||||
} else {
|
||||
world.removeBlock(pos, false);
|
||||
}
|
||||
} else if (!blockEntity.stabilized) {
|
||||
blockEntity.size += DimensionalDoorsInitializer.CONFIG.getGeneralConfig().riftGrowthSpeed / (blockEntity.size + 1);
|
||||
blockEntity.size += DimensionalDoorsInitializer.getConfig().getGeneralConfig().riftGrowthSpeed / (blockEntity.size + 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ public class EntranceRiftBlockEntity extends RiftBlockEntity {
|
|||
|
||||
@Override
|
||||
public boolean receiveEntity(Entity entity, float yawOffset) {
|
||||
Vec3d targetPos = Vec3d.ofCenter(this.pos).add(Vec3d.of(this.getOrientation().getOpposite().getVector()).multiply(DimensionalDoorsInitializer.CONFIG.getGeneralConfig().teleportOffset + 0.5));
|
||||
Vec3d targetPos = Vec3d.ofCenter(this.pos).add(Vec3d.of(this.getOrientation().getOpposite().getVector()).multiply(DimensionalDoorsInitializer.getConfig().getGeneralConfig().teleportOffset + 0.5));
|
||||
TeleportUtil.teleport(entity, this.world, targetPos, yawOffset);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ public class DetachedRiftBlockEntityRenderer implements BlockEntityRenderer<Deta
|
|||
|
||||
@Override
|
||||
public void render(DetachedRiftBlockEntity rift, float tickDelta, MatrixStack matrices, VertexConsumerProvider vcs, int breakProgress, int alpha) {
|
||||
if (DimensionalDoorsInitializer.CONFIG.getGraphicsConfig().showRiftCore) {
|
||||
if (DimensionalDoorsInitializer.getConfig().getGraphicsConfig().showRiftCore) {
|
||||
this.renderTesseract(vcs.getBuffer(MyRenderLayer.TESSERACT), rift, matrices, tickDelta);
|
||||
} else {
|
||||
long timeLeft = RiftBlockEntity.showRiftCoreUntil - System.currentTimeMillis();
|
||||
|
@ -43,7 +43,7 @@ public class DetachedRiftBlockEntityRenderer implements BlockEntityRenderer<Deta
|
|||
private void renderCrack(VertexConsumer vc, MatrixStack matrices, DetachedRiftBlockEntity rift) {
|
||||
matrices.push();
|
||||
matrices.translate(0.5, 0.5, 0.5);
|
||||
RiftCrackRenderer.drawCrack(matrices.peek().getModel(), vc, 0, CURVE, DimensionalDoorsInitializer.CONFIG.getGraphicsConfig().riftSize * rift.size / 150, 0);//0xF1234568L * rift.hashCode());
|
||||
RiftCrackRenderer.drawCrack(matrices.peek().getModel(), vc, 0, CURVE, DimensionalDoorsInitializer.getConfig().getGraphicsConfig().riftSize * rift.size / 150, 0);//0xF1234568L * rift.hashCode());
|
||||
matrices.pop();
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ package org.dimdev.dimdoors.client;
|
|||
|
||||
import org.dimdev.dimdoors.DimensionalDoorsInitializer;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.render.VertexConsumer;
|
||||
import net.minecraft.util.Util;
|
||||
import net.minecraft.util.math.Matrix4f;
|
||||
|
@ -35,7 +34,7 @@ public final class RiftCrackRenderer {
|
|||
float time = ((Util.getEpochTimeMs() + riftRandom) % 2000000) * motionSpeed;
|
||||
double[] jitters = new double[jCount];
|
||||
|
||||
double jitterScale = DimensionalDoorsInitializer.CONFIG.getGraphicsConfig().riftJitter * size * size * size / 2000f;
|
||||
double jitterScale = DimensionalDoorsInitializer.getConfig().getGraphicsConfig().riftJitter * size * size * size / 2000f;
|
||||
// We use random constants here on purpose just to get different wave forms
|
||||
double xJitter = jitterScale * Math.sin(1.1f * time*size) * Math.sin(0.8f * time);
|
||||
double yJitter = jitterScale * Math.sin(1.2f * time*size) * Math.sin(0.9f * time);
|
||||
|
|
|
@ -77,7 +77,7 @@ public class MonolithEntity extends MobEntity {
|
|||
}
|
||||
|
||||
public boolean isDangerous() {
|
||||
return DimensionalDoorsInitializer.CONFIG.getMonolithsConfig().monolithTeleportation && (ModDimensions.isLimboDimension(this.world) || DimensionalDoorsInitializer.CONFIG.getMonolithsConfig().dangerousLimboMonoliths);
|
||||
return DimensionalDoorsInitializer.getConfig().getMonolithsConfig().monolithTeleportation && (ModDimensions.isLimboDimension(this.world) || DimensionalDoorsInitializer.getConfig().getMonolithsConfig().dangerousLimboMonoliths);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -95,7 +95,7 @@ public class MonolithAggroGoal extends Goal {
|
|||
}
|
||||
|
||||
// Teleport the target player if various conditions are met
|
||||
if (this.mob.getAggro() >= MAX_AGGRO && DimensionalDoorsInitializer.CONFIG.getMonolithsConfig().monolithTeleportation && !this.target.isCreative() && this.mob.isDangerous()) {
|
||||
if (this.mob.getAggro() >= MAX_AGGRO && DimensionalDoorsInitializer.getConfig().getMonolithsConfig().monolithTeleportation && !this.target.isCreative() && this.mob.isDangerous()) {
|
||||
this.mob.setAggro(0);
|
||||
//Location destination = LimboDimension.getLimboSkySpawn(player);
|
||||
//TeleportUtil.teleport(player, destination, 0, 0);
|
||||
|
|
|
@ -44,7 +44,7 @@ public class DimensionalDoorItem extends TallBlockItem {
|
|||
|
||||
if (context.getWorld().isClient) {
|
||||
context.getPlayer().sendMessage(new TranslatableText("rifts.entrances.rift_too_close"), true);
|
||||
RiftBlockEntity.showRiftCoreUntil = System.currentTimeMillis() + DimensionalDoorsInitializer.CONFIG.getGraphicsConfig().highlightRiftCoreFor;
|
||||
RiftBlockEntity.showRiftCoreUntil = System.currentTimeMillis() + DimensionalDoorsInitializer.getConfig().getGraphicsConfig().highlightRiftCoreFor;
|
||||
}
|
||||
|
||||
return ActionResult.FAIL;
|
||||
|
|
|
@ -63,7 +63,7 @@ public class RiftBladeItem extends SwordItem {
|
|||
return new TypedActionResult<>(ActionResult.SUCCESS, stack);
|
||||
} else {
|
||||
player.sendMessage(new TranslatableText(this.getTranslationKey() + ".rift_miss"), true);
|
||||
RiftBlockEntity.showRiftCoreUntil = System.currentTimeMillis() + DimensionalDoorsInitializer.CONFIG.getGraphicsConfig().highlightRiftCoreFor;
|
||||
RiftBlockEntity.showRiftCoreUntil = System.currentTimeMillis() + DimensionalDoorsInitializer.getConfig().getGraphicsConfig().highlightRiftCoreFor;
|
||||
return new TypedActionResult<>(ActionResult.FAIL, stack);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ public class RiftRemoverItem extends Item {
|
|||
if (world.isClient) {
|
||||
if (!RaycastHelper.hitsDetachedRift(hit, world)) {
|
||||
player.sendMessage(new TranslatableText("tools.rift_miss"), true);
|
||||
RiftBlockEntity.showRiftCoreUntil = System.currentTimeMillis() + DimensionalDoorsInitializer.CONFIG.getGraphicsConfig().highlightRiftCoreFor;
|
||||
RiftBlockEntity.showRiftCoreUntil = System.currentTimeMillis() + DimensionalDoorsInitializer.getConfig().getGraphicsConfig().highlightRiftCoreFor;
|
||||
}
|
||||
return new TypedActionResult<>(ActionResult.FAIL, stack);
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ public class RiftStabilizerItem extends Item {
|
|||
return new TypedActionResult<>(ActionResult.SUCCESS, stack);
|
||||
} else {
|
||||
player.sendMessage(new TranslatableText("tools.rift_miss"), true);
|
||||
RiftBlockEntity.showRiftCoreUntil = System.currentTimeMillis() + DimensionalDoorsInitializer.CONFIG.getGraphicsConfig().highlightRiftCoreFor;
|
||||
RiftBlockEntity.showRiftCoreUntil = System.currentTimeMillis() + DimensionalDoorsInitializer.getConfig().getGraphicsConfig().highlightRiftCoreFor;
|
||||
return new TypedActionResult<>(ActionResult.FAIL, stack);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ import java.util.Random;
|
|||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dimdev.dimdoors.DimensionalDoorsInitializer;
|
||||
import org.dimdev.dimdoors.ModConfig;
|
||||
import org.dimdev.dimdoors.pockets.virtual.reference.PocketGeneratorReference;
|
||||
import org.dimdev.dimdoors.rift.registry.LinkProperties;
|
||||
import org.dimdev.dimdoors.rift.targets.VirtualTarget;
|
||||
|
@ -84,7 +83,7 @@ public final class PocketGenerator {
|
|||
float netherProbability = DimensionalDoorsInitializer.getWorld(virtualLocation.getWorld()).getDimension().isUltrawarm() ? 1 : (float) depth / 200; // TODO: improve nether probability
|
||||
Random random = new Random();
|
||||
String group = random.nextFloat() < netherProbability ? "nether" : "ruins";
|
||||
PocketTemplate pocketTemplate = SchematicHandler.INSTANCE.getRandomTemplate(group, depth, DimensionalDoorsInitializer.CONFIG.getPocketsConfig().maxPocketSize, false);
|
||||
PocketTemplate pocketTemplate = SchematicHandler.INSTANCE.getRandomTemplate(group, depth, DimensionalDoorsInitializer.getConfig().getPocketsConfig().maxPocketSize, false);
|
||||
|
||||
return generatePocketFromTemplate(DimensionalDoorsInitializer.getWorld(ModDimensions.DUNGEON), pocketTemplate, virtualLocation, linkTo, linkProperties);
|
||||
}
|
||||
|
|
|
@ -220,7 +220,7 @@ public class SchematicHandler { // TODO: parts of this should be moved to the or
|
|||
for (JsonElement pocketElement : pockets) {
|
||||
JsonObject pocket = pocketElement.getAsJsonObject();
|
||||
int size = pocket.get("size").getAsInt();
|
||||
if (!DimensionalDoorsInitializer.CONFIG.getPocketsConfig().loadAllSchematics && size > DimensionalDoorsInitializer.CONFIG.getPocketsConfig().maxPocketSize)
|
||||
if (!DimensionalDoorsInitializer.getConfig().getPocketsConfig().loadAllSchematics && size > DimensionalDoorsInitializer.getConfig().getPocketsConfig().maxPocketSize)
|
||||
continue;
|
||||
String id = pocket.get("id").getAsString();
|
||||
String type = pocket.has("type") ? pocket.get("type").getAsString() : null;
|
||||
|
@ -319,11 +319,11 @@ public class SchematicHandler { // TODO: parts of this should be moved to the or
|
|||
}
|
||||
|
||||
public PocketTemplate getPersonalPocketTemplate() {
|
||||
return this.getRandomTemplate("private", -1, DimensionalDoorsInitializer.CONFIG.getPocketsConfig().privatePocketSize, true);
|
||||
return this.getRandomTemplate("private", -1, DimensionalDoorsInitializer.getConfig().getPocketsConfig().privatePocketSize, true);
|
||||
}
|
||||
|
||||
public PocketTemplate getPublicPocketTemplate() {
|
||||
return this.getRandomTemplate("public", -1, DimensionalDoorsInitializer.CONFIG.getPocketsConfig().publicPocketSize, true);
|
||||
return this.getRandomTemplate("public", -1, DimensionalDoorsInitializer.getConfig().getPocketsConfig().publicPocketSize, true);
|
||||
}
|
||||
|
||||
public static void saveSchematic(Schematic schematic, String id) {
|
||||
|
@ -391,7 +391,7 @@ public class SchematicHandler { // TODO: parts of this should be moved to the or
|
|||
}
|
||||
|
||||
public boolean isUsedOftenEnough(PocketTemplate template) {
|
||||
int maxNrOfCachedSchematics = DimensionalDoorsInitializer.CONFIG.getPocketsConfig().cachedSchematics;
|
||||
int maxNrOfCachedSchematics = DimensionalDoorsInitializer.getConfig().getPocketsConfig().cachedSchematics;
|
||||
int usageRank = this.usageMap.get(template);
|
||||
return usageRank < maxNrOfCachedSchematics;
|
||||
}
|
||||
|
@ -420,9 +420,9 @@ public class SchematicHandler { // TODO: parts of this should be moved to the or
|
|||
this.usageList.set(insertionIndex, new SimpleEntry(template, newUsage));
|
||||
this.usageMap.put(template, insertionIndex);
|
||||
|
||||
if (insertionIndex < DimensionalDoorsInitializer.CONFIG.getPocketsConfig().cachedSchematics) { //if the schematic of this template is supposed to get cached
|
||||
if (this.usageList.size() > DimensionalDoorsInitializer.CONFIG.getPocketsConfig().cachedSchematics) { //if there are more used templates than there are schematics allowed to be cached
|
||||
this.usageList.get(DimensionalDoorsInitializer.CONFIG.getPocketsConfig().cachedSchematics).getKey().setSchematic(null); //make sure that the number of cached schematics is limited
|
||||
if (insertionIndex < DimensionalDoorsInitializer.getConfig().getPocketsConfig().cachedSchematics) { //if the schematic of this template is supposed to get cached
|
||||
if (this.usageList.size() > DimensionalDoorsInitializer.getConfig().getPocketsConfig().cachedSchematics) { //if there are more used templates than there are schematics allowed to be cached
|
||||
this.usageList.get(DimensionalDoorsInitializer.getConfig().getPocketsConfig().cachedSchematics).getKey().setSchematic(null); //make sure that the number of cached schematics is limited
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,10 +3,8 @@ package org.dimdev.dimdoors.util;
|
|||
import net.minecraft.server.world.ServerWorld;
|
||||
|
||||
import org.dimdev.dimdoors.DimensionalDoorsInitializer;
|
||||
import org.dimdev.dimdoors.ModConfig;
|
||||
import org.dimdev.dimdoors.rift.registry.LinkProperties;
|
||||
import org.dimdev.dimdoors.rift.targets.VirtualTarget;
|
||||
import org.dimdev.dimdoors.world.level.DimensionalRegistry;
|
||||
import org.dimdev.dimdoors.world.pocket.VirtualLocation;
|
||||
|
||||
import java.util.Map;
|
||||
|
@ -48,8 +46,8 @@ public class PocketGenerationParameters {
|
|||
|
||||
public Map<String, Double> toVariableMap(Map<String, Double> stringDoubleMap) {
|
||||
stringDoubleMap.put("depth", (double) this.sourceVirtualLocation.getDepth());
|
||||
stringDoubleMap.put("public_size", (double) DimensionalDoorsInitializer.CONFIG.getPocketsConfig().publicPocketSize);
|
||||
stringDoubleMap.put("private_size", (double) DimensionalDoorsInitializer.CONFIG.getPocketsConfig().privatePocketSize);
|
||||
stringDoubleMap.put("public_size", (double) DimensionalDoorsInitializer.getConfig().getPocketsConfig().publicPocketSize);
|
||||
stringDoubleMap.put("private_size", (double) DimensionalDoorsInitializer.getConfig().getPocketsConfig().privatePocketSize);
|
||||
return stringDoubleMap;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ public final class ModFeatures {
|
|||
}
|
||||
|
||||
static {
|
||||
int gatewayChance = FabricLoader.getInstance().isDevelopmentEnvironment() ? 20 : DimensionalDoorsInitializer.CONFIG.getWorldConfig().gatewayGenChance;
|
||||
int gatewayChance = FabricLoader.getInstance().isDevelopmentEnvironment() ? 20 : DimensionalDoorsInitializer.getConfig().getWorldConfig().gatewayGenChance;
|
||||
SANDSTONE_PILLARS_FEATURE = SCHEMATIC_GATEWAY_FEATURE.configure(new SchematicV2GatewayFeatureConfig(SchematicV2Gateway.ID_SCHEMATIC_MAP.inverse().get(SANDSTONE_PILLARS_GATEWAY))).decorate(ConfiguredFeatures.Decorators.SQUARE_TOP_SOLID_HEIGHTMAP.applyChance(gatewayChance));
|
||||
TWO_PILLARS_FEATURE = SCHEMATIC_GATEWAY_FEATURE.configure(new SchematicV2GatewayFeatureConfig(SchematicV2Gateway.ID_SCHEMATIC_MAP.inverse().get(TWO_PILLARS_GATEWAY))).decorate(ConfiguredFeatures.Decorators.SQUARE_TOP_SOLID_HEIGHTMAP.applyChance(gatewayChance));
|
||||
LIMBO_GATEWAY_CONFIGURED_FEATURE = LIMBO_GATEWAY_FEATURE.configure(DefaultFeatureConfig.INSTANCE).decorate(ConfiguredFeatures.Decorators.SQUARE_TOP_SOLID_HEIGHTMAP.applyChance(gatewayChance));
|
||||
|
|
|
@ -168,7 +168,7 @@ public final class LimboDecay {
|
|||
public static void applySpreadDecay(World world, BlockPos pos) {
|
||||
//Check if we randomly apply decay spread or not. This can be used to moderate the frequency of
|
||||
//full spread decay checks, which can also shift its performance impact on the game.
|
||||
if (random.nextDouble() < DimensionalDoorsInitializer.CONFIG.getLimboConfig().decaySpreadChance) {
|
||||
if (random.nextDouble() < DimensionalDoorsInitializer.getConfig().getLimboConfig().decaySpreadChance) {
|
||||
//Apply decay to the blocks above, below, and on all four sides.
|
||||
//World.getBlockId() implements bounds checking, so we don't have to worry about reaching out of the world
|
||||
boolean flag = decayBlock(world, pos.up());
|
||||
|
|
|
@ -23,7 +23,7 @@ public class PocketDirectory {
|
|||
RegistryKey<World> worldKey;
|
||||
|
||||
public PocketDirectory(RegistryKey<World> worldKey) {
|
||||
this.gridSize = DimensionalDoorsInitializer.CONFIG.getPocketsConfig().pocketGridSize;
|
||||
this.gridSize = DimensionalDoorsInitializer.getConfig().getPocketsConfig().pocketGridSize;
|
||||
this.worldKey = worldKey;
|
||||
this.nextID = 0;
|
||||
this.pockets = new HashMap<>();
|
||||
|
|
|
@ -70,7 +70,7 @@ public class VirtualLocation {
|
|||
virtualLocation = null; // TODO: door was placed in a pockets dim but outside of a pockets...
|
||||
}
|
||||
} else if (ModDimensions.isLimboDimension(location.getWorld())) { // TODO: convert to interface on worldprovider
|
||||
virtualLocation = new VirtualLocation(location.world, location.getX(), location.getZ(), DimensionalDoorsInitializer.CONFIG.getDungeonsConfig().maxDungeonDepth);
|
||||
virtualLocation = new VirtualLocation(location.world, location.getX(), location.getZ(), DimensionalDoorsInitializer.getConfig().getDungeonsConfig().maxDungeonDepth);
|
||||
} // TODO: nether coordinate transform
|
||||
|
||||
if (virtualLocation == null) {
|
||||
|
@ -86,7 +86,7 @@ public class VirtualLocation {
|
|||
world = world.getServer().getWorld(OVERWORLD);
|
||||
}
|
||||
|
||||
float spread = DimensionalDoorsInitializer.CONFIG.getGeneralConfig().depthSpreadFactor * this.depth;
|
||||
float spread = DimensionalDoorsInitializer.getConfig().getGeneralConfig().depthSpreadFactor * this.depth;
|
||||
int newX = (int) (this.x + spread * 2 * (Math.random() - 0.5));
|
||||
int newZ = (int) (this.z + spread * 2 * (Math.random() - 0.5));
|
||||
BlockPos pos = world.getTopPosition(Heightmap.Type.WORLD_SURFACE, new BlockPos(newX, 0, newZ));
|
||||
|
|
Loading…
Reference in a new issue