diff --git a/src/main/java/org/dimdev/annotatednbt/Saved.java b/src/main/java/org/dimdev/annotatednbt/Saved.java deleted file mode 100644 index a9cd168c..00000000 --- a/src/main/java/org/dimdev/annotatednbt/Saved.java +++ /dev/null @@ -1,4 +0,0 @@ -package org.dimdev.annotatednbt; - -public @interface Saved { -} diff --git a/src/main/java/org/dimdev/dimcore/schematic/Schematic.java b/src/main/java/org/dimdev/dimcore/schematic/Schematic.java index 0ceca495..88d7d82a 100644 --- a/src/main/java/org/dimdev/dimcore/schematic/Schematic.java +++ b/src/main/java/org/dimdev/dimcore/schematic/Schematic.java @@ -366,7 +366,7 @@ public class Schematic implements BlockView { // Place the schematic's blocks this.setBlocks(world, xBase, yBase, zBase); - // Set BlockEntity data + // Set BlockEntity data for (CompoundTag BlockEntityNBT : tileEntities) { Vec3i schematicPos = new BlockPos(BlockEntityNBT.getInt("x"), BlockEntityNBT.getInt("y"), BlockEntityNBT.getInt("z")); BlockPos pos = new BlockPos(xBase, yBase, zBase).add(schematicPos); @@ -469,7 +469,7 @@ public class Schematic implements BlockView { ServerWorld w; - if(world instanceof ServerWorldAccess) { + if (world instanceof ServerWorldAccess) { w = ((ServerWorldAccess) world).toServerWorld(); } else { w = (ServerWorld) world; diff --git a/src/main/java/org/dimdev/dimcore/schematic/v2/RelativeBlockSample.java b/src/main/java/org/dimdev/dimcore/schematic/v2/RelativeBlockSample.java index f9928830..31f8f47a 100644 --- a/src/main/java/org/dimdev/dimcore/schematic/v2/RelativeBlockSample.java +++ b/src/main/java/org/dimdev/dimcore/schematic/v2/RelativeBlockSample.java @@ -76,7 +76,7 @@ public class RelativeBlockSample implements BlockView, ModifiableWorld { if (block instanceof ConditionalBlockEntityProvider && ((ConditionalBlockEntityProvider) block).hasBlockEntity(this.getBlockState(pos)) && ((ConditionalBlockEntityProvider) block).hasBlockEntity(pos, this)) { return ((ConditionalBlockEntityProvider) block).createBlockEntity(this.world); } else { - return ((BlockEntityProvider)block).createBlockEntity(this.world); + return ((BlockEntityProvider) block).createBlockEntity(this.world); } } return null; diff --git a/src/main/java/org/dimdev/dimcore/schematic/v2/Schematic.java b/src/main/java/org/dimdev/dimcore/schematic/v2/Schematic.java index 3596f480..bce360a1 100644 --- a/src/main/java/org/dimdev/dimcore/schematic/v2/Schematic.java +++ b/src/main/java/org/dimdev/dimcore/schematic/v2/Schematic.java @@ -35,7 +35,7 @@ public class Schematic { Codec.BYTE_BUFFER.fieldOf("BlockData").forGetter(Schematic::getBlockData), Codec.list(CompoundTag.CODEC).optionalFieldOf("BlockEntities", ImmutableList.of()).forGetter(Schematic::getBlockEntities), Codec.list(CompoundTag.CODEC).optionalFieldOf("Entities", ImmutableList.of()).forGetter(Schematic::getEntities) - ).apply(instance, Schematic::new); + ).apply(instance, Schematic::new); }); private final int version; diff --git a/src/main/java/org/dimdev/dimcore/schematic/v2/SchematicBlockPalette.java b/src/main/java/org/dimdev/dimcore/schematic/v2/SchematicBlockPalette.java index 4f74d30e..082d37bd 100644 --- a/src/main/java/org/dimdev/dimcore/schematic/v2/SchematicBlockPalette.java +++ b/src/main/java/org/dimdev/dimcore/schematic/v2/SchematicBlockPalette.java @@ -7,8 +7,6 @@ import com.mojang.serialization.Codec; import com.mojang.serialization.DataResult; import com.mojang.serialization.codecs.UnboundedMapCodec; -import com.sk89q.worldedit.WorldEdit; -import com.sk89q.worldedit.world.block.BaseBlock; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.state.property.Property; @@ -28,7 +26,7 @@ public class SchematicBlockPalette { static DataResult to(String string) { if (!string.contains("[") && !string.contains("]")) { - BlockState state = Registry.BLOCK.get(new Identifier(string)).getDefaultState(); + BlockState state = Registry.BLOCK.get(new Identifier(string)).getDefaultState(); return DataResult.success(state); } else { Block block = Objects.requireNonNull(Registry.BLOCK.get(new Identifier(string.substring(0, string.indexOf("["))))); @@ -39,7 +37,7 @@ public class SchematicBlockPalette { String[] stateArray = string.substring(string.indexOf("[") + 1, string.length() - 1).split(","); for (String stateString : stateArray) { Property property = Objects.requireNonNull(block.getStateManager().getProperty(stateString.split("=")[0])); - state = process(property,stateString.split("=")[1], state); + state = process(property, stateString.split("=")[1], state); } System.out.println(state); @@ -54,7 +52,7 @@ public class SchematicBlockPalette { // Ensures that [ and ] are only added when properties are present boolean flag = true; Iterator> iterator = state.getProperties().iterator(); - while(iterator.hasNext()) { + while (iterator.hasNext()) { if (flag) { builder.append("["); flag = false; diff --git a/src/main/java/org/dimdev/dimcore/schematic/v2/SchematicPlacer.java b/src/main/java/org/dimdev/dimcore/schematic/v2/SchematicPlacer.java index 2d310177..03461c55 100644 --- a/src/main/java/org/dimdev/dimcore/schematic/v2/SchematicPlacer.java +++ b/src/main/java/org/dimdev/dimcore/schematic/v2/SchematicPlacer.java @@ -56,7 +56,7 @@ public final class SchematicPlacer { List entityTags = schematic.getEntities(); for (CompoundTag tag : entityTags) { // Ensures compatibility with worldedit schematics - if (SchematicPlacer.fixId(tag)){ + if (SchematicPlacer.fixId(tag)) { System.err.println("An unexpected error occurred parsing this entity"); System.err.println(tag.toString()); throw new IllegalStateException("Entity in schematic \"" + schematic.getMetadata().getName() + "\" did not have an Id tag, nor an id tag!"); @@ -93,7 +93,7 @@ public final class SchematicPlacer { DoubleTag.of(x + originX), DoubleTag.of(y + originY), DoubleTag.of(z + originZ) - ), + ), (byte) 6 ) ); diff --git a/src/main/java/org/dimdev/dimcore/schematic/v2/SchematicTest.java b/src/main/java/org/dimdev/dimcore/schematic/v2/SchematicTest.java index 486c6b28..f729bdf1 100644 --- a/src/main/java/org/dimdev/dimcore/schematic/v2/SchematicTest.java +++ b/src/main/java/org/dimdev/dimcore/schematic/v2/SchematicTest.java @@ -4,12 +4,11 @@ import java.io.IOException; import java.nio.ByteBuffer; import java.nio.file.Files; import java.nio.file.Path; -import java.util.stream.IntStream; +import org.dimdev.dimdoors.DimensionalDoorsInitializer; import com.google.common.collect.ImmutableBiMap; import com.google.common.collect.ImmutableList; import com.mojang.serialization.DataResult; -import org.dimdev.dimdoors.DimensionalDoorsInitializer; import net.minecraft.block.Blocks; import net.minecraft.block.entity.BlastFurnaceBlockEntity; diff --git a/src/main/java/org/dimdev/dimdoors/DimensionalDoorsInitializer.java b/src/main/java/org/dimdev/dimdoors/DimensionalDoorsInitializer.java index 906f28c5..f1f134a2 100644 --- a/src/main/java/org/dimdev/dimdoors/DimensionalDoorsInitializer.java +++ b/src/main/java/org/dimdev/dimdoors/DimensionalDoorsInitializer.java @@ -58,13 +58,13 @@ public class DimensionalDoorsInitializer implements ModInitializer { ModBlocks.init(); ModItems.init(); + ModFeatures.init(); + ModBiomes.init(); ModDimensions.init(); ModEntityTypes.init(); - ModBiomes.init(); ModBlockEntityTypes.init(); ModCommands.init(); ModSoundEvents.init(); - ModFeatures.init(); ModConfig.deserialize(); diff --git a/src/main/java/org/dimdev/dimdoors/block/entity/DetachedRiftBlockEntity.java b/src/main/java/org/dimdev/dimdoors/block/entity/DetachedRiftBlockEntity.java index 290bd0bc..74c03248 100644 --- a/src/main/java/org/dimdev/dimdoors/block/entity/DetachedRiftBlockEntity.java +++ b/src/main/java/org/dimdev/dimdoors/block/entity/DetachedRiftBlockEntity.java @@ -2,7 +2,6 @@ package org.dimdev.dimdoors.block.entity; import java.util.Random; -import org.dimdev.annotatednbt.Saved; import org.dimdev.dimdoors.ModConfig; import org.dimdev.dimdoors.block.ModBlocks; import org.dimdev.dimdoors.util.TeleportUtil; @@ -22,13 +21,9 @@ import net.fabricmc.api.Environment; public class DetachedRiftBlockEntity extends RiftBlockEntity implements Tickable { private static final Random random = new Random(); - @Saved public boolean closing = false; - @Saved public boolean stabilized = false; - @Saved public int spawnedEndermanId = 0; - @Saved public float size = 0; private boolean unregisterDisabled = false; diff --git a/src/main/java/org/dimdev/dimdoors/block/entity/ModBlockEntityTypes.java b/src/main/java/org/dimdev/dimdoors/block/entity/ModBlockEntityTypes.java index 7131aa96..9bb4dc83 100644 --- a/src/main/java/org/dimdev/dimdoors/block/entity/ModBlockEntityTypes.java +++ b/src/main/java/org/dimdev/dimdoors/block/entity/ModBlockEntityTypes.java @@ -2,10 +2,10 @@ package org.dimdev.dimdoors.block.entity; import java.util.function.Supplier; -import com.google.common.collect.Sets; import org.dimdev.dimdoors.block.ModBlocks; import org.dimdev.dimdoors.client.DetachedRiftBlockEntityRenderer; import org.dimdev.dimdoors.client.EntranceRiftBlockEntityRenderer; +import com.google.common.collect.Sets; import net.minecraft.block.Block; import net.minecraft.block.entity.BlockEntity; diff --git a/src/main/java/org/dimdev/dimdoors/block/entity/RiftBlockEntity.java b/src/main/java/org/dimdev/dimdoors/block/entity/RiftBlockEntity.java index 8e1442c0..0840d6a8 100644 --- a/src/main/java/org/dimdev/dimdoors/block/entity/RiftBlockEntity.java +++ b/src/main/java/org/dimdev/dimdoors/block/entity/RiftBlockEntity.java @@ -2,7 +2,6 @@ package org.dimdev.dimdoors.block.entity; import java.util.Objects; -import com.mojang.serialization.Codec; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.dimdev.dimdoors.pockets.PocketTemplate; @@ -19,6 +18,7 @@ import org.dimdev.dimdoors.util.Location; import org.dimdev.dimdoors.util.NbtUtil; import org.dimdev.dimdoors.util.RGBA; import org.dimdev.dimdoors.world.pocket.VirtualLocation; +import com.mojang.serialization.Codec; import net.minecraft.block.BlockState; import net.minecraft.block.entity.BlockEntity; @@ -173,8 +173,8 @@ public abstract class RiftBlockEntity extends BlockEntity implements BlockEntity EntityTarget target = this.getTarget().as(Targets.ENTITY); if (target.receiveEntity(entity, entity.yaw)) { - VirtualLocation vloc = VirtualLocation.fromLocation(new Location((ServerWorld) entity.world, entity.getBlockPos())); - EntityUtils.chat(entity, new LiteralText("You are at x = " + vloc.x + ", y = ?, z = " + vloc.z + ", w = " + vloc.depth)); + VirtualLocation vLoc = VirtualLocation.fromLocation(new Location((ServerWorld) entity.world, entity.getBlockPos())); + EntityUtils.chat(entity, new LiteralText("You are at x = " + vLoc.getX() + ", y = ?, z = " + vLoc.getZ() + ", w = " + vLoc.getDepth())); return true; } } catch (Exception e) { diff --git a/src/main/java/org/dimdev/dimdoors/block/entity/RiftData.java b/src/main/java/org/dimdev/dimdoors/block/entity/RiftData.java index 084cd3c2..8603614c 100644 --- a/src/main/java/org/dimdev/dimdoors/block/entity/RiftData.java +++ b/src/main/java/org/dimdev/dimdoors/block/entity/RiftData.java @@ -1,10 +1,10 @@ package org.dimdev.dimdoors.block.entity; -import com.mojang.serialization.Codec; -import com.mojang.serialization.codecs.RecordCodecBuilder; import org.dimdev.dimdoors.rift.registry.LinkProperties; import org.dimdev.dimdoors.rift.targets.VirtualTarget; import org.dimdev.dimdoors.util.RGBA; +import com.mojang.serialization.Codec; +import com.mojang.serialization.codecs.RecordCodecBuilder; public class RiftData { public static Codec CODEC = RecordCodecBuilder.create(instance -> { diff --git a/src/main/java/org/dimdev/dimdoors/client/DetachedRiftBlockEntityRenderer.java b/src/main/java/org/dimdev/dimdoors/client/DetachedRiftBlockEntityRenderer.java index 23a88553..d3751aae 100644 --- a/src/main/java/org/dimdev/dimdoors/client/DetachedRiftBlockEntityRenderer.java +++ b/src/main/java/org/dimdev/dimdoors/client/DetachedRiftBlockEntityRenderer.java @@ -1,10 +1,10 @@ package org.dimdev.dimdoors.client; -import com.flowpowered.math.TrigMath; import org.dimdev.dimdoors.ModConfig; import org.dimdev.dimdoors.block.entity.DetachedRiftBlockEntity; import org.dimdev.dimdoors.client.tesseract.Tesseract; import org.dimdev.dimdoors.util.RGBA; +import com.flowpowered.math.TrigMath; import net.minecraft.client.render.VertexConsumer; import net.minecraft.client.render.VertexConsumerProvider; diff --git a/src/main/java/org/dimdev/dimdoors/client/EntranceRiftBlockEntityRenderer.java b/src/main/java/org/dimdev/dimdoors/client/EntranceRiftBlockEntityRenderer.java index c2c6015e..b3c96b8c 100644 --- a/src/main/java/org/dimdev/dimdoors/client/EntranceRiftBlockEntityRenderer.java +++ b/src/main/java/org/dimdev/dimdoors/client/EntranceRiftBlockEntityRenderer.java @@ -2,13 +2,10 @@ package org.dimdev.dimdoors.client; import java.util.List; import java.util.Random; -import java.util.stream.Collector; import java.util.stream.IntStream; -import com.google.common.collect.ImmutableList; -import it.unimi.dsi.fastutil.ints.AbstractInt2FloatMap; import org.dimdev.dimdoors.block.entity.EntranceRiftBlockEntity; -import org.dimdev.dimdoors.util.RGBA; +import com.google.common.collect.ImmutableList; import net.minecraft.client.MinecraftClient; import net.minecraft.client.render.RenderLayer; diff --git a/src/main/java/org/dimdev/dimdoors/client/MonolithRenderer.java b/src/main/java/org/dimdev/dimdoors/client/MonolithRenderer.java index 9ed4f726..fc573b36 100644 --- a/src/main/java/org/dimdev/dimdoors/client/MonolithRenderer.java +++ b/src/main/java/org/dimdev/dimdoors/client/MonolithRenderer.java @@ -2,8 +2,8 @@ package org.dimdev.dimdoors.client; import java.util.List; -import com.google.common.collect.Lists; import org.dimdev.dimdoors.entity.MonolithEntity; +import com.google.common.collect.Lists; import net.minecraft.client.render.entity.EntityRenderDispatcher; import net.minecraft.client.render.entity.LivingEntityRenderer; diff --git a/src/main/java/org/dimdev/dimdoors/client/MyRenderLayer.java b/src/main/java/org/dimdev/dimdoors/client/MyRenderLayer.java index 6b3fb8f6..50e6e232 100644 --- a/src/main/java/org/dimdev/dimdoors/client/MyRenderLayer.java +++ b/src/main/java/org/dimdev/dimdoors/client/MyRenderLayer.java @@ -3,12 +3,12 @@ package org.dimdev.dimdoors.client; import java.util.Arrays; import java.util.Random; +import org.dimdev.dimdoors.mixin.DirectionAccessor; +import org.lwjgl.opengl.GL11; import com.flowpowered.math.vector.VectorNi; import com.mojang.blaze3d.systems.RenderSystem; -import org.dimdev.dimdoors.block.entity.EntranceRiftBlockEntity; -import org.dimdev.dimdoors.mixin.DirectionAccessor; -import org.dimdev.dimdoors.util.RGBA; -import org.lwjgl.opengl.GL11; +import static org.lwjgl.opengl.GL11.GL_ONE_MINUS_DST_COLOR; +import static org.lwjgl.opengl.GL11.GL_ZERO; import net.minecraft.block.enums.DoorHinge; import net.minecraft.client.render.RenderLayer; @@ -20,12 +20,6 @@ import net.minecraft.state.property.BooleanProperty; import net.minecraft.state.property.DirectionProperty; import net.minecraft.state.property.EnumProperty; import net.minecraft.util.Identifier; -import net.minecraft.util.Util; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.Vec3d; - -import static org.lwjgl.opengl.GL11.GL_ONE_MINUS_DST_COLOR; -import static org.lwjgl.opengl.GL11.GL_ZERO; public class MyRenderLayer extends RenderLayer { public static final Identifier WARP_PATH = new Identifier("dimdoors:textures/other/warp.png"); @@ -60,26 +54,6 @@ public class MyRenderLayer extends RenderLayer { .texture(new Texture(DetachedRiftBlockEntityRenderer.TESSERACT_PATH, false, false)) .alpha(Alpha.HALF_ALPHA) .build(false)); -// -// public static RenderLayer getDimensionalPortal(int phase, EntranceRiftBlockEntity blockEntity) { -// Direction orientation = blockEntity.getOrientation(); -// Texture tex = new Texture(WARP_PATH, false, false); -// Vec3d offset = new Vec3d(orientation.getOpposite().getUnitVector()); -// return of("dimensional_portal", -// VertexFormats.POSITION_COLOR, -// 7, 256, -// false, -// true, -// RenderLayer.MultiPhaseParameters.builder() -// .transparency(ADDITIVE_TRANSPARENCY) -// .texture(tex) -// .texturing(new DimensionalPortalTexturing(phase, -// blockEntity, -// blockEntity.getPos().getX() + offset.x, -// blockEntity.getPos().getY() + offset.y, -// blockEntity.getPos().getZ() + offset.z)) -// .fog(BLACK_FOG).build(false)); -// } public static RenderLayer getPortal(int layer) { RenderPhase.Transparency transparency; @@ -94,40 +68,4 @@ public class MyRenderLayer extends RenderLayer { return of("dimensional_portal", VertexFormats.POSITION_COLOR, 7, 256, false, true, RenderLayer.MultiPhaseParameters.builder().transparency(transparency).texture(texture).texturing(new RenderPhase.PortalTexturing(layer)).fog(BLACK_FOG).build(false)); } - -// public static class DimensionalPortalTexturing extends RenderPhase.Texturing { -// public final int layer; -// -// public DimensionalPortalTexturing(int layer, EntranceRiftBlockEntity blockEntity, double x, double y, double z) { -// super("dimensional_portal_texturing", () -> { -// float translationScale = 16 - layer; -// float scale = 0.3625F; -// float offset = Util.getMeasuringTimeNano() % 200000L / 200000.0F; -// if (layer == 0) { -// translationScale = 25.0F; -// scale = 0.125F; -// } -// if (layer == 1) { -// scale = 0.5F; -// } -// RenderSystem.matrixMode(GL11.GL_TEXTURE); -// RenderSystem.pushMatrix(); -// RenderSystem.loadIdentity(); -// RenderSystem.translatef(0.1F, offset * translationScale, 0.1F); -// RenderSystem.scalef(scale, scale, scale); -// RenderSystem.translatef(0.5F, 0.5F, 0.5F); -// RenderSystem.rotatef((layer * layer * 4321 + layer) * 9 * 2.0F, 0.0F, 0.0F, 1.0F); -// RenderSystem.scalef(4.5F - (float)layer / 4.0F, 4.5F - (float)layer / 4.0F, 1.0F); -// RenderSystem.mulTextureByProjModelView(); -// RenderSystem.matrixMode(GL11.GL_MODELVIEW); -// RenderSystem.setupEndPortalTexGen(); -// }, () -> { -// RenderSystem.matrixMode(GL11.GL_TEXTURE); -// RenderSystem.popMatrix(); -// RenderSystem.matrixMode(GL11.GL_MODELVIEW); -// RenderSystem.clearTexGen(); -// }); -// this.layer = layer; -// } -// } } diff --git a/src/main/java/org/dimdev/dimdoors/client/tesseract/Plane.java b/src/main/java/org/dimdev/dimdoors/client/tesseract/Plane.java index 903fb9cb..c939259f 100644 --- a/src/main/java/org/dimdev/dimdoors/client/tesseract/Plane.java +++ b/src/main/java/org/dimdev/dimdoors/client/tesseract/Plane.java @@ -1,9 +1,9 @@ package org.dimdev.dimdoors.client.tesseract; +import org.dimdev.dimdoors.util.RGBA; import com.flowpowered.math.matrix.Matrix4f; import com.flowpowered.math.vector.Vector3f; import com.flowpowered.math.vector.Vector4f; -import org.dimdev.dimdoors.util.RGBA; import net.minecraft.client.render.VertexConsumer; diff --git a/src/main/java/org/dimdev/dimdoors/client/tesseract/Tesseract.java b/src/main/java/org/dimdev/dimdoors/client/tesseract/Tesseract.java index a0b35732..74ff35f7 100644 --- a/src/main/java/org/dimdev/dimdoors/client/tesseract/Tesseract.java +++ b/src/main/java/org/dimdev/dimdoors/client/tesseract/Tesseract.java @@ -1,7 +1,7 @@ package org.dimdev.dimdoors.client.tesseract; -import com.flowpowered.math.vector.Vector4f; import org.dimdev.dimdoors.util.RGBA; +import com.flowpowered.math.vector.Vector4f; import net.minecraft.client.render.VertexConsumer; import net.minecraft.util.math.Matrix4f; diff --git a/src/main/java/org/dimdev/dimdoors/command/DimTeleportCommand.java b/src/main/java/org/dimdev/dimdoors/command/DimTeleportCommand.java index 69a92948..ab0c7367 100644 --- a/src/main/java/org/dimdev/dimdoors/command/DimTeleportCommand.java +++ b/src/main/java/org/dimdev/dimdoors/command/DimTeleportCommand.java @@ -1,7 +1,6 @@ package org.dimdev.dimdoors.command; import com.mojang.brigadier.CommandDispatcher; -import org.dimdev.dimdoors.util.TeleportUtil; import net.minecraft.command.argument.DimensionArgumentType; import net.minecraft.command.argument.Vec3ArgumentType; @@ -10,8 +9,6 @@ import net.minecraft.server.command.ServerCommandSource; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.world.ServerWorld; import net.minecraft.util.math.Vec3d; -import net.minecraft.util.registry.RegistryKey; -import net.minecraft.world.World; public class DimTeleportCommand { public static void register(CommandDispatcher dispatcher) { diff --git a/src/main/java/org/dimdev/dimdoors/command/PocketCommand.java b/src/main/java/org/dimdev/dimdoors/command/PocketCommand.java index 4b8b77b0..798d2330 100644 --- a/src/main/java/org/dimdev/dimdoors/command/PocketCommand.java +++ b/src/main/java/org/dimdev/dimdoors/command/PocketCommand.java @@ -1,10 +1,5 @@ package org.dimdev.dimdoors.command; -import com.flowpowered.math.vector.Vector3i; -import com.mojang.brigadier.CommandDispatcher; -import com.mojang.brigadier.arguments.BoolArgumentType; -import com.mojang.brigadier.context.CommandContext; -import com.mojang.brigadier.exceptions.CommandSyntaxException; import org.dimdev.dimdoors.command.arguments.GroupArugmentType; import org.dimdev.dimdoors.command.arguments.NameArugmentType; import org.dimdev.dimdoors.pockets.PocketGenerator; @@ -16,6 +11,11 @@ import org.dimdev.dimdoors.util.Location; import org.dimdev.dimdoors.util.TeleportUtil; import org.dimdev.dimdoors.world.ModDimensions; import org.dimdev.dimdoors.world.pocket.Pocket; +import com.flowpowered.math.vector.Vector3i; +import com.mojang.brigadier.CommandDispatcher; +import com.mojang.brigadier.arguments.BoolArgumentType; +import com.mojang.brigadier.context.CommandContext; +import com.mojang.brigadier.exceptions.CommandSyntaxException; import net.minecraft.command.CommandException; import net.minecraft.server.command.CommandManager; diff --git a/src/main/java/org/dimdev/dimdoors/command/arguments/GroupArugmentType.java b/src/main/java/org/dimdev/dimdoors/command/arguments/GroupArugmentType.java index 578bd0bf..4552bc51 100644 --- a/src/main/java/org/dimdev/dimdoors/command/arguments/GroupArugmentType.java +++ b/src/main/java/org/dimdev/dimdoors/command/arguments/GroupArugmentType.java @@ -2,14 +2,14 @@ package org.dimdev.dimdoors.command.arguments; import java.util.concurrent.CompletableFuture; +import org.dimdev.dimdoors.pockets.PocketTemplate; +import org.dimdev.dimdoors.pockets.SchematicHandler; import com.mojang.brigadier.StringReader; import com.mojang.brigadier.arguments.ArgumentType; import com.mojang.brigadier.context.CommandContext; import com.mojang.brigadier.exceptions.CommandSyntaxException; import com.mojang.brigadier.suggestion.Suggestions; import com.mojang.brigadier.suggestion.SuggestionsBuilder; -import org.dimdev.dimdoors.pockets.PocketTemplate; -import org.dimdev.dimdoors.pockets.SchematicHandler; import net.minecraft.server.command.CommandSource; diff --git a/src/main/java/org/dimdev/dimdoors/command/arguments/NameArugmentType.java b/src/main/java/org/dimdev/dimdoors/command/arguments/NameArugmentType.java index 43a5503b..3f3066ae 100644 --- a/src/main/java/org/dimdev/dimdoors/command/arguments/NameArugmentType.java +++ b/src/main/java/org/dimdev/dimdoors/command/arguments/NameArugmentType.java @@ -2,13 +2,13 @@ package org.dimdev.dimdoors.command.arguments; import java.util.concurrent.CompletableFuture; +import org.dimdev.dimdoors.pockets.SchematicHandler; import com.mojang.brigadier.StringReader; import com.mojang.brigadier.arguments.ArgumentType; import com.mojang.brigadier.context.CommandContext; import com.mojang.brigadier.exceptions.CommandSyntaxException; import com.mojang.brigadier.suggestion.Suggestions; import com.mojang.brigadier.suggestion.SuggestionsBuilder; -import org.dimdev.dimdoors.pockets.SchematicHandler; import net.minecraft.server.command.CommandSource; diff --git a/src/main/java/org/dimdev/dimdoors/entity/ai/MonolithAggroGoal.java b/src/main/java/org/dimdev/dimdoors/entity/ai/MonolithAggroGoal.java index 540a17f0..a4fa2ae6 100644 --- a/src/main/java/org/dimdev/dimdoors/entity/ai/MonolithAggroGoal.java +++ b/src/main/java/org/dimdev/dimdoors/entity/ai/MonolithAggroGoal.java @@ -9,6 +9,7 @@ import org.dimdev.dimdoors.ModConfig; import org.dimdev.dimdoors.entity.MonolithEntity; import org.dimdev.dimdoors.item.ModItems; import org.dimdev.dimdoors.sound.ModSoundEvents; +import static org.dimdev.dimdoors.entity.MonolithEntity.MAX_AGGRO; import net.minecraft.entity.ai.TargetPredicate; import net.minecraft.entity.ai.goal.Goal; @@ -20,7 +21,6 @@ import net.minecraft.util.math.BlockPos; import net.fabricmc.fabric.api.network.ServerSidePacketRegistry; import static net.minecraft.predicate.entity.EntityPredicates.EXCEPT_SPECTATOR; -import static org.dimdev.dimdoors.entity.MonolithEntity.MAX_AGGRO; public class MonolithAggroGoal extends Goal { protected final MonolithEntity mob; diff --git a/src/main/java/org/dimdev/dimdoors/item/RiftRemoverItem.java b/src/main/java/org/dimdev/dimdoors/item/RiftRemoverItem.java index 75bdd2fe..c64d95d7 100644 --- a/src/main/java/org/dimdev/dimdoors/item/RiftRemoverItem.java +++ b/src/main/java/org/dimdev/dimdoors/item/RiftRemoverItem.java @@ -9,7 +9,6 @@ import org.dimdev.dimdoors.client.DetachedRiftBlockEntityRenderer; import org.dimdev.dimdoors.sound.ModSoundEvents; import net.minecraft.client.item.TooltipContext; -import net.minecraft.client.resource.language.I18n; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; diff --git a/src/main/java/org/dimdev/dimdoors/mixin/client/GlStateManagerAccessor.java b/src/main/java/org/dimdev/dimdoors/mixin/client/GlStateManagerAccessor.java index 5560ef3b..5375b066 100644 --- a/src/main/java/org/dimdev/dimdoors/mixin/client/GlStateManagerAccessor.java +++ b/src/main/java/org/dimdev/dimdoors/mixin/client/GlStateManagerAccessor.java @@ -2,9 +2,9 @@ package org.dimdev.dimdoors.mixin.client; import java.nio.FloatBuffer; -import com.mojang.blaze3d.platform.GlStateManager; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Invoker; +import com.mojang.blaze3d.platform.GlStateManager; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; diff --git a/src/main/java/org/dimdev/dimdoors/mixin/client/InGameHudMixin.java b/src/main/java/org/dimdev/dimdoors/mixin/client/InGameHudMixin.java index 5dc96a17..07219e08 100644 --- a/src/main/java/org/dimdev/dimdoors/mixin/client/InGameHudMixin.java +++ b/src/main/java/org/dimdev/dimdoors/mixin/client/InGameHudMixin.java @@ -1,11 +1,11 @@ package org.dimdev.dimdoors.mixin.client; -import com.mojang.blaze3d.systems.RenderSystem; import org.dimdev.dimdoors.world.ModBiomes; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.gui.hud.InGameHud; import net.minecraft.entity.Entity; diff --git a/src/main/java/org/dimdev/dimdoors/pockets/PocketGenerator.java b/src/main/java/org/dimdev/dimdoors/pockets/PocketGenerator.java index c55938f6..03d31bf7 100644 --- a/src/main/java/org/dimdev/dimdoors/pockets/PocketGenerator.java +++ b/src/main/java/org/dimdev/dimdoors/pockets/PocketGenerator.java @@ -57,8 +57,8 @@ public final class PocketGenerator { * @return The newly-generated dungeon pockets */ public static Pocket generateDungeonPocket(VirtualLocation virtualLocation, VirtualTarget linkTo, LinkProperties linkProperties) { - int depth = virtualLocation.depth; - float netherProbability = WorldUtil.getWorld(virtualLocation.world).getDimension().isUltrawarm() ? 1 : (float) depth / 200; // TODO: improve nether probability + int depth = virtualLocation.getDepth(); + float netherProbability = WorldUtil.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, ModConfig.INSTANCE.getPocketsConfig().maxPocketSize, false); diff --git a/src/main/java/org/dimdev/dimdoors/pockets/SchematicHandler.java b/src/main/java/org/dimdev/dimdoors/pockets/SchematicHandler.java index 46b7cbd0..542d9246 100644 --- a/src/main/java/org/dimdev/dimdoors/pockets/SchematicHandler.java +++ b/src/main/java/org/dimdev/dimdoors/pockets/SchematicHandler.java @@ -23,10 +23,6 @@ import java.util.Map.Entry; import java.util.Set; import java.util.stream.Collectors; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; import org.apache.commons.io.IOUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -34,6 +30,10 @@ import org.dimdev.dimcore.schematic.Schematic; import org.dimdev.dimdoors.DimensionalDoorsInitializer; import org.dimdev.dimdoors.ModConfig; import org.dimdev.dimdoors.util.math.MathUtil; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtIo; diff --git a/src/main/java/org/dimdev/dimdoors/rift/registry/LinkProperties.java b/src/main/java/org/dimdev/dimdoors/rift/registry/LinkProperties.java index 2da40373..53fefa38 100644 --- a/src/main/java/org/dimdev/dimdoors/rift/registry/LinkProperties.java +++ b/src/main/java/org/dimdev/dimdoors/rift/registry/LinkProperties.java @@ -4,10 +4,9 @@ import java.util.HashSet; import java.util.Objects; import java.util.Set; +import org.dimdev.dimdoors.util.Codecs; import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; -import org.dimdev.annotatednbt.Saved; -import org.dimdev.dimdoors.util.Codecs; public class LinkProperties { @@ -39,11 +38,8 @@ public class LinkProperties { public float floatingWeight; // TODO: depend on rift properties (ex. size, stability, or maybe a getWeightFactor method) rather than rift type public float entranceWeight; - @Saved public Set groups = new HashSet<>(); - @Saved public int linksRemaining; - @Saved public boolean oneWay; public LinkProperties(float floatingWeight, float entranceWeight, Set groups, int linksRemaining, boolean oneWay) { diff --git a/src/main/java/org/dimdev/dimdoors/rift/registry/PlayerRiftPointer.java b/src/main/java/org/dimdev/dimdoors/rift/registry/PlayerRiftPointer.java index ed111674..479caef4 100644 --- a/src/main/java/org/dimdev/dimdoors/rift/registry/PlayerRiftPointer.java +++ b/src/main/java/org/dimdev/dimdoors/rift/registry/PlayerRiftPointer.java @@ -4,7 +4,6 @@ import java.util.UUID; import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; -import org.dimdev.annotatednbt.Saved; import net.minecraft.util.dynamic.DynamicSerializableUuid; @@ -20,7 +19,6 @@ public class PlayerRiftPointer extends RegistryVertex { }); }); - @Saved public UUID player; public PlayerRiftPointer(UUID player) { diff --git a/src/main/java/org/dimdev/dimdoors/rift/registry/PocketEntrancePointer.java b/src/main/java/org/dimdev/dimdoors/rift/registry/PocketEntrancePointer.java index 31c60a91..3e4038b2 100644 --- a/src/main/java/org/dimdev/dimdoors/rift/registry/PocketEntrancePointer.java +++ b/src/main/java/org/dimdev/dimdoors/rift/registry/PocketEntrancePointer.java @@ -2,7 +2,6 @@ package org.dimdev.dimdoors.rift.registry; import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; -import org.dimdev.annotatednbt.Saved; import net.minecraft.util.dynamic.DynamicSerializableUuid; import net.minecraft.util.registry.RegistryKey; @@ -21,9 +20,7 @@ public class PocketEntrancePointer extends RegistryVertex { // TODO: PocketRiftP }); }); - @Saved public RegistryKey pocketDim; - @Saved public int pocketId; public PocketEntrancePointer(RegistryKey pocketDim, int pocketId) { diff --git a/src/main/java/org/dimdev/dimdoors/rift/registry/RegistryVertex.java b/src/main/java/org/dimdev/dimdoors/rift/registry/RegistryVertex.java index 9cea6df2..ef4f0142 100644 --- a/src/main/java/org/dimdev/dimdoors/rift/registry/RegistryVertex.java +++ b/src/main/java/org/dimdev/dimdoors/rift/registry/RegistryVertex.java @@ -3,7 +3,6 @@ package org.dimdev.dimdoors.rift.registry; import java.util.UUID; import com.mojang.serialization.Codec; -import org.dimdev.annotatednbt.Saved; import net.minecraft.util.Identifier; import net.minecraft.util.registry.Registry; @@ -20,7 +19,6 @@ public abstract class RegistryVertex { public static final Codec CODEC = registry.dispatch(RegistryVertex::getType, RegistryVertexType::codec); - @Saved public UUID id = UUID.randomUUID(); // Used to create pointers to registry vertices. Should not be used for anything other than saving. public void sourceGone(RegistryVertex source) { diff --git a/src/main/java/org/dimdev/dimdoors/rift/registry/Rift.java b/src/main/java/org/dimdev/dimdoors/rift/registry/Rift.java index a6e5e3e2..4c8f7d59 100644 --- a/src/main/java/org/dimdev/dimdoors/rift/registry/Rift.java +++ b/src/main/java/org/dimdev/dimdoors/rift/registry/Rift.java @@ -1,12 +1,11 @@ package org.dimdev.dimdoors.rift.registry; -import com.mojang.serialization.Codec; -import com.mojang.serialization.codecs.RecordCodecBuilder; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.dimdev.annotatednbt.Saved; import org.dimdev.dimdoors.block.entity.RiftBlockEntity; import org.dimdev.dimdoors.util.Location; +import com.mojang.serialization.Codec; +import com.mojang.serialization.codecs.RecordCodecBuilder; import net.minecraft.util.dynamic.DynamicSerializableUuid; @@ -25,11 +24,8 @@ public class Rift extends RegistryVertex { }); private static final Logger LOGGER = LogManager.getLogger(); - @Saved public Location location; - @Saved public boolean isDetached; - @Saved public LinkProperties properties; public Rift(Location location) { diff --git a/src/main/java/org/dimdev/dimdoors/rift/registry/RiftPlaceholder.java b/src/main/java/org/dimdev/dimdoors/rift/registry/RiftPlaceholder.java index 8905eefb..014fbaac 100644 --- a/src/main/java/org/dimdev/dimdoors/rift/registry/RiftPlaceholder.java +++ b/src/main/java/org/dimdev/dimdoors/rift/registry/RiftPlaceholder.java @@ -1,8 +1,8 @@ package org.dimdev.dimdoors.rift.registry; -import com.mojang.serialization.Codec; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import com.mojang.serialization.Codec; import net.minecraft.util.dynamic.DynamicSerializableUuid; diff --git a/src/main/java/org/dimdev/dimdoors/rift/registry/RiftRegistry.java b/src/main/java/org/dimdev/dimdoors/rift/registry/RiftRegistry.java index d5295c49..fbc2c919 100644 --- a/src/main/java/org/dimdev/dimdoors/rift/registry/RiftRegistry.java +++ b/src/main/java/org/dimdev/dimdoors/rift/registry/RiftRegistry.java @@ -18,6 +18,7 @@ import org.dimdev.dimdoors.world.pocket.PocketRegistry; import org.dimdev.dimdoors.world.pocket.PrivatePocketData; import org.jgrapht.graph.DefaultDirectedGraph; import org.jgrapht.graph.DefaultEdge; +import static org.dimdev.dimdoors.DimensionalDoorsInitializer.getWorld; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; @@ -26,7 +27,6 @@ import net.minecraft.world.PersistentState; import net.minecraft.world.World; import static net.minecraft.world.World.OVERWORLD; -import static org.dimdev.dimdoors.DimensionalDoorsInitializer.getWorld; public class RiftRegistry extends PersistentState { private static final Logger LOGGER = LogManager.getLogger(); diff --git a/src/main/java/org/dimdev/dimdoors/rift/targets/EscapeTarget.java b/src/main/java/org/dimdev/dimdoors/rift/targets/EscapeTarget.java index b3972df3..15fee0a8 100644 --- a/src/main/java/org/dimdev/dimdoors/rift/targets/EscapeTarget.java +++ b/src/main/java/org/dimdev/dimdoors/rift/targets/EscapeTarget.java @@ -2,21 +2,20 @@ package org.dimdev.dimdoors.rift.targets; import java.util.UUID; -import com.mojang.serialization.Codec; -import com.mojang.serialization.codecs.RecordCodecBuilder; import org.dimdev.dimdoors.block.entity.RiftBlockEntity; import org.dimdev.dimdoors.rift.registry.RiftRegistry; import org.dimdev.dimdoors.util.Location; import org.dimdev.dimdoors.util.TeleportUtil; import org.dimdev.dimdoors.world.ModDimensions; import org.dimdev.dimdoors.world.pocket.VirtualLocation; +import com.mojang.serialization.Codec; +import com.mojang.serialization.codecs.RecordCodecBuilder; +import static org.dimdev.dimdoors.util.EntityUtils.chat; import net.minecraft.entity.Entity; import net.minecraft.server.world.ServerWorld; import net.minecraft.text.TranslatableText; -import static org.dimdev.dimdoors.util.EntityUtils.chat; - public class EscapeTarget extends VirtualTarget implements EntityTarget { // TODO: createRift option public static final Codec CODEC = RecordCodecBuilder.create(instance -> { return instance.group( diff --git a/src/main/java/org/dimdev/dimdoors/rift/targets/FlowTracker.java b/src/main/java/org/dimdev/dimdoors/rift/targets/FlowTracker.java index dc69be6d..8ab20208 100644 --- a/src/main/java/org/dimdev/dimdoors/rift/targets/FlowTracker.java +++ b/src/main/java/org/dimdev/dimdoors/rift/targets/FlowTracker.java @@ -1,31 +1,28 @@ -package org.dimdev.dimdoors.rift.targets; - -import java.util.HashMap; -import java.util.Map; - -import org.dimdev.annotatednbt.AnnotatedNbt; -import org.dimdev.annotatednbt.Saved; - -import net.minecraft.nbt.CompoundTag; -import net.minecraft.util.math.Direction; - -/** - * Helps flow (fluid, redstone, power) senders to keep track of flow received by the - * target rift. - */ - -public class FlowTracker { // TODO - //@Saved public Map> fluids = new HashMap<>(); - @Saved - public Map redstone = new HashMap<>(); - @Saved - public Map power = new HashMap<>(); - - public void fromTag(CompoundTag nbt) { - AnnotatedNbt.load(this, nbt); - } - - public CompoundTag toTag(CompoundTag nbt) { - return AnnotatedNbt.serialize(this); - } -} +//package org.dimdev.dimdoors.rift.targets; +// +//import java.util.HashMap; +//import java.util.Map; +// +//import org.dimdev.dimdoors.util.AnnotatedNbt; +// +//import net.minecraft.nbt.CompoundTag; +//import net.minecraft.util.math.Direction; +// +///** +// * Helps flow (fluid, redstone, power) senders to keep track of flow received by the +// * target rift. +// */ +// +//public class FlowTracker { // TODO +// //@Saved public Map> fluids = new HashMap<>(); +// public Map redstone = new HashMap<>(); +// public Map power = new HashMap<>(); +// +// public void fromTag(CompoundTag nbt) { +// AnnotatedNbt.load(this, nbt); +// } +// +// public CompoundTag toTag(CompoundTag nbt) { +// return AnnotatedNbt.serialize(this); +// } +//} diff --git a/src/main/java/org/dimdev/dimdoors/rift/targets/GlobalReference.java b/src/main/java/org/dimdev/dimdoors/rift/targets/GlobalReference.java index 7160b8ca..08cb3c03 100644 --- a/src/main/java/org/dimdev/dimdoors/rift/targets/GlobalReference.java +++ b/src/main/java/org/dimdev/dimdoors/rift/targets/GlobalReference.java @@ -1,7 +1,7 @@ package org.dimdev.dimdoors.rift.targets; -import com.mojang.serialization.Codec; import org.dimdev.dimdoors.util.Location; +import com.mojang.serialization.Codec; public class GlobalReference extends RiftReference { public static Codec CODEC = Location.CODEC.fieldOf("location").xmap(GlobalReference::new, GlobalReference::getReferencedLocation).codec(); diff --git a/src/main/java/org/dimdev/dimdoors/rift/targets/LocalReference.java b/src/main/java/org/dimdev/dimdoors/rift/targets/LocalReference.java index db608e28..be24bfc2 100644 --- a/src/main/java/org/dimdev/dimdoors/rift/targets/LocalReference.java +++ b/src/main/java/org/dimdev/dimdoors/rift/targets/LocalReference.java @@ -1,15 +1,13 @@ package org.dimdev.dimdoors.rift.targets; -import com.mojang.serialization.Codec; -import org.dimdev.annotatednbt.Saved; import org.dimdev.dimdoors.util.Location; +import com.mojang.serialization.Codec; import net.minecraft.util.math.BlockPos; public class LocalReference extends RiftReference { public static final Codec CODEC = BlockPos.CODEC.xmap(LocalReference::new, LocalReference::getTarget).fieldOf("target").codec(); - @Saved protected BlockPos target; public LocalReference(BlockPos target) { diff --git a/src/main/java/org/dimdev/dimdoors/rift/targets/PocketEntranceMarker.java b/src/main/java/org/dimdev/dimdoors/rift/targets/PocketEntranceMarker.java index 4f4a9924..4cbf1175 100644 --- a/src/main/java/org/dimdev/dimdoors/rift/targets/PocketEntranceMarker.java +++ b/src/main/java/org/dimdev/dimdoors/rift/targets/PocketEntranceMarker.java @@ -1,8 +1,8 @@ package org.dimdev.dimdoors.rift.targets; +import org.dimdev.dimdoors.util.EntityUtils; import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; -import org.dimdev.dimdoors.util.EntityUtils; import net.minecraft.entity.Entity; import net.minecraft.text.TranslatableText; diff --git a/src/main/java/org/dimdev/dimdoors/rift/targets/PocketExitMarker.java b/src/main/java/org/dimdev/dimdoors/rift/targets/PocketExitMarker.java index 4f7d6598..bee9d86b 100644 --- a/src/main/java/org/dimdev/dimdoors/rift/targets/PocketExitMarker.java +++ b/src/main/java/org/dimdev/dimdoors/rift/targets/PocketExitMarker.java @@ -1,7 +1,7 @@ package org.dimdev.dimdoors.rift.targets; -import com.mojang.serialization.Codec; import org.dimdev.dimdoors.util.EntityUtils; +import com.mojang.serialization.Codec; import net.minecraft.entity.Entity; import net.minecraft.text.TranslatableText; diff --git a/src/main/java/org/dimdev/dimdoors/rift/targets/PrivatePocketExitTarget.java b/src/main/java/org/dimdev/dimdoors/rift/targets/PrivatePocketExitTarget.java index d4629b99..d85bfc29 100644 --- a/src/main/java/org/dimdev/dimdoors/rift/targets/PrivatePocketExitTarget.java +++ b/src/main/java/org/dimdev/dimdoors/rift/targets/PrivatePocketExitTarget.java @@ -2,7 +2,6 @@ package org.dimdev.dimdoors.rift.targets; import java.util.UUID; -import com.mojang.serialization.Codec; import org.dimdev.dimdoors.block.entity.RiftBlockEntity; import org.dimdev.dimdoors.rift.registry.RiftRegistry; import org.dimdev.dimdoors.util.EntityUtils; @@ -12,6 +11,7 @@ import org.dimdev.dimdoors.world.ModDimensions; import org.dimdev.dimdoors.world.pocket.Pocket; import org.dimdev.dimdoors.world.pocket.PocketRegistry; import org.dimdev.dimdoors.world.pocket.PrivatePocketData; +import com.mojang.serialization.Codec; import net.minecraft.entity.Entity; import net.minecraft.text.TranslatableText; diff --git a/src/main/java/org/dimdev/dimdoors/rift/targets/PrivatePocketTarget.java b/src/main/java/org/dimdev/dimdoors/rift/targets/PrivatePocketTarget.java index 4e3e8e8f..bdecb1f5 100644 --- a/src/main/java/org/dimdev/dimdoors/rift/targets/PrivatePocketTarget.java +++ b/src/main/java/org/dimdev/dimdoors/rift/targets/PrivatePocketTarget.java @@ -2,7 +2,6 @@ package org.dimdev.dimdoors.rift.targets; import java.util.UUID; -import com.mojang.serialization.Codec; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.dimdev.dimdoors.pockets.PocketGenerator; @@ -13,6 +12,7 @@ import org.dimdev.dimdoors.util.RGBA; import org.dimdev.dimdoors.world.pocket.Pocket; import org.dimdev.dimdoors.world.pocket.PrivatePocketData; import org.dimdev.dimdoors.world.pocket.VirtualLocation; +import com.mojang.serialization.Codec; import net.minecraft.block.entity.BlockEntity; import net.minecraft.entity.Entity; @@ -34,15 +34,15 @@ public class PrivatePocketTarget extends VirtualTarget implements EntityTarget { public boolean receiveEntity(Entity entity, float yawOffset) { // TODO: make this recursive UUID uuid = EntityUtils.getOwner(entity).getUuid(); - VirtualLocation virtualLocation = VirtualLocation.fromLocation(location); + VirtualLocation virtualLocation = VirtualLocation.fromLocation(this.location); if (uuid != null) { Pocket pocket = PrivatePocketData.instance().getPrivatePocket(uuid); if (pocket == null) { // generate the private pocket and get its entrances // set to where the pocket was first created - pocket = PocketGenerator.generatePrivatePocket(new VirtualLocation(virtualLocation.world, virtualLocation.x, virtualLocation.z, -1)); + pocket = PocketGenerator.generatePrivatePocket(new VirtualLocation(virtualLocation.getWorld(), virtualLocation.getX(), virtualLocation.getZ(), -1)); PrivatePocketData.instance().setPrivatePocketID(uuid, pocket); - processEntity(pocket, RiftRegistry.instance().getPocketEntrance(pocket).getBlockEntity(), entity, uuid, yawOffset); + this.processEntity(pocket, RiftRegistry.instance().getPocketEntrance(pocket).getBlockEntity(), entity, uuid, yawOffset); return true; } else { Location destLoc = RiftRegistry.instance().getPrivatePocketEntrance(uuid); // get the last used entrances @@ -50,13 +50,13 @@ public class PrivatePocketTarget extends VirtualTarget implements EntityTarget { destLoc = RiftRegistry.instance().getPocketEntrance(pocket); // if there's none, then set the target to the main entrances if (destLoc == null) { // if the pocket entrances is gone, then create a new private pocket LOGGER.info("All entrances are gone, creating a new private pocket!"); - pocket = PocketGenerator.generatePrivatePocket(new VirtualLocation(virtualLocation.world, virtualLocation.x, virtualLocation.z, -1)); + pocket = PocketGenerator.generatePrivatePocket(new VirtualLocation(virtualLocation.getWorld(), virtualLocation.getX(), virtualLocation.getZ(), -1)); PrivatePocketData.instance().setPrivatePocketID(uuid, pocket); destLoc = RiftRegistry.instance().getPocketEntrance(pocket); } - processEntity(pocket, destLoc.getBlockEntity(), entity, uuid, yawOffset); + this.processEntity(pocket, destLoc.getBlockEntity(), entity, uuid, yawOffset); return true; } } else { @@ -76,7 +76,7 @@ public class PrivatePocketTarget extends VirtualTarget implements EntityTarget { } } else { ((EntityTarget) BlockEntity).receiveEntity(entity, relativeYaw); - RiftRegistry.instance().setLastPrivatePocketExit(uuid, location); + RiftRegistry.instance().setLastPrivatePocketExit(uuid, this.location); } } diff --git a/src/main/java/org/dimdev/dimdoors/rift/targets/PublicPocketTarget.java b/src/main/java/org/dimdev/dimdoors/rift/targets/PublicPocketTarget.java index 319da8df..464f5bff 100644 --- a/src/main/java/org/dimdev/dimdoors/rift/targets/PublicPocketTarget.java +++ b/src/main/java/org/dimdev/dimdoors/rift/targets/PublicPocketTarget.java @@ -1,12 +1,12 @@ package org.dimdev.dimdoors.rift.targets; -import com.mojang.serialization.Codec; -import com.mojang.serialization.codecs.RecordCodecBuilder; import org.dimdev.dimdoors.pockets.PocketGenerator; import org.dimdev.dimdoors.rift.registry.RiftRegistry; import org.dimdev.dimdoors.util.Location; import org.dimdev.dimdoors.world.pocket.Pocket; import org.dimdev.dimdoors.world.pocket.VirtualLocation; +import com.mojang.serialization.Codec; +import com.mojang.serialization.codecs.RecordCodecBuilder; public class PublicPocketTarget extends RestoringTarget { public final static Codec CODEC = RecordCodecBuilder.create(instance -> { @@ -27,7 +27,7 @@ public class PublicPocketTarget extends RestoringTarget { @Override protected VirtualTarget getTarget() { - return wrappedDestination; + return this.wrappedDestination; } @Override @@ -37,11 +37,11 @@ public class PublicPocketTarget extends RestoringTarget { @Override public Location makeLinkTarget() { - VirtualLocation riftVirtualLocation = VirtualLocation.fromLocation(location); + VirtualLocation riftVirtualLocation = VirtualLocation.fromLocation(this.location); VirtualLocation newVirtualLocation; - int depth = Math.max(riftVirtualLocation.depth, 1); - newVirtualLocation = new VirtualLocation(riftVirtualLocation.world, riftVirtualLocation.x, riftVirtualLocation.z, depth); - Pocket pocket = PocketGenerator.generatePublicPocket(newVirtualLocation, new GlobalReference(location), null); + int depth = Math.max(riftVirtualLocation.getDepth(), 1); + newVirtualLocation = new VirtualLocation(riftVirtualLocation.getWorld(), riftVirtualLocation.getX(), riftVirtualLocation.getZ(), depth); + Pocket pocket = PocketGenerator.generatePublicPocket(newVirtualLocation, new GlobalReference(this.location), null); return RiftRegistry.instance().getPocketEntrance(pocket); } diff --git a/src/main/java/org/dimdev/dimdoors/rift/targets/RandomTarget.java b/src/main/java/org/dimdev/dimdoors/rift/targets/RandomTarget.java index 1dec1f3b..1da1f3f5 100644 --- a/src/main/java/org/dimdev/dimdoors/rift/targets/RandomTarget.java +++ b/src/main/java/org/dimdev/dimdoors/rift/targets/RandomTarget.java @@ -5,11 +5,6 @@ import java.util.Map; import java.util.Set; import java.util.stream.Collectors; -import com.google.common.collect.Sets; -import com.mojang.serialization.Codec; -import com.mojang.serialization.DataResult; -import com.mojang.serialization.codecs.RecordCodecBuilder; -import org.dimdev.annotatednbt.Saved; import org.dimdev.dimdoors.block.ModBlocks; import org.dimdev.dimdoors.block.entity.DetachedRiftBlockEntity; import org.dimdev.dimdoors.block.entity.RiftBlockEntity; @@ -22,6 +17,10 @@ import org.dimdev.dimdoors.util.WorldUtil; import org.dimdev.dimdoors.util.math.MathUtil; import org.dimdev.dimdoors.world.pocket.Pocket; import org.dimdev.dimdoors.world.pocket.VirtualLocation; +import com.google.common.collect.Sets; +import com.mojang.serialization.Codec; +import com.mojang.serialization.DataResult; +import com.mojang.serialization.codecs.RecordCodecBuilder; import net.minecraft.server.world.ServerWorld; import net.minecraft.util.math.BlockPos; @@ -36,27 +35,19 @@ public class RandomTarget extends VirtualTarget { // TODO: Split into DungeonTar Codec.DOUBLE.fieldOf("coordFactor").forGetter(location -> location.coordFactor), Codec.DOUBLE.fieldOf("positiveDepthFactor").forGetter(location -> location.positiveDepthFactor), Codec.DOUBLE.fieldOf("negativeDepthFactor").forGetter(location -> location.negativeDepthFactor), - Codec.INT_STREAM.>comapFlatMap(a -> DataResult.success(a.boxed().collect(Collectors.toSet())), a -> a.stream().mapToInt(Integer::intValue)).fieldOf("acceptedGroups").forGetter(target -> target.acceptedGroups), + Codec.INT_STREAM.comapFlatMap(a -> DataResult.success(a.boxed().collect(Collectors.toSet())), a -> a.stream().mapToInt(Integer::intValue)).fieldOf("acceptedGroups").forGetter(target -> target.acceptedGroups), Codec.BOOL.fieldOf("noLink").forGetter(target -> target.noLink), Codec.BOOL.fieldOf("noLinkBack").forGetter(target -> target.noLinkBack) ).apply(instance, RandomTarget::new); }); - @Saved protected float newRiftWeight; - @Saved protected double weightMaximum; - @Saved protected double coordFactor; - @Saved protected double positiveDepthFactor; - @Saved protected double negativeDepthFactor; - @Saved protected Set acceptedGroups; - @Saved protected boolean noLink; - @Saved protected boolean noLinkBack; public RandomTarget(float newRiftWeight, double weightMaximum, double coordFactor, double positiveDepthFactor, double negativeDepthFactor, Set acceptedGroups, boolean noLink, boolean noLinkBack) { @@ -76,24 +67,24 @@ public class RandomTarget extends VirtualTarget { // TODO: Split into DungeonTar @Override public Target receiveOther() { // TODO: Wrap rather than replace - VirtualLocation virtualLocationHere = VirtualLocation.fromLocation(location); + VirtualLocation virtualLocationHere = VirtualLocation.fromLocation(this.location); Map riftWeights = new HashMap<>(); - if (newRiftWeight > 0) riftWeights.put(null, newRiftWeight); + if (this.newRiftWeight > 0) riftWeights.put(null, this.newRiftWeight); for (Rift otherRift : RiftRegistry.instance().getRifts()) { VirtualLocation otherVirtualLocation = VirtualLocation.fromLocation(otherRift.location); if (otherRift.properties == null) continue; double otherWeight = otherRift.isDetached ? otherRift.properties.floatingWeight : otherRift.properties.entranceWeight; - if (otherWeight == 0 || Sets.intersection(acceptedGroups, otherRift.properties.groups).isEmpty()) continue; + if (otherWeight == 0 || Sets.intersection(this.acceptedGroups, otherRift.properties.groups).isEmpty()) continue; // Calculate the distance as sqrt((coordFactor * coordDistance)^2 + (depthFactor * depthDifference)^2) - if (otherVirtualLocation == null || otherRift.properties.linksRemaining == 0) continue; - double depthDifference = otherVirtualLocation.depth - virtualLocationHere.depth; - double coordDistance = Math.sqrt(sq(otherVirtualLocation.x - virtualLocationHere.x) - + sq(otherVirtualLocation.z - virtualLocationHere.z)); - double depthFactor = depthDifference > 0 ? positiveDepthFactor : negativeDepthFactor; - double distance = Math.sqrt(sq(coordFactor * coordDistance) + sq(depthFactor * depthDifference)); + if (otherRift.properties.linksRemaining == 0) continue; + double depthDifference = otherVirtualLocation.getDepth() - virtualLocationHere.getDepth(); + double coordDistance = Math.sqrt(this.sq(otherVirtualLocation.getX() - virtualLocationHere.getX()) + + this.sq(otherVirtualLocation.getZ() - virtualLocationHere.getZ())); + double depthFactor = depthDifference > 0 ? this.positiveDepthFactor : this.negativeDepthFactor; + double distance = Math.sqrt(this.sq(this.coordFactor * coordDistance) + this.sq(depthFactor * depthDifference)); // Calculate the weight as 4m/pi w/(m^2/d + d)^2. This is similar to how gravitational/electromagnetic attraction // works in physics (G m1 m2/d^2 and k_e m1 m2/d^2). Even though we add a depth dimension to the world, we keep @@ -103,13 +94,13 @@ public class RandomTarget extends VirtualTarget { // TODO: Split into DungeonTar // of f((m^(a+1)/a)/d^a). m is the location of f's maximum. The constant 4m/pi makes it such that a newRiftWeight // of 1 is equivalent to having a total link weight of 1 distributed equally across all layers. // TODO: We might want an a larger than 1 to make the function closer to 1/d^2 - double weight = 4 * weightMaximum / Math.PI * otherWeight / sq(sq(weightMaximum) / distance + distance); + double weight = 4 * this.weightMaximum / Math.PI * otherWeight / this.sq(this.sq(this.weightMaximum) / distance + distance); riftWeights.put(otherRift.location, (float) weight); } Location selectedLink; if (riftWeights.size() == 0) { - if (newRiftWeight == -1) { + if (this.newRiftWeight == -1) { selectedLink = null; } else { return null; @@ -139,48 +130,48 @@ public class RandomTarget extends VirtualTarget { // TODO: Split into DungeonTar // Clear[m]; // inverseCummulativeNormalizedDistribution = Normal[fit] double r = Math.random(); - double distance = weightMaximum * (2 * Math.tan(Math.PI / 2 * r) - 0.5578284481138029 * Math.sqrt(r) * Math.log(r)); + double distance = this.weightMaximum * (2 * Math.tan(Math.PI / 2 * r) - 0.5578284481138029 * Math.sqrt(r) * Math.log(r)); // Randomly split the vector into depth, x, and z components // TODO: Two random angles isn't a uniformly random direction! Use random vector, normalize, add depth offset, scale xz, scale depth. double theta = Math.random() * Math.PI; // Angle between vector and xz plane double phi = Math.random() * Math.PI; // Angle of the vector on the xz plane relative to the x axis double depth = distance * Math.sin(theta); - depth /= depth > 0 ? positiveDepthFactor : negativeDepthFactor; - double x = Math.cos(theta) * Math.cos(phi) * distance / coordFactor; - double z = Math.cos(theta) * Math.sin(phi) * distance / coordFactor; - VirtualLocation virtualLocation = new VirtualLocation(virtualLocationHere.world, - virtualLocationHere.x + (int) Math.round(x), - virtualLocationHere.z + (int) Math.round(z), - virtualLocationHere.depth + (int) Math.round(depth)); + depth /= depth > 0 ? this.positiveDepthFactor : this.negativeDepthFactor; + double x = Math.cos(theta) * Math.cos(phi) * distance / this.coordFactor; + double z = Math.cos(theta) * Math.sin(phi) * distance / this.coordFactor; + VirtualLocation virtualLocation = new VirtualLocation(virtualLocationHere.getWorld(), + virtualLocationHere.getX() + (int) Math.round(x), + virtualLocationHere.getZ() + (int) Math.round(z), + virtualLocationHere.getDepth() + (int) Math.round(depth)); - if (virtualLocation.depth <= 0) { + if (virtualLocation.getDepth() <= 0) { // This will lead to the overworld - World world = WorldUtil.getWorld(virtualLocation.world); - BlockPos pos = world.getTopPosition(Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, new BlockPos(virtualLocation.x, 0, virtualLocation.z)); + ServerWorld world = WorldUtil.getWorld(virtualLocation.getWorld()); + BlockPos pos = world.getTopPosition(Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, new BlockPos(virtualLocation.getX(), 0, virtualLocation.getZ())); if (pos.getY() == -1) { // No blocks at that XZ (hole in bedrock) - pos = new BlockPos(virtualLocation.x, 0, virtualLocation.z); + pos = new BlockPos(virtualLocation.getX(), 0, virtualLocation.getX()); } world.setBlockState(pos, ModBlocks.DETACHED_RIFT.getDefaultState()); - RiftBlockEntity thisRift = (RiftBlockEntity) location.getBlockEntity(); + RiftBlockEntity thisRift = (RiftBlockEntity) this.location.getBlockEntity(); DetachedRiftBlockEntity riftEntity = (DetachedRiftBlockEntity) world.getBlockEntity(pos); // TODO: Should the rift not be configured like the other link riftEntity.setProperties(thisRift.getProperties().toBuilder().linksRemaining(1).build()); - if (!noLinkBack && !riftEntity.getProperties().oneWay) - linkRifts(new Location((ServerWorld) world, pos), location); - if (!noLink) linkRifts(location, new Location((ServerWorld) world, pos)); + if (!this.noLinkBack && !riftEntity.getProperties().oneWay) + linkRifts(new Location(world, pos), this.location); + if (!this.noLink) linkRifts(this.location, new Location(world, pos)); return riftEntity.as(Targets.ENTITY); } else { // Make a new dungeon pocket - RiftBlockEntity thisRift = (RiftBlockEntity) location.getBlockEntity(); + RiftBlockEntity thisRift = (RiftBlockEntity) this.location.getBlockEntity(); LinkProperties newLink = thisRift.getProperties() != null ? thisRift.getProperties().toBuilder().linksRemaining(0).build() : null; - Pocket pocket = PocketGenerator.generateDungeonPocket(virtualLocation, new GlobalReference(!noLinkBack ? location : null), newLink); // TODO make the generated dungeon of the same type, but in the overworld + Pocket pocket = PocketGenerator.generateDungeonPocket(virtualLocation, new GlobalReference(!this.noLinkBack ? this.location : null), newLink); // TODO make the generated dungeon of the same type, but in the overworld // Link the rift if necessary and teleport the entity - if (!noLink) linkRifts(location, RiftRegistry.instance().getPocketEntrance(pocket)); + if (!this.noLink) linkRifts(this.location, RiftRegistry.instance().getPocketEntrance(pocket)); return (Target) RiftRegistry.instance().getPocketEntrance(pocket).getBlockEntity(); } } else { @@ -188,8 +179,8 @@ public class RandomTarget extends VirtualTarget { // TODO: Split into DungeonTar RiftBlockEntity riftEntity = (RiftBlockEntity) selectedLink.getBlockEntity(); // Link the rifts if necessary and teleport the entity - if (!noLink) linkRifts(location, selectedLink); - if (!noLinkBack && !riftEntity.getProperties().oneWay) linkRifts(selectedLink, location); + if (!this.noLink) linkRifts(this.location, selectedLink); + if (!this.noLinkBack && !riftEntity.getProperties().oneWay) linkRifts(selectedLink, this.location); return riftEntity; } } @@ -301,7 +292,7 @@ public class RandomTarget extends VirtualTarget { // TODO: Split into DungeonTar } public RandomTarget build() { - return new RandomTarget(newRiftWeight, weightMaximum, coordFactor, positiveDepthFactor, negativeDepthFactor, acceptedGroups, noLink, noLinkBack); + return new RandomTarget(this.newRiftWeight, this.weightMaximum, this.coordFactor, this.positiveDepthFactor, this.negativeDepthFactor, this.acceptedGroups, this.noLink, this.noLinkBack); } } } diff --git a/src/main/java/org/dimdev/dimdoors/rift/targets/RelativeReference.java b/src/main/java/org/dimdev/dimdoors/rift/targets/RelativeReference.java index 87b9bab9..4112ed4c 100644 --- a/src/main/java/org/dimdev/dimdoors/rift/targets/RelativeReference.java +++ b/src/main/java/org/dimdev/dimdoors/rift/targets/RelativeReference.java @@ -1,7 +1,7 @@ package org.dimdev.dimdoors.rift.targets; -import com.mojang.serialization.Codec; import org.dimdev.dimdoors.util.Location; +import com.mojang.serialization.Codec; import net.minecraft.util.math.Vec3i; diff --git a/src/main/java/org/dimdev/dimdoors/rift/targets/VirtualTarget.java b/src/main/java/org/dimdev/dimdoors/rift/targets/VirtualTarget.java index aa0e571d..8240d307 100644 --- a/src/main/java/org/dimdev/dimdoors/rift/targets/VirtualTarget.java +++ b/src/main/java/org/dimdev/dimdoors/rift/targets/VirtualTarget.java @@ -1,9 +1,9 @@ package org.dimdev.dimdoors.rift.targets; -import com.mojang.serialization.Codec; import org.dimdev.dimdoors.util.Location; import org.dimdev.dimdoors.util.NbtUtil; import org.dimdev.dimdoors.util.RGBA; +import com.mojang.serialization.Codec; import net.minecraft.nbt.CompoundTag; import net.minecraft.util.Identifier; diff --git a/src/main/java/org/dimdev/annotatednbt/AnnotatedNbt.java b/src/main/java/org/dimdev/dimdoors/util/AnnotatedNbt.java similarity index 93% rename from src/main/java/org/dimdev/annotatednbt/AnnotatedNbt.java rename to src/main/java/org/dimdev/dimdoors/util/AnnotatedNbt.java index 8b715935..b9238efb 100644 --- a/src/main/java/org/dimdev/annotatednbt/AnnotatedNbt.java +++ b/src/main/java/org/dimdev/dimdoors/util/AnnotatedNbt.java @@ -1,9 +1,8 @@ -package org.dimdev.annotatednbt; +package org.dimdev.dimdoors.util; import com.google.gson.Gson; import com.mojang.serialization.Dynamic; import com.mojang.serialization.JsonOps; -import org.dimdev.dimdoors.util.RotatedLocation; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtOps; diff --git a/src/main/java/org/dimdev/dimdoors/util/Location.java b/src/main/java/org/dimdev/dimdoors/util/Location.java index 45766125..dade4980 100644 --- a/src/main/java/org/dimdev/dimdoors/util/Location.java +++ b/src/main/java/org/dimdev/dimdoors/util/Location.java @@ -1,8 +1,8 @@ package org.dimdev.dimdoors.util; +import org.dimdev.dimdoors.DimensionalDoorsInitializer; import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; -import org.dimdev.dimdoors.DimensionalDoorsInitializer; import net.minecraft.block.BlockState; import net.minecraft.block.entity.BlockEntity; diff --git a/src/main/java/org/dimdev/dimdoors/util/RotatedLocation.java b/src/main/java/org/dimdev/dimdoors/util/RotatedLocation.java index b881dfd7..7fa3a153 100644 --- a/src/main/java/org/dimdev/dimdoors/util/RotatedLocation.java +++ b/src/main/java/org/dimdev/dimdoors/util/RotatedLocation.java @@ -2,7 +2,6 @@ package org.dimdev.dimdoors.util; import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; -import org.dimdev.annotatednbt.Saved; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.Tag; @@ -20,9 +19,7 @@ public class RotatedLocation extends Location { ).apply(instance, RotatedLocation::new); }); - @Saved public final float yaw; - @Saved public final float pitch; public RotatedLocation(RegistryKey world, BlockPos pos, float yaw, float pitch) { diff --git a/src/main/java/org/dimdev/dimdoors/world/ModBiomes.java b/src/main/java/org/dimdev/dimdoors/world/ModBiomes.java index f0281368..9943e886 100644 --- a/src/main/java/org/dimdev/dimdoors/world/ModBiomes.java +++ b/src/main/java/org/dimdev/dimdoors/world/ModBiomes.java @@ -80,6 +80,7 @@ public final class ModBiomes { .build()) .generationSettings(new GenerationSettings.Builder() .feature(GenerationStep.Feature.SURFACE_STRUCTURES, ModFeatures.LIMBO_GATEWAY_CONFIGURED_FEATURE) + .feature(GenerationStep.Feature.LAKES, ModFeatures.ETERNAL_FLUID_LAKE) .surfaceBuilder(SurfaceBuilder.NETHER.method_30478(new TernarySurfaceConfig(ModBlocks.UNRAVELLED_FABRIC.getDefaultState(), ModBlocks.UNRAVELLED_FABRIC.getDefaultState(), ModBlocks.ETERNAL_FLUID.getDefaultState()))) .build()) .precipitation(Biome.Precipitation.NONE) diff --git a/src/main/java/org/dimdev/dimdoors/world/ModDimensions.java b/src/main/java/org/dimdev/dimdoors/world/ModDimensions.java index 82c384bb..57954912 100644 --- a/src/main/java/org/dimdev/dimdoors/world/ModDimensions.java +++ b/src/main/java/org/dimdev/dimdoors/world/ModDimensions.java @@ -3,13 +3,13 @@ package org.dimdev.dimdoors.world; import java.util.Optional; import java.util.OptionalLong; -import com.google.common.collect.ImmutableMap; import org.dimdev.dimdoors.block.ModBlocks; import org.dimdev.dimdoors.mixin.ChunkGeneratorSettingsAccessor; import org.dimdev.dimdoors.mixin.DimensionTypeAccessor; import org.dimdev.dimdoors.world.limbo.LimboBiomeSource; import org.dimdev.dimdoors.world.limbo.LimboChunkGenerator; import org.dimdev.dimdoors.world.pocket.BlankChunkGenerator; +import com.google.common.collect.ImmutableMap; import net.minecraft.server.world.ServerWorld; import net.minecraft.tag.BlockTags; diff --git a/src/main/java/org/dimdev/dimdoors/world/feature/ModFeatures.java b/src/main/java/org/dimdev/dimdoors/world/feature/ModFeatures.java index 027f5c08..f734cbd8 100644 --- a/src/main/java/org/dimdev/dimdoors/world/feature/ModFeatures.java +++ b/src/main/java/org/dimdev/dimdoors/world/feature/ModFeatures.java @@ -1,6 +1,7 @@ package org.dimdev.dimdoors.world.feature; import org.dimdev.dimdoors.ModConfig; +import org.dimdev.dimdoors.block.ModBlocks; import org.dimdev.dimdoors.world.feature.gateway.LimboGatewayFeature; import org.dimdev.dimdoors.world.feature.gateway.schematic.SandstonePillarsV2Gateway; import org.dimdev.dimdoors.world.feature.gateway.schematic.SchematicV2Gateway; @@ -10,10 +11,13 @@ import org.dimdev.dimdoors.world.feature.gateway.schematic.SchematicV2GatewayFea import net.minecraft.util.Identifier; import net.minecraft.util.registry.BuiltinRegistries; import net.minecraft.util.registry.Registry; +import net.minecraft.world.gen.decorator.Decorator; +import net.minecraft.world.gen.decorator.RangeDecoratorConfig; import net.minecraft.world.gen.feature.ConfiguredFeature; import net.minecraft.world.gen.feature.ConfiguredFeatures; import net.minecraft.world.gen.feature.DefaultFeatureConfig; import net.minecraft.world.gen.feature.Feature; +import net.minecraft.world.gen.feature.SingleStateFeatureConfig; import net.fabricmc.loader.api.FabricLoader; @@ -23,11 +27,13 @@ public final class ModFeatures { public static final SchematicV2Gateway SANDSTONE_PILLARS_GATEWAY = new SandstonePillarsV2Gateway(); public static final ConfiguredFeature SANDSTONE_PILLARS_FEATURE; public static final ConfiguredFeature LIMBO_GATEWAY_CONFIGURED_FEATURE; + public static ConfiguredFeature ETERNAL_FLUID_LAKE; public static void init() { SANDSTONE_PILLARS_GATEWAY.init(); Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, new Identifier("dimdoors", "sandstone_pillars"), SANDSTONE_PILLARS_FEATURE); Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, new Identifier("dimdoors", "limbo_gateway"), LIMBO_GATEWAY_CONFIGURED_FEATURE); + ETERNAL_FLUID_LAKE = Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, new Identifier("dimdoors", "eternal_fluid_lake"), Feature.LAKE.configure(new SingleStateFeatureConfig(ModBlocks.ETERNAL_FLUID.getDefaultState())).decorate(Decorator.RANGE.configure(new RangeDecoratorConfig(5, 70, 128)).applyChance(20))); } static { diff --git a/src/main/java/org/dimdev/dimdoors/world/limbo/LimboBiomeSource.java b/src/main/java/org/dimdev/dimdoors/world/limbo/LimboBiomeSource.java index 75bc81d0..c1b25cc1 100644 --- a/src/main/java/org/dimdev/dimdoors/world/limbo/LimboBiomeSource.java +++ b/src/main/java/org/dimdev/dimdoors/world/limbo/LimboBiomeSource.java @@ -2,10 +2,10 @@ package org.dimdev.dimdoors.world.limbo; import java.util.Set; +import org.dimdev.dimdoors.world.ModBiomes; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.mojang.serialization.Codec; -import org.dimdev.dimdoors.world.ModBiomes; import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.source.BiomeSource; diff --git a/src/main/java/org/dimdev/dimdoors/world/limbo/LimboChunkGenerator.java b/src/main/java/org/dimdev/dimdoors/world/limbo/LimboChunkGenerator.java index 1c821097..75740122 100644 --- a/src/main/java/org/dimdev/dimdoors/world/limbo/LimboChunkGenerator.java +++ b/src/main/java/org/dimdev/dimdoors/world/limbo/LimboChunkGenerator.java @@ -9,11 +9,11 @@ import java.util.stream.IntStream; import it.unimi.dsi.fastutil.objects.ObjectArrayList; import it.unimi.dsi.fastutil.objects.ObjectList; import it.unimi.dsi.fastutil.objects.ObjectListIterator; -import com.mojang.serialization.Codec; import org.dimdev.dimdoors.block.ModBlocks; import org.dimdev.dimdoors.mixin.ChunkGeneratorAccessor; import org.dimdev.dimdoors.world.ModDimensions; import org.jetbrains.annotations.Nullable; +import com.mojang.serialization.Codec; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; @@ -376,29 +376,21 @@ public class LimboChunkGenerator extends ChunkGenerator { } } - this.buildFluid(chunk, chunkRandom); + this.buildAncientFabricFloor(chunk, chunkRandom); } - private void buildFluid(Chunk chunk, Random random) { + private void buildAncientFabricFloor(Chunk chunk, Random random) { BlockPos.Mutable mutable = new BlockPos.Mutable(); - int i = chunk.getPos().getStartX(); - int j = chunk.getPos().getStartZ(); - ChunkGeneratorSettings chunkGeneratorSettings = this.settings.get(); - int k = chunkGeneratorSettings.getBedrockFloorY(); - boolean bl2 = k + 4 >= 0 && k < this.worldHeight; + int startX = chunk.getPos().getStartX(); + int startZ = chunk.getPos().getStartZ(); + ChunkGeneratorSettings settings = this.settings.get(); + int bedrockFloorY = settings.getBedrockFloorY(); + boolean bl2 = bedrockFloorY + 4 >= 0 && bedrockFloorY < this.worldHeight; if (bl2) { - Iterator iterator = BlockPos.iterate(i, 0, j, i + 15, 0, j + 15).iterator(); - while (true) { - BlockPos blockPos; - int o; - if (!iterator.hasNext()) { - return; - } - - blockPos = iterator.next(); - for (o = 4; o >= 0; --o) { + for (BlockPos blockPos : BlockPos.iterate(startX, 0, startZ, startX + 15, 0, startZ + 15)) { + for (int o = 4; o >= 0; --o) { if (o <= random.nextInt(5)) { - chunk.setBlockState(mutable.set(blockPos.getX(), k + o, blockPos.getZ()), ModBlocks.ETERNAL_FLUID.getDefaultState(), false); + chunk.setBlockState(mutable.set(blockPos.getX(), bedrockFloorY + o, blockPos.getZ()), ModBlocks.BLACK_ANCIENT_FABRIC.getDefaultState(), false); } } } @@ -406,8 +398,8 @@ public class LimboChunkGenerator extends ChunkGenerator { } public void populateNoise(WorldAccess world, StructureAccessor accessor, Chunk chunk) { - ObjectList objectList = new ObjectArrayList<>(10); - ObjectList objectList2 = new ObjectArrayList<>(32); + ObjectList structurePieces = new ObjectArrayList<>(10); + ObjectList jigsawJunctions = new ObjectArrayList<>(32); ChunkPos chunkPos = chunk.getPos(); int posX = chunkPos.x; int posZ = chunkPos.z; @@ -431,18 +423,18 @@ public class LimboChunkGenerator extends ChunkGenerator { PoolStructurePiece poolStructurePiece = (PoolStructurePiece) structurePiece; StructurePool.Projection projection = poolStructurePiece.getPoolElement().getProjection(); if (projection == StructurePool.Projection.RIGID) { - objectList.add(poolStructurePiece); + structurePieces.add(poolStructurePiece); } for (JigsawJunction jigsawJunction : poolStructurePiece.getJunctions()) { int kx = jigsawJunction.getSourceX(); int lx = jigsawJunction.getSourceZ(); if (kx > k - 12 && lx > l - 12 && kx < k + 15 + 12 && lx < l + 15 + 12) { - objectList2.add(jigsawJunction); + jigsawJunctions.add(jigsawJunction); } } } else { - objectList.add(structurePiece); + structurePieces.add(structurePiece); } } }); @@ -460,8 +452,8 @@ public class LimboChunkGenerator extends ChunkGenerator { Heightmap heightmap = protoChunk.getHeightmap(Heightmap.Type.OCEAN_FLOOR_WG); Heightmap heightmap2 = protoChunk.getHeightmap(Heightmap.Type.WORLD_SURFACE_WG); BlockPos.Mutable mutable = new BlockPos.Mutable(); - ObjectListIterator objectListIterator = objectList.iterator(); - ObjectListIterator objectListIterator2 = objectList2.iterator(); + ObjectListIterator objectListIterator = structurePieces.iterator(); + ObjectListIterator objectListIterator2 = jigsawJunctions.iterator(); for (int n = 0; n < this.noiseSizeX; ++n) { int p; @@ -524,7 +516,7 @@ public class LimboChunkGenerator extends ChunkGenerator { ar = Math.max(0, Math.max(blockBox.minZ - ak, ak - blockBox.maxZ)); } - objectListIterator.back(objectList.size()); + objectListIterator.back(structurePieces.size()); while (objectListIterator2.hasNext()) { JigsawJunction jigsawJunction = objectListIterator2.next(); @@ -534,7 +526,7 @@ public class LimboChunkGenerator extends ChunkGenerator { ao += getNoiseWeight(as, at, au) * 0.4D; } - objectListIterator2.back(objectList2.size()); + objectListIterator2.back(jigsawJunctions.size()); BlockState blockState = this.getBlockState(ao, v); if (blockState != Blocks.AIR.getDefaultState()) { if (blockState.getLuminance() != 0) { @@ -573,7 +565,7 @@ public class LimboChunkGenerator extends ChunkGenerator { public void populateEntities(ChunkRegion region) { int i = region.getCenterChunkX(); int j = region.getCenterChunkZ(); - Biome biome = region.getBiome((new ChunkPos(i, j)).getStartPos()); + Biome biome = region.getBiome(new ChunkPos(i, j).getStartPos()); ChunkRandom chunkRandom = new ChunkRandom(); chunkRandom.setPopulationSeed(region.getSeed(), i << 4, j << 4); SpawnHelper.populateEntities(region, biome, i, j, chunkRandom); diff --git a/src/main/java/org/dimdev/dimdoors/world/limbo/LimboDecay.java b/src/main/java/org/dimdev/dimdoors/world/limbo/LimboDecay.java index 90af3e27..a3a4880c 100644 --- a/src/main/java/org/dimdev/dimdoors/world/limbo/LimboDecay.java +++ b/src/main/java/org/dimdev/dimdoors/world/limbo/LimboDecay.java @@ -6,14 +6,6 @@ import java.util.Random; import java.util.function.BiConsumer; import org.dimdev.dimdoors.ModConfig; - -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.BlockWithEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; - -import static net.minecraft.block.Blocks.*; import static org.dimdev.dimdoors.block.ModBlocks.DETACHED_RIFT; import static org.dimdev.dimdoors.block.ModBlocks.DIMENSIONAL_PORTAL; import static org.dimdev.dimdoors.block.ModBlocks.ETERNAL_FLUID; @@ -24,6 +16,14 @@ import static org.dimdev.dimdoors.block.ModBlocks.OAK_DIMENSIONAL_DOOR; import static org.dimdev.dimdoors.block.ModBlocks.QUARTZ_DOOR; import static org.dimdev.dimdoors.block.ModBlocks.UNRAVELLED_FABRIC; +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.block.BlockWithEntity; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; + +import static net.minecraft.block.Blocks.*; + /** * Provides methods for applying Limbo decay. Limbo decay refers to the effect that most blocks placed in Limbo * naturally change into stone, then cobble, then gravel, and finally Unraveled Fabric as time passes. diff --git a/src/main/java/org/dimdev/dimdoors/world/pocket/Pocket.java b/src/main/java/org/dimdev/dimdoors/world/pocket/Pocket.java index 2e4faf64..2f399ed9 100644 --- a/src/main/java/org/dimdev/dimdoors/world/pocket/Pocket.java +++ b/src/main/java/org/dimdev/dimdoors/world/pocket/Pocket.java @@ -1,11 +1,10 @@ package org.dimdev.dimdoors.world.pocket; +import org.dimdev.dimdoors.util.Codecs; +import org.dimdev.dimdoors.util.EntityUtils; import com.flowpowered.math.vector.Vector3i; import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; -import org.dimdev.annotatednbt.Saved; -import org.dimdev.dimdoors.util.Codecs; -import org.dimdev.dimdoors.util.EntityUtils; import net.minecraft.entity.Entity; import net.minecraft.text.TranslatableText; @@ -29,17 +28,11 @@ public final class Pocket { }); private static final int BLOCKS_PAINTED_PER_DYE = 1106; - @Saved public final int id; - @Saved public BlockBox box; - @Saved public VirtualLocation virtualLocation; - @Saved public PocketColor dyeColor = PocketColor.WHITE; - @Saved public PocketColor nextDyeColor = PocketColor.NONE; - @Saved public int count = 0; public RegistryKey world; diff --git a/src/main/java/org/dimdev/dimdoors/world/pocket/PocketRegistry.java b/src/main/java/org/dimdev/dimdoors/world/pocket/PocketRegistry.java index cac4dc36..5f28fc74 100644 --- a/src/main/java/org/dimdev/dimdoors/world/pocket/PocketRegistry.java +++ b/src/main/java/org/dimdev/dimdoors/world/pocket/PocketRegistry.java @@ -3,13 +3,12 @@ package org.dimdev.dimdoors.world.pocket; import java.util.HashMap; import java.util.Map; -import com.mojang.serialization.Codec; -import org.dimdev.annotatednbt.Saved; import org.dimdev.dimdoors.ModConfig; import org.dimdev.dimdoors.util.NbtUtil; import org.dimdev.dimdoors.util.WorldUtil; import org.dimdev.dimdoors.util.math.GridUtil; import org.dimdev.dimdoors.world.ModDimensions; +import com.mojang.serialization.Codec; import net.minecraft.nbt.CompoundTag; import net.minecraft.server.world.ServerWorld; @@ -23,11 +22,11 @@ public class PocketRegistry extends PersistentState { private static final String DATA_NAME = "pocketlib_pockets"; - @Saved /*package-private*/ int gridSize; // Determines how much pockets in their dimension are spaced - @Saved /*package-private*/ int privatePocketSize; - @Saved /*package-private*/ int publicPocketSize; - @Saved /*package-private*/ Map pockets; - @Saved /*package-private*/ int nextID; + /*package-private*/ int gridSize; // Determines how much pockets in their dimension are spaced + /*package-private*/ int privatePocketSize; + /*package-private*/ int publicPocketSize; + /*package-private*/ Map pockets; + /*package-private*/ int nextID; private ServerWorld world; diff --git a/src/main/java/org/dimdev/dimdoors/world/pocket/PrivatePocketData.java b/src/main/java/org/dimdev/dimdoors/world/pocket/PrivatePocketData.java index 18222518..992455e5 100644 --- a/src/main/java/org/dimdev/dimdoors/world/pocket/PrivatePocketData.java +++ b/src/main/java/org/dimdev/dimdoors/world/pocket/PrivatePocketData.java @@ -2,13 +2,12 @@ package org.dimdev.dimdoors.world.pocket; import java.util.UUID; +import org.dimdev.dimdoors.util.NbtUtil; +import org.dimdev.dimdoors.util.WorldUtil; import com.google.common.collect.BiMap; import com.google.common.collect.HashBiMap; import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; -import org.dimdev.annotatednbt.Saved; -import org.dimdev.dimdoors.util.NbtUtil; -import org.dimdev.dimdoors.util.WorldUtil; import net.minecraft.nbt.CompoundTag; import net.minecraft.util.dynamic.DynamicSerializableUuid; @@ -27,9 +26,7 @@ public class PrivatePocketData extends PersistentState { ).apply(instance, PocketInfo::new); }); - @Saved public final RegistryKey world; - @Saved public final int id; public PocketInfo(RegistryKey world, int id) { @@ -42,7 +39,6 @@ public class PrivatePocketData extends PersistentState { private static final String DATA_NAME = "dimdoors_private_pockets"; - @Saved protected BiMap privatePocketMap = HashBiMap.create(); // Player UUID -> Pocket Info TODO: fix AnnotatedNBT and use UUID rather than String public PrivatePocketData(String name) { diff --git a/src/main/java/org/dimdev/dimdoors/world/pocket/VirtualLocation.java b/src/main/java/org/dimdev/dimdoors/world/pocket/VirtualLocation.java index 83108f45..349f8f38 100644 --- a/src/main/java/org/dimdev/dimdoors/world/pocket/VirtualLocation.java +++ b/src/main/java/org/dimdev/dimdoors/world/pocket/VirtualLocation.java @@ -1,14 +1,14 @@ package org.dimdev.dimdoors.world.pocket; -import com.mojang.serialization.Codec; -import com.mojang.serialization.codecs.RecordCodecBuilder; -import org.dimdev.annotatednbt.AnnotatedNbt; import org.dimdev.dimdoors.DimensionalDoorsInitializer; import org.dimdev.dimdoors.ModConfig; import org.dimdev.dimdoors.util.Location; import org.dimdev.dimdoors.world.ModDimensions; +import com.mojang.serialization.Codec; +import com.mojang.serialization.codecs.RecordCodecBuilder; import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtOps; import net.minecraft.server.world.ServerWorld; import net.minecraft.util.math.BlockPos; import net.minecraft.util.registry.RegistryKey; @@ -27,14 +27,10 @@ public class VirtualLocation { ).apply(instance, VirtualLocation::new) ); - - public final RegistryKey world; - - public final int x; - - public final int z; - - public final int depth; + private RegistryKey world; + private int x; + private int z; + private int depth; public VirtualLocation(RegistryKey world, int x, int z, int depth) { this.world = world; @@ -43,13 +39,20 @@ public class VirtualLocation { this.depth = depth; } - public void fromTag(CompoundTag nbt) { - AnnotatedNbt.load(this, nbt); + public void fromTag(CompoundTag tag) { + VirtualLocation location = CODEC.decode(NbtOps.INSTANCE, tag).getOrThrow(false, System.err::println).getFirst(); + this.x = location.x; + this.z = location.z; + this.depth = location.depth; + this.world = location.world; } - public CompoundTag toTag(CompoundTag nbt) { - AnnotatedNbt.save(this, nbt); - return nbt; + public CompoundTag toTag(CompoundTag tag) { + CompoundTag encodedTag = (CompoundTag) CODEC.encodeStart(NbtOps.INSTANCE, this).getOrThrow(false, System.err::println); + for (String key : encodedTag.getKeys()) { + tag.put(key, encodedTag.get(key)); + } + return tag; } public static VirtualLocation fromLocation(Location location) { @@ -86,4 +89,20 @@ public class VirtualLocation { BlockPos pos = world.getTopPosition(Heightmap.Type.WORLD_SURFACE, new BlockPos(newX, 0, newZ)); return new Location(world, pos); } + + public RegistryKey getWorld() { + return this.world; + } + + public int getX() { + return this.x; + } + + public int getZ() { + return this.z; + } + + public int getDepth() { + return this.depth; + } }