Replace placeholders late

This commit is contained in:
SD 2020-10-21 17:04:54 +05:30
parent 0db9c0bd00
commit a72c42637b
No known key found for this signature in database
GPG key ID: E36B57EE08544BC5
73 changed files with 344 additions and 340 deletions

View file

@ -1,9 +1,9 @@
minecraft_version=1.16.3
yarn_mappings=1.16.3+build.26
loader_version=0.9.3+build.207
loader_version=0.10.1+build.209
fabric_version=0.21.0+build.407-1.16
libcbe_version = 1.1.0
org.gradle.jvmargs=-Xmx2048m
org.gradle.jvmargs=-Xmx2048m

View file

@ -2,7 +2,6 @@ package org.dimdev.dimdoors;
import java.io.IOException;
import org.dimdev.dimdoors.util.schematic.v2.SchematicTest;
import org.dimdev.dimdoors.block.ModBlocks;
import org.dimdev.dimdoors.block.entity.ModBlockEntityTypes;
import org.dimdev.dimdoors.command.ModCommands;
@ -12,6 +11,7 @@ import org.dimdev.dimdoors.pockets.SchematicHandler;
import org.dimdev.dimdoors.pockets.SchematicV2Handler;
import org.dimdev.dimdoors.rift.targets.Targets;
import org.dimdev.dimdoors.sound.ModSoundEvents;
import org.dimdev.dimdoors.util.schematic.v2.SchematicTest;
import org.dimdev.dimdoors.world.ModBiomes;
import org.dimdev.dimdoors.world.ModDimensions;
import org.dimdev.dimdoors.world.feature.ModFeatures;

View file

@ -8,16 +8,16 @@ import java.nio.file.Path;
import java.util.LinkedHashSet;
import java.util.Set;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.dimdev.dimdoors.util.Codecs;
import org.dimdev.dimdoors.world.limbo.LimboDecay;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonParser;
import com.mojang.serialization.Codec;
import com.mojang.serialization.JsonOps;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.dimdev.dimdoors.util.Codecs;
import org.dimdev.dimdoors.world.limbo.LimboDecay;
import net.fabricmc.loader.api.FabricLoader;

View file

@ -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;

View file

@ -2,6 +2,7 @@ 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;
@ -18,7 +19,6 @@ 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;
@ -61,7 +61,7 @@ public abstract class RiftBlockEntity extends BlockEntity implements BlockEntity
}
protected CompoundTag serialize(CompoundTag tag) {
if(this.data != null) tag.put("data", NbtUtil.serialize(this.data, CODEC));
if (this.data != null) tag.put("data", NbtUtil.serialize(this.data, CODEC));
return tag;
}

View file

@ -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<RiftData> CODEC = RecordCodecBuilder.create(instance -> instance.group(
@ -21,7 +21,8 @@ public class RiftData {
private boolean forcedColor;
private RGBA color = RGBA.NONE;
public RiftData() {}
public RiftData() {
}
private RiftData(VirtualTarget destination, LinkProperties properties, boolean alwaysDelete, boolean forcedColor, RGBA color) {
this.destination = destination;

View file

@ -2,12 +2,12 @@ package org.dimdev.dimdoors.client;
import java.util.Objects;
import com.flowpowered.math.TrigMath;
import org.dimdev.dimdoors.ModConfig;
import org.dimdev.dimdoors.block.entity.DetachedRiftBlockEntity;
import org.dimdev.dimdoors.block.entity.RiftBlockEntity;
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;
@ -55,7 +55,7 @@ public class DetachedRiftBlockEntityRenderer extends BlockEntityRenderer<Detache
matrices.pop();
}
private void renderTesseract( VertexConsumer vc, DetachedRiftBlockEntity rift, MatrixStack matrices, float tickDelta) {
private void renderTesseract(VertexConsumer vc, DetachedRiftBlockEntity rift, MatrixStack matrices, float tickDelta) {
double radian = this.nextAngle(rift, tickDelta) * TrigMath.DEG_TO_RAD;
RGBA color = rift.getColor();
if (Objects.equals(color, RGBA.NONE)) {

View file

@ -5,8 +5,8 @@ import java.util.Random;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import org.dimdev.dimdoors.block.entity.EntranceRiftBlockEntity;
import com.google.common.collect.ImmutableList;
import org.dimdev.dimdoors.block.entity.EntranceRiftBlockEntity;
import net.minecraft.block.BlockState;
import net.minecraft.block.DoorBlock;
@ -69,8 +69,8 @@ public class EntranceRiftBlockEntityRenderer extends BlockEntityRenderer<Entranc
Matrix4f matrix4f = matrices.peek().getModel();
this.drawAllVertices(entrance, u, 0.15F, matrix4f, vertexConsumers.getBuffer(layers.get(0)));
for(int i = 1; i < offset; ++i) {
this.drawAllVertices(entrance, u, 2.0F / (float)(18 - i), matrix4f, vertexConsumers.getBuffer(layers.get(i)));
for (int i = 1; i < offset; ++i) {
this.drawAllVertices(entrance, u, 2.0F / (float) (18 - i), matrix4f, vertexConsumers.getBuffer(layers.get(i)));
}
}

View file

@ -29,7 +29,7 @@ public class LimboSkyProvider extends CustomSkyProvider {
MinecraftClient.getInstance().getTextureManager().bindTexture(EndPortalBlockEntityRenderer.SKY_TEXTURE);
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder bufferBuilder = tessellator.getBuffer();
for(int i = 0; i < 6; ++i) {
for (int i = 0; i < 6; ++i) {
matrices.push();
this.multiply(matrices, i);
Matrix4f matrix4f = matrices.peek().getModel();

View file

@ -8,7 +8,6 @@ import org.dimdev.dimdoors.world.ModDimensions;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.texture.Sprite;
import net.minecraft.client.texture.SpriteAtlasTexture;
import net.minecraft.fluid.Fluid;
import net.minecraft.fluid.FluidState;
import net.minecraft.resource.ResourceManager;

View file

@ -15,22 +15,22 @@ public class MonolithModel extends EntityModel<MonolithEntity> {
private final ModelPart body;
public MonolithModel() {
textureWidth = 256;
textureHeight = 256;
this.textureWidth = 256;
this.textureHeight = 256;
body = new ModelPart(this);
body.setPivot(0.0F, 0.0F, 0.0F);
body.setTextureOffset(0, 0).addCuboid(-24.0F, -108.0F, -6.0F, 48.0F, 108.0F, 12.0F, 0.0F, false);
this.body = new ModelPart(this);
this.body.setPivot(0.0F, 0.0F, 0.0F);
this.body.setTextureOffset(0, 0).addCuboid(-24.0F, -108.0F, -6.0F, 48.0F, 108.0F, 12.0F, 0.0F, false);
}
@Override
public void render(MatrixStack matrixStack, VertexConsumer consumer, int packedLight, int packedOverlay, float red, float green, float blue, float alpha) {
body.render(matrixStack, consumer, packedLight, packedOverlay);
this.body.render(matrixStack, consumer, packedLight, packedOverlay);
}
@Override
public void setAngles(MonolithEntity entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) {
body.yaw = netHeadYaw * 0.017453292F;
body.pitch = headPitch * 0.017453292F;
this.body.yaw = netHeadYaw * 0.017453292F;
this.body.pitch = headPitch * 0.017453292F;
}
}

View file

@ -2,8 +2,8 @@ package org.dimdev.dimdoors.client;
import java.util.List;
import org.dimdev.dimdoors.entity.MonolithEntity;
import com.google.common.collect.Lists;
import org.dimdev.dimdoors.entity.MonolithEntity;
import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.render.entity.LivingEntityRenderer;

View file

@ -3,12 +3,10 @@ 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 static org.lwjgl.opengl.GL11.GL_ONE_MINUS_DST_COLOR;
import static org.lwjgl.opengl.GL11.GL_ZERO;
import org.dimdev.dimdoors.mixin.DirectionAccessor;
import org.lwjgl.opengl.GL11;
import net.minecraft.block.enums.DoorHinge;
import net.minecraft.client.render.RenderLayer;
@ -21,6 +19,9 @@ import net.minecraft.state.property.DirectionProperty;
import net.minecraft.state.property.EnumProperty;
import net.minecraft.util.Identifier;
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");
public static final BooleanProperty OPEN_PROPERTY = BooleanProperty.of("open");

View file

@ -338,12 +338,12 @@ public final class RiftCurves {
@Override
public boolean equals(Object o) {
return o instanceof Point && ((Point) o).x == x && ((Point) o).y == y;
return o instanceof Point && ((Point) o).x == this.x && ((Point) o).y == this.y;
}
@Override
public int hashCode() {
return x * 31 + y;
return this.x * 31 + this.y;
}
}
}

View file

@ -25,13 +25,13 @@ public class RiftParticle extends AnimatedParticle {
this.velocityZ = velocityZ;
scale *= scale;
maxAge = averageAge - ageSpread / 2 + random.nextInt(ageSpread);
this.maxAge = averageAge - ageSpread / 2 + this.random.nextInt(ageSpread);
setColor(color, color, color);
this.setColor(color, color, color);
}
@Override
public void tick() {
setColorAlpha(1 - (float) age / maxAge);
this.setColorAlpha(1 - (float) this.age / this.maxAge);
}
}

View file

@ -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;

View file

@ -1,7 +1,7 @@
package org.dimdev.dimdoors.client.tesseract;
import org.dimdev.dimdoors.util.RGBA;
import com.flowpowered.math.vector.Vector4f;
import org.dimdev.dimdoors.util.RGBA;
import net.minecraft.client.render.VertexConsumer;
import net.minecraft.util.math.Matrix4f;

View file

@ -1,7 +1,7 @@
package org.dimdev.dimdoors.command;
import org.dimdev.dimdoors.ModConfig;
import com.mojang.brigadier.CommandDispatcher;
import org.dimdev.dimdoors.ModConfig;
import net.minecraft.server.command.ServerCommandSource;

View file

@ -1,5 +1,10 @@
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;
@ -11,11 +16,6 @@ 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;

View file

@ -3,11 +3,11 @@ package org.dimdev.dimdoors.command;
import java.io.IOException;
import java.io.InputStream;
import org.dimdev.dimdoors.util.schematic.Schematic;
import org.dimdev.dimdoors.util.schematic.SchematicConverter;
import org.dimdev.dimdoors.command.arguments.SchematicNamespaceArgumentType;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import org.dimdev.dimdoors.command.arguments.SchematicNamespaceArgumentType;
import org.dimdev.dimdoors.util.schematic.Schematic;
import org.dimdev.dimdoors.util.schematic.SchematicConverter;
import net.minecraft.nbt.NbtIo;
import net.minecraft.server.command.ServerCommandSource;

View file

@ -3,17 +3,17 @@ package org.dimdev.dimdoors.command;
import java.io.IOException;
import java.io.InputStream;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.dimdev.dimdoors.util.schematic.v2.Schematic;
import org.dimdev.dimdoors.util.schematic.v2.SchematicPlacer;
import org.dimdev.dimdoors.DimensionalDoorsInitializer;
import org.dimdev.dimdoors.command.arguments.SchematicNamespaceArgumentType;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.dimdev.dimdoors.DimensionalDoorsInitializer;
import org.dimdev.dimdoors.command.arguments.SchematicNamespaceArgumentType;
import org.dimdev.dimdoors.util.schematic.v2.Schematic;
import org.dimdev.dimdoors.util.schematic.v2.SchematicPlacer;
import net.minecraft.nbt.NbtIo;
import net.minecraft.server.command.ServerCommandSource;

View file

@ -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.command.CommandSource;

View file

@ -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.command.CommandSource;

View file

@ -9,7 +9,6 @@ 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;
@ -21,6 +20,7 @@ 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;

View file

@ -87,7 +87,7 @@ public abstract class EternalFluid extends FlowableFluid {
@Override
public int getNextTickDelay(World world, BlockPos blockPos, FluidState fluidState, FluidState fluidState2) {
int tickDelay = getTickRate(world);
int tickDelay = this.getTickRate(world);
if (!fluidState.isEmpty() && !fluidState2.isEmpty() && !fluidState.get(FALLING) && !fluidState2.get(FALLING) && fluidState2.getHeight(world, blockPos) > fluidState.getHeight(world, blockPos) && world.getRandom().nextInt(4) != 0) {
tickDelay *= 4;

View file

@ -67,10 +67,10 @@ public class DimensionalDoorItem extends TallBlockItem {
if (rift == null) {
// Get the rift entity (not hard coded, works with any door size)
@SuppressWarnings("unchecked") // Guaranteed to be IRiftProvider<TileEntityEntranceRift> because of constructor
EntranceRiftBlockEntity entranceRift = ((RiftProvider<EntranceRiftBlockEntity>) state.getBlock()).getRift(context.getWorld(), pos, state);
EntranceRiftBlockEntity entranceRift = ((RiftProvider<EntranceRiftBlockEntity>) state.getBlock()).getRift(context.getWorld(), pos, state);
// Configure the rift to its default functionality
setupRift(entranceRift);
this.setupRift(entranceRift);
// Register the rift in the registry
entranceRift.markDirty();
@ -107,6 +107,6 @@ public class DimensionalDoorItem extends TallBlockItem {
}
public void setupRift(EntranceRiftBlockEntity entranceRift) {
setupFunction.accept(entranceRift);
this.setupFunction.accept(entranceRift);
}
}

View file

@ -44,7 +44,7 @@ public class DimensionalTrapdoorItem extends BlockItem {
EntranceRiftBlockEntity entranceRift = ((RiftProvider<EntranceRiftBlockEntity>) state.getBlock()).getRift(world, pos, state);
// Configure the rift to its default functionality
setupRift(entranceRift);
this.setupRift(entranceRift);
// Register the rift in the registry
entranceRift.markDirty();
@ -55,6 +55,6 @@ public class DimensionalTrapdoorItem extends BlockItem {
}
protected void setupRift(EntranceRiftBlockEntity entranceRift) {
setupFunction.accept(entranceRift);
this.setupFunction.accept(entranceRift);
}
}

View file

@ -70,7 +70,7 @@ public class RiftSignatureItem extends Item {
if (target == null) {
// The link signature has not been used. Store its current target as the first location.
setSource(stack, new RotatedLocation(world.getRegistryKey(), pos, player.yaw, 0));
player.sendMessage(new TranslatableText(getTranslationKey() + ".stored"), true);
player.sendMessage(new TranslatableText(this.getTranslationKey() + ".stored"), true);
world.playSound(null, player.getBlockPos(), ModSoundEvents.RIFT_START, SoundCategory.BLOCKS, 0.6f, 1);
} else {
// Place a rift at the saved point
@ -97,7 +97,7 @@ public class RiftSignatureItem extends Item {
}); // TODO: calculate damage based on position?
clearSource(stack);
player.sendMessage(new TranslatableText(getTranslationKey() + ".created"), true);
player.sendMessage(new TranslatableText(this.getTranslationKey() + ".created"), true);
// null = send sound to the player too, we have to do this because this code is not run client-side
world.playSound(null, player.getBlockPos(), ModSoundEvents.RIFT_END, SoundCategory.BLOCKS, 0.6f, 1);
}
@ -129,9 +129,9 @@ public class RiftSignatureItem extends Item {
public void appendTooltip(ItemStack itemStack, World world, List<Text> list, TooltipContext tooltipContext) {
RotatedLocation transform = getSource(itemStack);
if (transform != null) {
list.add(new TranslatableText(getTranslationKey() + ".bound.info", transform.getX(), transform.getY(), transform.getZ(), transform.getWorldId()));
list.add(new TranslatableText(this.getTranslationKey() + ".bound.info", transform.getX(), transform.getY(), transform.getZ(), transform.getWorldId()));
} else {
list.add(new TranslatableText(getTranslationKey() + ".unbound.info"));
list.add(new TranslatableText(this.getTranslationKey() + ".unbound.info"));
}
}
}

View file

@ -65,7 +65,7 @@ public class StabilizedRiftSignatureItem extends Item { // TODO: common supercla
if (target == null) {
// The link signature has not been used. Store its current target as the first location.
setSource(stack, new RotatedLocation(world.getRegistryKey(), pos, player.yaw, 0));
player.sendMessage(new TranslatableText(getTranslationKey() + ".stored"), true);
player.sendMessage(new TranslatableText(this.getTranslationKey() + ".stored"), true);
world.playSound(null, player.getBlockPos(), ModSoundEvents.RIFT_START, SoundCategory.BLOCKS, 0.6f, 1);
} else {
// Place a rift at the target point
@ -90,7 +90,7 @@ public class StabilizedRiftSignatureItem extends Item { // TODO: common supercla
stack.damage(1, player, playerEntity -> {
});
player.sendMessage(new TranslatableText(getTranslationKey() + ".created"), true);
player.sendMessage(new TranslatableText(this.getTranslationKey() + ".created"), true);
world.playSound(null, player.getBlockPos(), ModSoundEvents.RIFT_END, SoundCategory.BLOCKS, 0.6f, 1);
}
@ -121,9 +121,9 @@ public class StabilizedRiftSignatureItem extends Item { // TODO: common supercla
RotatedLocation transform = getTarget(itemStack);
if (transform != null) {
list.add(new TranslatableText(getTranslationKey() + ".bound.info", transform.getX(), transform.getY(), transform.getZ(), transform.getWorldId()));
list.add(new TranslatableText(this.getTranslationKey() + ".bound.info", transform.getX(), transform.getY(), transform.getZ(), transform.getWorldId()));
} else {
list.add(new TranslatableText(getTranslationKey() + ".unbound.info"));
list.add(new TranslatableText(this.getTranslationKey() + ".unbound.info"));
}
}
}

View file

@ -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;

View file

@ -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;

View file

@ -5,7 +5,6 @@ import java.util.List;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.dimdev.dimdoors.util.schematic.Schematic;
import org.dimdev.dimdoors.DimensionalDoorsInitializer;
import org.dimdev.dimdoors.block.entity.EntranceRiftBlockEntity;
import org.dimdev.dimdoors.block.entity.ModBlockEntityTypes;
@ -13,6 +12,7 @@ import org.dimdev.dimdoors.block.entity.RiftBlockEntity;
import org.dimdev.dimdoors.rift.registry.LinkProperties;
import org.dimdev.dimdoors.rift.targets.VirtualTarget;
import org.dimdev.dimdoors.util.Location;
import org.dimdev.dimdoors.util.schematic.Schematic;
import org.dimdev.dimdoors.world.pocket.Pocket;
import org.dimdev.dimdoors.world.pocket.PocketRegistry;

View file

@ -6,15 +6,13 @@ import java.util.Objects;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.dimdev.dimdoors.util.schematic.v2.Schematic;
import org.dimdev.dimdoors.util.schematic.v2.SchematicPlacer;
import org.dimdev.dimdoors.DimensionalDoorsInitializer;
import org.dimdev.dimdoors.block.entity.EntranceRiftBlockEntity;
import org.dimdev.dimdoors.block.entity.ModBlockEntityTypes;
import org.dimdev.dimdoors.block.entity.RiftBlockEntity;
import org.dimdev.dimdoors.rift.registry.LinkProperties;
import org.dimdev.dimdoors.rift.targets.VirtualTarget;
import org.dimdev.dimdoors.util.Location;
import org.dimdev.dimdoors.util.schematic.v2.Schematic;
import org.dimdev.dimdoors.util.schematic.v2.SchematicPlacer;
import org.dimdev.dimdoors.world.pocket.Pocket;
import net.minecraft.block.entity.BlockEntity;
@ -27,7 +25,7 @@ import net.minecraft.util.math.BlockPos;
public class PocketTemplateV2 {
private static final Logger LOGGER = LogManager.getLogger();
private static boolean replacingPlaceholders = false;
private static final boolean replacingPlaceholders = false;
private final Schematic schematic;
private final String group;
private final int size;
@ -76,7 +74,7 @@ public class PocketTemplateV2 {
public void place(Pocket pocket) {
pocket.setSize(this.size * 16, this.size * 16, this.size * 16);
ServerWorld world = DimensionalDoorsInitializer.getWorld(pocket.world);
BlockPos origin = new BlockPos(pocket.box.minX, pocket.box.minY, pocket.box.minZ);
BlockPos origin = new BlockPos(pocket.box.minX, pocket.box.minY, pocket.box.minZ);
LOGGER.info("Placing new pocket using schematic " + this.id + " at x = " + origin.getX() + ", z = " + origin.getZ());
SchematicPlacer.place(this.schematic, world, origin);
}

View file

@ -23,17 +23,17 @@ import java.util.Map.Entry;
import java.util.Set;
import java.util.stream.Collectors;
import org.apache.commons.io.IOUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.dimdev.dimdoors.util.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 org.apache.commons.io.IOUtils;
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.util.math.MathUtil;
import org.dimdev.dimdoors.util.schematic.Schematic;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtIo;
@ -221,7 +221,8 @@ 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 (!ModConfig.INSTANCE.getPocketsConfig().loadAllSchematics && size > ModConfig.INSTANCE.getPocketsConfig().maxPocketSize) continue;
if (!ModConfig.INSTANCE.getPocketsConfig().loadAllSchematics && size > ModConfig.INSTANCE.getPocketsConfig().maxPocketSize)
continue;
String id = pocket.get("id").getAsString();
String type = pocket.has("type") ? pocket.get("type").getAsString() : null;
String name = pocket.has("name") ? pocket.get("name").getAsString() : null;
@ -301,7 +302,7 @@ public class SchematicHandler { // TODO: parts of this should be moved to the or
// TODO: cache this for faster calls:
Map<PocketTemplate, Float> weightedTemplates = new HashMap<>();
int largestSize = 0;
for (PocketTemplate template : this.templates) {
for (PocketTemplate template : this.templates) {
if (template.getGroup().equals(group) && (maxSize == -1 || template.getSize() <= maxSize)) {
if (getLargest && template.getSize() > largestSize) {
weightedTemplates = new HashMap<>();

View file

@ -12,9 +12,6 @@ import java.util.List;
import java.util.Random;
import java.util.Set;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.dimdev.dimdoors.util.schematic.v2.Schematic;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
@ -23,6 +20,9 @@ import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonObject;
import com.mojang.serialization.JsonOps;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.dimdev.dimdoors.util.schematic.v2.Schematic;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtIo;
@ -41,7 +41,7 @@ public class SchematicV2Handler {
}
public void load() {
if (this.loaded){
if (this.loaded) {
throw new UnsupportedOperationException("Attempted to load schematics twice!");
}
this.loaded = true;
@ -50,7 +50,7 @@ public class SchematicV2Handler {
for (String name : names) {
try (BufferedReader reader = Files.newBufferedReader(Paths.get(SchematicV2Handler.class.getResource(String.format("/data/dimdoors/pockets/json/v2/%s.json", name)).toURI()))) {
List<String> result = new ArrayList<>();
while(true) {
while (true) {
String line = reader.readLine();
if (line == null) {
break;

View file

@ -4,9 +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.dimdoors.util.Codecs;
public class LinkProperties {
public static Codec<LinkProperties> CODEC = RecordCodecBuilder.create(instance -> {
@ -60,15 +60,14 @@ public class LinkProperties {
if (o == this) return true;
if (!(o instanceof LinkProperties)) return false;
final LinkProperties other = (LinkProperties) o;
if (!other.canEqual((Object) this)) return false;
if (!other.canEqual(this)) return false;
if (Float.compare(this.floatingWeight, other.floatingWeight) != 0) return false;
if (Float.compare(this.entranceWeight, other.entranceWeight) != 0) return false;
final Object this$groups = this.groups;
final Object other$groups = other.groups;
if (!Objects.equals(this$groups, other$groups)) return false;
if (this.linksRemaining != other.linksRemaining) return false;
if (this.oneWay != other.oneWay) return false;
return true;
return this.oneWay == other.oneWay;
}
protected boolean canEqual(final Object other) {
@ -131,7 +130,7 @@ public class LinkProperties {
}
public LinkProperties build() {
return new LinkProperties(floatingWeight, entranceWeight, groups, linksRemaining, oneWay);
return new LinkProperties(this.floatingWeight, this.entranceWeight, this.groups, this.linksRemaining, this.oneWay);
}
public String toString() {

View file

@ -2,12 +2,12 @@ package org.dimdev.dimdoors.rift.registry;
import java.util.UUID;
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.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;

View file

@ -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;

View file

@ -18,7 +18,6 @@ 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;
@ -27,6 +26,7 @@ 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();
@ -58,33 +58,33 @@ public class RiftRegistry extends PersistentState {
ListTag riftsNBT = (ListTag) nbt.get("rifts");
for (Tag riftNBT : riftsNBT) {
Rift rift = NbtUtil.deserialize(riftNBT, Rift.CODEC);
graph.addVertex(rift);
uuidMap.put(rift.id, rift);
locationMap.put(rift.location, rift);
this.graph.addVertex(rift);
this.uuidMap.put(rift.id, rift);
this.locationMap.put(rift.location, rift);
}
ListTag pocketsNBT = (ListTag) nbt.get("pockets");
for (Tag pocketNBT : pocketsNBT) {
PocketEntrancePointer pocket = NbtUtil.deserialize(pocketNBT, PocketEntrancePointer.CODEC);
graph.addVertex(pocket);
uuidMap.put(pocket.id, pocket);
pocketEntranceMap.put(PocketRegistry.getInstance(pocket.world).getPocket(pocket.pocketId), pocket);
this.graph.addVertex(pocket);
this.uuidMap.put(pocket.id, pocket);
this.pocketEntranceMap.put(PocketRegistry.getInstance(pocket.world).getPocket(pocket.pocketId), pocket);
}
// Read the connections between links that have a source or destination in this dimension
ListTag linksNBT = (ListTag) nbt.get("links");
for (Tag linkNBT : linksNBT) {
RegistryVertex from = uuidMap.get(((CompoundTag) linkNBT).getUuid("from"));
RegistryVertex to = uuidMap.get(((CompoundTag) linkNBT).getUuid("to"));
RegistryVertex from = this.uuidMap.get(((CompoundTag) linkNBT).getUuid("from"));
RegistryVertex to = this.uuidMap.get(((CompoundTag) linkNBT).getUuid("to"));
if (from != null && to != null) {
graph.addEdge(from, to);
this.graph.addEdge(from, to);
// We need a system for detecting links that are incomplete after processing them in the other subregistry too
}
}
lastPrivatePocketEntrances = readPlayerRiftPointers((ListTag) nbt.get("lastPrivatePocketEntrances"));
lastPrivatePocketExits = readPlayerRiftPointers((ListTag) nbt.get("lastPrivatePocketExits"));
overworldRifts = readPlayerRiftPointers((ListTag) nbt.get("overworldRifts"));
this.lastPrivatePocketEntrances = this.readPlayerRiftPointers((ListTag) nbt.get("lastPrivatePocketEntrances"));
this.lastPrivatePocketExits = this.readPlayerRiftPointers((ListTag) nbt.get("lastPrivatePocketExits"));
this.overworldRifts = this.readPlayerRiftPointers((ListTag) nbt.get("overworldRifts"));
}
@Override
@ -94,7 +94,7 @@ public class RiftRegistry extends PersistentState {
// Write rifts in this dimension
ListTag riftsNBT = new ListTag();
ListTag pocketsNBT = new ListTag();
for (RegistryVertex vertex : graph.vertexSet()) {
for (RegistryVertex vertex : this.graph.vertexSet()) {
CompoundTag vertexNBT = (CompoundTag) NbtUtil.serialize(vertex, RegistryVertex.CODEC);
if (vertex instanceof Rift) {
riftsNBT.add(vertexNBT);
@ -109,9 +109,9 @@ public class RiftRegistry extends PersistentState {
// Write the connections between links that have a source or destination in this dimension
ListTag linksNBT = new ListTag();
for (DefaultEdge edge : graph.edgeSet()) {
RegistryVertex from = graph.getEdgeSource(edge);
RegistryVertex to = graph.getEdgeTarget(edge);
for (DefaultEdge edge : this.graph.edgeSet()) {
RegistryVertex from = this.graph.getEdgeSource(edge);
RegistryVertex to = this.graph.getEdgeTarget(edge);
CompoundTag linkNBT = new CompoundTag();
linkNBT.putUuid("from", from.id);
linkNBT.putUuid("to", to.id);
@ -120,9 +120,9 @@ public class RiftRegistry extends PersistentState {
tag.put("links", linksNBT);
// Subregistries are written automatically when the worlds are saved.
tag.put("lastPrivatePocketEntrances", writePlayerRiftPointers(lastPrivatePocketEntrances));
tag.put("lastPrivatePocketExits", writePlayerRiftPointers(lastPrivatePocketExits));
tag.put("overworldRifts", writePlayerRiftPointers(overworldRifts));
tag.put("lastPrivatePocketEntrances", this.writePlayerRiftPointers(this.lastPrivatePocketEntrances));
tag.put("lastPrivatePocketExits", this.writePlayerRiftPointers(this.lastPrivatePocketExits));
tag.put("overworldRifts", this.writePlayerRiftPointers(this.overworldRifts));
return tag;
}
@ -133,9 +133,9 @@ public class RiftRegistry extends PersistentState {
UUID rift = ((CompoundTag) entryNBT).getUuid("rift");
PlayerRiftPointer pointer = new PlayerRiftPointer(player);
pointerMap.put(player, pointer);
uuidMap.put(pointer.id, pointer);
graph.addVertex(pointer);
graph.addEdge(pointer, uuidMap.get(rift));
this.uuidMap.put(pointer.id, pointer);
this.graph.addVertex(pointer);
this.graph.addEdge(pointer, this.uuidMap.get(rift));
}
return pointerMap;
}
@ -146,8 +146,8 @@ public class RiftRegistry extends PersistentState {
CompoundTag entryNBT = new CompoundTag();
entryNBT.putUuid("player", entry.getKey());
int count = 0;
for (DefaultEdge edge : graph.outgoingEdgesOf(entry.getValue())) {
entryNBT.putUuid("rift", graph.getEdgeTarget(edge).id);
for (DefaultEdge edge : this.graph.outgoingEdgesOf(entry.getValue())) {
entryNBT.putUuid("rift", this.graph.getEdgeTarget(edge).id);
count++;
}
if (count != 1) throw new RuntimeException("PlayerRiftPointer points to more than one rift");
@ -157,73 +157,73 @@ public class RiftRegistry extends PersistentState {
}
public boolean isRiftAt(Location location) {
Rift possibleRift = locationMap.get(location);
Rift possibleRift = this.locationMap.get(location);
return possibleRift != null && !(possibleRift instanceof RiftPlaceholder);
}
public Rift getRift(Location location) {
Rift rift = locationMap.get(location);
Rift rift = this.locationMap.get(location);
if (rift == null) throw new IllegalArgumentException("There is no rift registered at " + location);
return rift;
}
private Rift getRiftOrPlaceholder(Location location) {
Rift rift = locationMap.get(location);
Rift rift = this.locationMap.get(location);
if (rift == null) {
LOGGER.debug("Creating a rift placeholder at " + location);
rift = new RiftPlaceholder();
rift.world = location.world;
rift.location = location;
locationMap.put(location, rift);
uuidMap.put(rift.id, rift);
graph.addVertex(rift);
this.locationMap.put(location, rift);
this.uuidMap.put(rift.id, rift);
this.graph.addVertex(rift);
}
return rift;
}
public void addRift(Location location) {
LOGGER.debug("Adding rift at " + location);
RegistryVertex currentRift = locationMap.get(location);
RegistryVertex currentRift = this.locationMap.get(location);
Rift rift;
if (currentRift instanceof RiftPlaceholder) {
LOGGER.info("Converting a rift placeholder at " + location + " into a rift");
rift = new Rift(location);
rift.world = location.world;
rift.id = currentRift.id;
GraphUtils.replaceVertex(graph, currentRift, rift);
GraphUtils.replaceVertex(this.graph, currentRift, rift);
} else if (currentRift == null) {
rift = new Rift(location);
rift.world = location.world;
graph.addVertex(rift);
this.graph.addVertex(rift);
} else {
throw new IllegalArgumentException("There is already a rift registered at " + location);
}
uuidMap.put(rift.id, rift);
locationMap.put(location, rift);
this.uuidMap.put(rift.id, rift);
this.locationMap.put(location, rift);
rift.markDirty();
}
public void removeRift(Location location) {
LOGGER.debug("Removing rift at " + location);
Rift rift = getRift(location);
Rift rift = this.getRift(location);
Set<DefaultEdge> incomingEdges = graph.incomingEdgesOf(rift);
Set<DefaultEdge> outgoingEdges = graph.outgoingEdgesOf(rift);
Set<DefaultEdge> incomingEdges = this.graph.incomingEdgesOf(rift);
Set<DefaultEdge> outgoingEdges = this.graph.outgoingEdgesOf(rift);
graph.removeVertex(rift);
locationMap.remove(location);
uuidMap.remove(rift.id);
this.graph.removeVertex(rift);
this.locationMap.remove(location);
this.uuidMap.remove(rift.id);
// Notify the adjacent vertices of the change
for (DefaultEdge edge : incomingEdges) graph.getEdgeSource(edge).targetGone(rift);
for (DefaultEdge edge : outgoingEdges) graph.getEdgeTarget(edge).sourceGone(rift);
for (DefaultEdge edge : incomingEdges) this.graph.getEdgeSource(edge).targetGone(rift);
for (DefaultEdge edge : outgoingEdges) this.graph.getEdgeTarget(edge).sourceGone(rift);
}
private void addEdge(RegistryVertex from, RegistryVertex to) {
graph.addEdge(from, to);
this.graph.addEdge(from, to);
if (from instanceof PlayerRiftPointer) {
markDirty();
this.markDirty();
} else if (from instanceof Rift) {
((Rift) from).markDirty();
}
@ -233,20 +233,20 @@ public class RiftRegistry extends PersistentState {
}
private void removeEdge(RegistryVertex from, RegistryVertex to) {
graph.removeEdge(from, to);
this.graph.removeEdge(from, to);
if (from instanceof PlayerRiftPointer) {
markDirty();
this.markDirty();
}
}
public void addLink(Location locationFrom, Location locationTo) {
LOGGER.debug("Adding link " + locationFrom + " -> " + locationTo);
Rift from = getRiftOrPlaceholder(locationFrom);
Rift to = getRiftOrPlaceholder(locationTo);
Rift from = this.getRiftOrPlaceholder(locationFrom);
Rift to = this.getRiftOrPlaceholder(locationTo);
addEdge(from, to);
this.addEdge(from, to);
// Notify the linked vertices of the change
if (!(from instanceof RiftPlaceholder) && !(to instanceof RiftPlaceholder)) {
@ -258,10 +258,10 @@ public class RiftRegistry extends PersistentState {
public void removeLink(Location locationFrom, Location locationTo) {
LOGGER.debug("Removing link " + locationFrom + " -> " + locationTo);
Rift from = getRift(locationFrom);
Rift to = getRift(locationTo);
Rift from = this.getRift(locationFrom);
Rift to = this.getRift(locationTo);
removeEdge(from, to);
this.removeEdge(from, to);
// Notify the linked vertices of the change
from.targetGone(to);
@ -270,18 +270,18 @@ public class RiftRegistry extends PersistentState {
public void setProperties(Location location, LinkProperties properties) {
LOGGER.debug("Setting DungeonLinkProperties for rift at " + location + " to " + properties);
Rift rift = getRift(location);
Rift rift = this.getRift(location);
rift.properties = properties;
rift.markDirty();
}
public Set<Location> getPocketEntrances(Pocket pocket) {
PocketEntrancePointer pointer = pocketEntranceMap.get(pocket);
PocketEntrancePointer pointer = this.pocketEntranceMap.get(pocket);
if (pointer == null) {
return Collections.emptySet();
} else {
return graph.outgoingEdgesOf(pointer).stream()
.map(graph::getEdgeTarget)
return this.graph.outgoingEdgesOf(pointer).stream()
.map(this.graph::getEdgeTarget)
.map(Rift.class::cast)
.map(rift -> rift.location)
.collect(Collectors.toSet());
@ -289,91 +289,91 @@ public class RiftRegistry extends PersistentState {
}
public Location getPocketEntrance(Pocket pocket) {
return getPocketEntrances(pocket).stream().findFirst().orElse(null);
return this.getPocketEntrances(pocket).stream().findFirst().orElse(null);
}
public void addPocketEntrance(Pocket pocket, Location location) {
LOGGER.debug("Adding pocket entrance for pocket " + pocket.id + " in dimension " + pocket.world + " at " + location);
PocketEntrancePointer pointer = pocketEntranceMap.get(pocket);
PocketEntrancePointer pointer = this.pocketEntranceMap.get(pocket);
if (pointer == null) {
pointer = new PocketEntrancePointer(pocket.world, pocket.id);
pointer.world = pocket.world;
graph.addVertex(pointer);
pocketEntranceMap.put(pocket, pointer);
uuidMap.put(pointer.id, pointer);
this.graph.addVertex(pointer);
this.pocketEntranceMap.put(pocket, pointer);
this.uuidMap.put(pointer.id, pointer);
}
Rift rift = getRift(location);
addEdge(pointer, rift);
Rift rift = this.getRift(location);
this.addEdge(pointer, rift);
}
public Location getPrivatePocketEntrance(UUID playerUUID) {
// Try to get the last used entrance
PlayerRiftPointer entrancePointer = lastPrivatePocketEntrances.get(playerUUID);
Rift entrance = (Rift) GraphUtils.followPointer(graph, entrancePointer);
PlayerRiftPointer entrancePointer = this.lastPrivatePocketEntrances.get(playerUUID);
Rift entrance = (Rift) GraphUtils.followPointer(this.graph, entrancePointer);
if (entrance != null) return entrance.location;
// If there was no last used private entrance, get the first player's private pocket entrance
return getPocketEntrance(PrivatePocketData.instance().getPrivatePocket(playerUUID));
return this.getPocketEntrance(PrivatePocketData.instance().getPrivatePocket(playerUUID));
}
private void setPlayerRiftPointer(UUID playerUUID, Location rift, Map<UUID, PlayerRiftPointer> map) {
PlayerRiftPointer pointer = map.get(playerUUID);
if (pointer != null) {
graph.removeVertex(pointer);
this.graph.removeVertex(pointer);
map.remove(playerUUID);
uuidMap.remove(pointer.id);
this.uuidMap.remove(pointer.id);
}
if (rift != null) {
pointer = new PlayerRiftPointer(playerUUID);
graph.addVertex(pointer);
this.graph.addVertex(pointer);
map.put(playerUUID, pointer);
uuidMap.put(pointer.id, pointer);
addEdge(pointer, getRift(rift));
this.uuidMap.put(pointer.id, pointer);
this.addEdge(pointer, this.getRift(rift));
}
}
public void setLastPrivatePocketEntrance(UUID playerUUID, Location rift) {
LOGGER.debug("Setting last used private pocket entrance for " + playerUUID + " at " + rift);
setPlayerRiftPointer(playerUUID, rift, lastPrivatePocketEntrances);
this.setPlayerRiftPointer(playerUUID, rift, this.lastPrivatePocketEntrances);
}
public Location getPrivatePocketExit(UUID playerUUID) {
PlayerRiftPointer entrancePointer = lastPrivatePocketExits.get(playerUUID);
Rift entrance = (Rift) GraphUtils.followPointer(graph, entrancePointer);
PlayerRiftPointer entrancePointer = this.lastPrivatePocketExits.get(playerUUID);
Rift entrance = (Rift) GraphUtils.followPointer(this.graph, entrancePointer);
return entrance != null ? entrance.location : null;
}
public void setLastPrivatePocketExit(UUID playerUUID, Location rift) {
LOGGER.debug("Setting last used private pocket exit for " + playerUUID + " at " + rift);
setPlayerRiftPointer(playerUUID, rift, lastPrivatePocketExits);
this.setPlayerRiftPointer(playerUUID, rift, this.lastPrivatePocketExits);
}
public Location getOverworldRift(UUID playerUUID) {
PlayerRiftPointer entrancePointer = overworldRifts.get(playerUUID);
Rift rift = (Rift) GraphUtils.followPointer(graph, entrancePointer);
PlayerRiftPointer entrancePointer = this.overworldRifts.get(playerUUID);
Rift rift = (Rift) GraphUtils.followPointer(this.graph, entrancePointer);
return rift != null ? rift.location : null;
}
public void setOverworldRift(UUID playerUUID, Location rift) {
LOGGER.debug("Setting last used overworld rift for " + playerUUID + " at " + rift);
setPlayerRiftPointer(playerUUID, rift, overworldRifts);
this.setPlayerRiftPointer(playerUUID, rift, this.overworldRifts);
}
public Collection<Rift> getRifts() {
return locationMap.values();
return this.locationMap.values();
}
public Set<Location> getTargets(Location location) {
return graph.outgoingEdgesOf(getRift(location)).stream()
.map(graph::getEdgeTarget)
return this.graph.outgoingEdgesOf(this.getRift(location)).stream()
.map(this.graph::getEdgeTarget)
.map(Rift.class::cast)
.map(rift -> rift.location)
.collect(Collectors.toSet());
}
public Set<Location> getSources(Location location) {
return graph.incomingEdgesOf(getRift(location)).stream()
.map(graph::getEdgeTarget)
return this.graph.incomingEdgesOf(this.getRift(location)).stream()
.map(this.graph::getEdgeTarget)
.map(Rift.class::cast)
.map(rift -> rift.location)
.collect(Collectors.toSet());

View file

@ -2,20 +2,21 @@ 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<EscapeTarget> CODEC = RecordCodecBuilder.create(instance -> {
return instance.group(

View file

@ -1,7 +1,7 @@
package org.dimdev.dimdoors.rift.targets;
import org.dimdev.dimdoors.util.Location;
import com.mojang.serialization.Codec;
import org.dimdev.dimdoors.util.Location;
public class GlobalReference extends RiftReference {
public static Codec<GlobalReference> CODEC = Location.CODEC.fieldOf("location").xmap(GlobalReference::new, GlobalReference::getReferencedLocation).codec();
@ -14,7 +14,7 @@ public class GlobalReference extends RiftReference {
@Override
public Location getReferencedLocation() {
return target;
return this.target;
}
@Override

View file

@ -1,7 +1,7 @@
package org.dimdev.dimdoors.rift.targets;
import org.dimdev.dimdoors.util.Location;
import com.mojang.serialization.Codec;
import org.dimdev.dimdoors.util.Location;
import net.minecraft.util.math.BlockPos;

View file

@ -8,8 +8,8 @@ import net.minecraft.text.TranslatableText;
@SuppressWarnings("OverloadedVarargsMethod")
public class MessageTarget implements EntityTarget {
private Target forwardTo;
private String message;
private Object[] messageParams;
private final String message;
private final Object[] messageParams;
public MessageTarget(Target forwardTo, String message, Object... messageParams) {
this.forwardTo = forwardTo;
@ -24,10 +24,10 @@ public class MessageTarget implements EntityTarget {
@Override
public boolean receiveEntity(Entity entity, float yawOffset) {
EntityUtils.chat(entity, new TranslatableText(message, messageParams));
EntityUtils.chat(entity, new TranslatableText(this.message, this.messageParams));
if (forwardTo != null) {
forwardTo.as(Targets.ENTITY).receiveEntity(entity, yawOffset);
if (this.forwardTo != null) {
this.forwardTo.as(Targets.ENTITY).receiveEntity(entity, yawOffset);
return true;
} else {
return false;

View file

@ -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;
@ -41,23 +41,23 @@ public class PocketEntranceMarker extends VirtualTarget implements EntityTarget
}
public float getWeight() {
return weight;
return this.weight;
}
public VirtualTarget getIfDestination() {
return ifDestination;
return this.ifDestination;
}
public VirtualTarget getOtherwiseDestination() {
return otherwiseDestination;
return this.otherwiseDestination;
}
public String toString() {
return "PocketEntranceMarker(weight=" + getWeight() + ", ifDestination=" + getIfDestination() + ", otherwiseDestination=" + getOtherwiseDestination() + ")";
return "PocketEntranceMarker(weight=" + this.getWeight() + ", ifDestination=" + this.getIfDestination() + ", otherwiseDestination=" + this.getOtherwiseDestination() + ")";
}
public PocketEntranceMarkerBuilder toBuilder() {
return new PocketEntranceMarkerBuilder().weight(weight).ifDestination(ifDestination).otherwiseDestination(otherwiseDestination);
return new PocketEntranceMarkerBuilder().weight(this.weight).ifDestination(this.ifDestination).otherwiseDestination(this.otherwiseDestination);
}
@Override
@ -89,11 +89,11 @@ public class PocketEntranceMarker extends VirtualTarget implements EntityTarget
}
public PocketEntranceMarker build() {
return new PocketEntranceMarker(weight, ifDestination, otherwiseDestination);
return new PocketEntranceMarker(this.weight, this.ifDestination, this.otherwiseDestination);
}
public String toString() {
return "PocketEntranceMarker.PocketEntranceMarkerBuilder(weight=" + weight + ", ifDestination=" + ifDestination + ", otherwiseDestination=" + otherwiseDestination + ")";
return "PocketEntranceMarker.PocketEntranceMarkerBuilder(weight=" + this.weight + ", ifDestination=" + this.ifDestination + ", otherwiseDestination=" + this.otherwiseDestination + ")";
}
}
}

View file

@ -1,7 +1,7 @@
package org.dimdev.dimdoors.rift.targets;
import org.dimdev.dimdoors.util.EntityUtils;
import com.mojang.serialization.Codec;
import org.dimdev.dimdoors.util.EntityUtils;
import net.minecraft.entity.Entity;
import net.minecraft.text.TranslatableText;

View file

@ -2,6 +2,7 @@ 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;
@ -11,7 +12,6 @@ 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;
@ -33,8 +33,8 @@ public class PrivatePocketExitTarget extends VirtualTarget implements EntityTarg
if (uuid != null) {
destLoc = RiftRegistry.instance().getPrivatePocketExit(uuid);
Pocket pocket = PrivatePocketData.instance().getPrivatePocket(uuid);
if (ModDimensions.isDimDoorsPocketDimension(location.getWorld()) && pocket != null && PocketRegistry.getInstance(pocket.world).getPocketAt(location.pos).equals(pocket)) {
RiftRegistry.instance().setLastPrivatePocketEntrance(uuid, location); // Remember which exit was used for next time the pocket is entered
if (ModDimensions.isDimDoorsPocketDimension(this.location.getWorld()) && pocket != null && PocketRegistry.getInstance(pocket.world).getPocketAt(this.location.pos).equals(pocket)) {
RiftRegistry.instance().setLastPrivatePocketEntrance(uuid, this.location); // Remember which exit was used for next time the pocket is entered
}
if (destLoc == null || !(destLoc.getBlockEntity() instanceof RiftBlockEntity)) {
if (destLoc == null) {
@ -56,9 +56,9 @@ public class PrivatePocketExitTarget extends VirtualTarget implements EntityTarg
@Override
public void register() {
super.register();
PocketRegistry privatePocketRegistry = PocketRegistry.getInstance(location.world);
Pocket pocket = privatePocketRegistry.getPocketAt(location.pos);
RiftRegistry.instance().addPocketEntrance(pocket, location);
PocketRegistry privatePocketRegistry = PocketRegistry.getInstance(this.location.world);
Pocket pocket = privatePocketRegistry.getPocketAt(this.location.pos);
RiftRegistry.instance().addPocketEntrance(pocket, this.location);
}
@Override

View file

@ -2,6 +2,7 @@ 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;
@ -12,7 +13,6 @@ 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;

View file

@ -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<PublicPocketTarget> CODEC = RecordCodecBuilder.create(instance -> {

View file

@ -5,6 +5,10 @@ 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.dimdoors.DimensionalDoorsInitializer;
import org.dimdev.dimdoors.block.ModBlocks;
import org.dimdev.dimdoors.block.entity.DetachedRiftBlockEntity;
@ -17,10 +21,6 @@ import org.dimdev.dimdoors.util.Location;
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;
@ -75,7 +75,8 @@ public class RandomTarget extends VirtualTarget { // TODO: Split into DungeonTar
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(this.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 (otherRift.properties.linksRemaining == 0) continue;

View file

@ -1,7 +1,7 @@
package org.dimdev.dimdoors.rift.targets;
import org.dimdev.dimdoors.util.Location;
import com.mojang.serialization.Codec;
import org.dimdev.dimdoors.util.Location;
import net.minecraft.util.math.Vec3i;

View file

@ -10,18 +10,18 @@ public abstract class RestoringTarget extends VirtualTarget {
@Override
public Target receiveOther() {
if (getTarget() != null) {
getTarget().location = location;
return getTarget();
if (this.getTarget() != null) {
this.getTarget().location = this.location;
return this.getTarget();
}
Location linkTarget = makeLinkTarget();
Location linkTarget = this.makeLinkTarget();
if (linkTarget != null) {
setTarget(RiftReference.tryMakeLocal(location, linkTarget));
getTarget().setLocation(location);
getTarget().register();
this.setTarget(RiftReference.tryMakeLocal(this.location, linkTarget));
this.getTarget().setLocation(this.location);
this.getTarget().register();
return getTarget();
return this.getTarget();
} else {
return null;
}
@ -29,8 +29,8 @@ public abstract class RestoringTarget extends VirtualTarget {
@Override
public boolean shouldInvalidate(Location deletedRift) {
if (getTarget().shouldInvalidate(deletedRift)) {
getTarget().unregister();
if (this.getTarget().shouldInvalidate(deletedRift)) {
this.getTarget().unregister();
}
return false;
}
@ -38,14 +38,14 @@ public abstract class RestoringTarget extends VirtualTarget {
@Override
public void setLocation(Location location) {
super.setLocation(location);
if (getTarget() != null) {
getTarget().setLocation(location);
if (this.getTarget() != null) {
this.getTarget().setLocation(location);
}
}
@Override
public void unregister() {
if (getTarget() != null) getTarget().unregister();
if (this.getTarget() != null) this.getTarget().unregister();
}
protected abstract VirtualTarget getTarget();
@ -54,11 +54,11 @@ public abstract class RestoringTarget extends VirtualTarget {
@Override
public RGBA getColor() {
if (getTarget() != null) {
getTarget().location = location;
return getTarget().getColor();
if (this.getTarget() != null) {
this.getTarget().location = this.location;
return this.getTarget().getColor();
} else {
return getUnlinkedColor(location);
return this.getUnlinkedColor(this.location);
}
}

View file

@ -43,23 +43,23 @@ public abstract class RiftReference extends VirtualTarget {
@Override
public Target receiveOther() {
return (Target) getReferencedLocation().getBlockEntity();
return (Target) this.getReferencedLocation().getBlockEntity();
}
@Override
public void register() {
RiftRegistry.instance().addLink(location, getReferencedLocation());
RiftRegistry.instance().addLink(this.location, this.getReferencedLocation());
}
@Override
public void unregister() {
RiftRegistry.instance().removeLink(location, getReferencedLocation());
RiftRegistry.instance().removeLink(this.location, this.getReferencedLocation());
}
@Override
public boolean shouldInvalidate(Location deletedRift) {
// A rift we may have asked the registry to notify us about was deleted
return deletedRift.equals(getReferencedLocation());
return deletedRift.equals(this.getReferencedLocation());
}
@Override
@ -69,10 +69,10 @@ public abstract class RiftReference extends VirtualTarget {
@Override
public RGBA getColor() {
Location target = getReferencedLocation();
Location target = this.getReferencedLocation();
if (target != null && RiftRegistry.instance().isRiftAt(target)) {
Set<Location> otherRiftTargets = RiftRegistry.instance().getTargets(target);
if (otherRiftTargets.size() == 1 && otherRiftTargets.contains(location)) {
if (otherRiftTargets.size() == 1 && otherRiftTargets.contains(this.location)) {
return new RGBA(0, 1, 0, 1);
}
}

View file

@ -10,10 +10,10 @@ public interface Target {
}
default <T extends Target> T as(Class<T> type) {
if (type.isAssignableFrom(getClass())) {
if (type.isAssignableFrom(this.getClass())) {
return type.cast(this);
} else {
Target forwardTo = receiveOther();
Target forwardTo = this.receiveOther();
if (forwardTo != null) {
return forwardTo.as(type);
} else {

View file

@ -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;

View file

@ -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;

View file

@ -7,10 +7,12 @@ import net.minecraft.nbt.Tag;
public class NbtUtil {
public static <T> T deserialize(Tag data, Codec<T> codec) {
return NbtOps.INSTANCE.withParser(codec).apply(data).getOrThrow(true, a -> {});
return NbtOps.INSTANCE.withParser(codec).apply(data).getOrThrow(true, a -> {
});
}
public static <T> Tag serialize(T data, Codec<T> codec) {
return NbtOps.INSTANCE.withEncoder(codec).apply(data).getOrThrow(true, a -> {});
return NbtOps.INSTANCE.withEncoder(codec).apply(data).getOrThrow(true, a -> {
});
}
}

View file

@ -4,9 +4,9 @@ import java.util.Iterator;
import java.util.Objects;
import java.util.function.Consumer;
import org.jetbrains.annotations.NotNull;
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import org.jetbrains.annotations.NotNull;
public final class RGBA implements Cloneable, Comparable<RGBA>, Iterable<Float> {
public static final RGBA NONE = new RGBA(-1, -1, -1, -1);

View file

@ -25,8 +25,7 @@ public final class TeleportUtil {
if (entity instanceof ServerPlayerEntity) {
((ServerPlayerEntity) entity).teleport((ServerWorld) world, pos.x, pos.y, pos.z, entity.getYaw(1.0F) + yawOffset, entity.getPitch(1.0F));
}
else if (entity.world.getRegistryKey().equals(world.getRegistryKey())) {
} else if (entity.world.getRegistryKey().equals(world.getRegistryKey())) {
entity.setPos(pos.x, pos.y, pos.z);
entity.setYaw(entity.yaw + yawOffset);
} else {

View file

@ -58,7 +58,7 @@ public class Schematic implements BlockView {
public List<CompoundTag> entities = new ArrayList<>();
public Schematic() {
paletteMax = -1;
this.paletteMax = -1;
}
public Schematic(short width, short height, short length) {
@ -66,10 +66,10 @@ public class Schematic implements BlockView {
this.sizeX = width;
this.sizeY = height;
this.sizeZ = length;
blockData = new short[width][height][length];
palette.add(Blocks.AIR.getDefaultState());
paletteMax++;
creationDate = System.currentTimeMillis();
this.blockData = new short[width][height][length];
this.palette.add(Blocks.AIR.getDefaultState());
this.paletteMax++;
this.creationDate = System.currentTimeMillis();
}
public Schematic(String name, String author, short width, short height, short length) {
@ -191,46 +191,46 @@ public class Schematic implements BlockView {
public CompoundTag saveToNBT() {
CompoundTag nbt = new CompoundTag();
nbt.putInt("Version", version);
nbt.putInt("Version", this.version);
CompoundTag metadataCompound = new CompoundTag();
if (author != null) {
metadataCompound.putString("Author", author);
if (this.author != null) {
metadataCompound.putString("Author", this.author);
}
metadataCompound.putString("Name", name);
if (creationDate != -1) metadataCompound.putLong("Date", creationDate);
metadataCompound.putString("Name", this.name);
if (this.creationDate != -1) metadataCompound.putLong("Date", this.creationDate);
ListTag requiredModsTagList = new ListTag();
for (String requiredMod : requiredMods) {
for (String requiredMod : this.requiredMods) {
requiredModsTagList.add(StringTag.of(requiredMod));
}
metadataCompound.put("RequiredMods", requiredModsTagList);
nbt.put("Metadata", metadataCompound);
nbt.putShort("Width", sizeX);
nbt.putShort("Height", sizeY);
nbt.putShort("Length", sizeZ);
nbt.putIntArray("Offset", offset);
nbt.putInt("PaletteMax", paletteMax);
nbt.putShort("Width", this.sizeX);
nbt.putShort("Height", this.sizeY);
nbt.putShort("Length", this.sizeZ);
nbt.putIntArray("Offset", this.offset);
nbt.putInt("PaletteMax", this.paletteMax);
CompoundTag paletteNBT = new CompoundTag();
for (int i = 0; i < palette.size(); i++) {
BlockState state = palette.get(i);
for (int i = 0; i < this.palette.size(); i++) {
BlockState state = this.palette.get(i);
String blockStateString = getBlockStateStringFromState(state);
paletteNBT.putInt(blockStateString, i);
}
nbt.put("Palette", paletteNBT);
byte[] blockDataIntArray = new byte[sizeX * sizeY * sizeZ];
byte[] blockDataIntArray = new byte[this.sizeX * this.sizeY * this.sizeZ];
for (int x = 0; x < sizeX; x++) {
for (int y = 0; y < sizeY; y++) {
for (int z = 0; z < sizeZ; z++) {
blockDataIntArray[x + z * sizeX + y * sizeX * sizeZ] = (byte) blockData[x][y][z]; //according to the documentation on https://github.com/SpongePowered/Schematic-Specification/blob/master/versions/schematic-1.md
for (int x = 0; x < this.sizeX; x++) {
for (int y = 0; y < this.sizeY; y++) {
for (int z = 0; z < this.sizeZ; z++) {
blockDataIntArray[x + z * this.sizeX + y * this.sizeX * this.sizeZ] = (byte) this.blockData[x][y][z]; //according to the documentation on https://github.com/SpongePowered/Schematic-Specification/blob/master/versions/schematic-1.md
}
}
}
@ -238,11 +238,11 @@ public class Schematic implements BlockView {
nbt.putByteArray("BlockData", blockDataIntArray);
ListTag tileEntitiesTagList = new ListTag();
tileEntitiesTagList.addAll(tileEntities);
tileEntitiesTagList.addAll(this.tileEntities);
nbt.put("TileEntities", tileEntitiesTagList);
ListTag entitiesTagList = new ListTag();
entitiesTagList.addAll(entities);
entitiesTagList.addAll(this.entities);
nbt.put("Entities", entitiesTagList);
return nbt;
@ -367,7 +367,7 @@ public class Schematic implements BlockView {
this.setBlocks(world, xBase, yBase, zBase);
// Set BlockEntity data
for (CompoundTag BlockEntityNBT : tileEntities) {
for (CompoundTag BlockEntityNBT : this.tileEntities) {
Vec3i schematicPos = new BlockPos(BlockEntityNBT.getInt("x"), BlockEntityNBT.getInt("y"), BlockEntityNBT.getInt("z"));
BlockPos pos = new BlockPos(xBase, yBase, zBase).add(schematicPos);
BlockEntity blockEntity = world.getBlockEntity(pos);
@ -406,19 +406,19 @@ public class Schematic implements BlockView {
}
public BlockState getBlockState(int x, int y, int z) {
if (x < 0 || x >= sizeX || y < 0 || y >= sizeY || z < 0 || z >= sizeZ) {
if (x < 0 || x >= this.sizeX || y < 0 || y >= this.sizeY || z < 0 || z >= this.sizeZ) {
return Blocks.AIR.getDefaultState();
}
return palette.get(blockData[x][y][z]);
return this.palette.get(this.blockData[x][y][z]);
}
public void setBlockState(int x, int y, int z, BlockState state) {
if (palette.contains(state)) {
blockData[x][y][z] = (short) palette.indexOf(state); // TODO: optimize this (there must be some efficient list implementations)
if (this.palette.contains(state)) {
this.blockData[x][y][z] = (short) this.palette.indexOf(state); // TODO: optimize this (there must be some efficient list implementations)
} else {
palette.add(state);
blockData[x][y][z] = (short) ++paletteMax;
this.palette.add(state);
this.blockData[x][y][z] = (short) ++this.paletteMax;
}
}
@ -427,13 +427,13 @@ public class Schematic implements BlockView {
long setTime = 0;
long relightTime = 0;
for (int cx = 0; cx <= (sizeX >> 4) + 1; cx++) {
for (int cz = 0; cz <= (sizeZ >> 4) + 1; cz++) {
for (int cx = 0; cx <= (this.sizeX >> 4) + 1; cx++) {
for (int cz = 0; cz <= (this.sizeZ >> 4) + 1; cz++) {
long setStart = System.nanoTime();
Chunk chunk = world.getChunk((originX >> 4) + cx, (originZ >> 4) + cz);
ChunkSection[] sections = chunk.getSectionArray();
for (int cy = 0; cy <= (sizeY >> 4) + 1; cy++) {
for (int cy = 0; cy <= (this.sizeY >> 4) + 1; cy++) {
ChunkSection section = sections[(originY >> 4) + cy];
boolean setAir = true;
@ -450,8 +450,8 @@ public class Schematic implements BlockView {
int y = (cy << 4) + ly - (originY & 0x0F);
int z = (cz << 4) + lz - (originZ & 0x0F);
if (x >= 0 && y >= 0 && z >= 0 && x < sizeX && y < sizeY && z < sizeZ) {
BlockState state = palette.get(blockData[x][y][z]);
if (x >= 0 && y >= 0 && z >= 0 && x < this.sizeX && y < this.sizeY && z < this.sizeZ) {
BlockState state = this.palette.get(this.blockData[x][y][z]);
if (setAir || !state.getBlock().equals(Blocks.AIR)) {
section.setBlockState(lx, ly, lz, state);
@ -503,7 +503,7 @@ public class Schematic implements BlockView {
@Override
public BlockState getBlockState(BlockPos blockPos) {
return getBlockState(blockPos.getX(), blockPos.getY(), blockPos.getZ());
return this.getBlockState(blockPos.getX(), blockPos.getY(), blockPos.getZ());
}
@Override

View file

@ -20,8 +20,8 @@ public class SchematicStorage {
public Schematic get(Identifier id) {
try {
return cache.get(id, () -> {
try (InputStream in = resourceManager.getResource(id).getInputStream()) {
return this.cache.get(id, () -> {
try (InputStream in = this.resourceManager.getResource(id).getInputStream()) {
return Schematic.fromTag(NbtIo.readCompressed(in));
}
}

View file

@ -4,11 +4,11 @@ import java.util.Map;
import java.util.Objects;
import io.github.boogiemonster1o1.libcbe.api.ConditionalBlockEntityProvider;
import org.jetbrains.annotations.Nullable;
import com.google.common.collect.BiMap;
import com.google.common.collect.ImmutableBiMap;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Maps;
import org.jetbrains.annotations.Nullable;
import net.minecraft.block.Block;
import net.minecraft.block.BlockEntityProvider;

View file

@ -3,10 +3,10 @@ package org.dimdev.dimdoors.util.schematic.v2;
import java.util.List;
import java.util.Objects;
import com.google.common.collect.ImmutableList;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.dimdev.dimdoors.mixin.ListTagAccessor;
import com.google.common.collect.ImmutableList;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;

View file

@ -5,10 +5,10 @@ import java.nio.ByteBuffer;
import java.nio.file.Files;
import java.nio.file.Path;
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;

View file

@ -3,12 +3,12 @@ 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.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;

View file

@ -2,10 +2,10 @@ package org.dimdev.dimdoors.world.feature.gateway;
import java.util.Set;
import com.google.common.collect.ImmutableSet;
import org.dimdev.dimdoors.block.ModBlocks;
import org.dimdev.dimdoors.world.ModBiomes;
import org.dimdev.dimdoors.world.ModDimensions;
import com.google.common.collect.ImmutableSet;
import net.minecraft.block.BlockState;
import net.minecraft.util.math.BlockPos;

View file

@ -15,6 +15,6 @@ public class SandstonePillarsV2Gateway extends SchematicV2Gateway {
@Override
public Set<RegistryKey<Biome>> getBiomes() {
return ImmutableSet.of( BiomeKeys.DESERT, BiomeKeys.DESERT_LAKES, BiomeKeys.DESERT_HILLS);
return ImmutableSet.of(BiomeKeys.DESERT, BiomeKeys.DESERT_LAKES, BiomeKeys.DESERT_HILLS);
}
}

View file

@ -6,8 +6,6 @@ import java.io.UncheckedIOException;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.dimdev.dimdoors.DimensionalDoorsInitializer;
import org.dimdev.dimdoors.pockets.TemplateUtils;
import org.dimdev.dimdoors.util.schematic.v2.Schematic;
@ -22,6 +20,7 @@ public abstract class SchematicV2Gateway implements Gateway {
private Schematic schematic;
private final String id;
public static final BiMap<String, SchematicV2Gateway> ID_SCHEMATIC_MAP = HashBiMap.create();
private boolean replaced;
public SchematicV2Gateway(String id) {
ID_SCHEMATIC_MAP.putIfAbsent(id, this);
@ -40,13 +39,16 @@ public abstract class SchematicV2Gateway implements Gateway {
} catch (IOException ex) {
throw new RuntimeException("Schematic file for " + this.id + " could not be read as a valid schematic NBT file.", ex);
}
TemplateUtils.replacePlaceholders(this.schematic);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
public final void generate(StructureWorldAccess world, BlockPos pos) {
if (!this.replaced) {
TemplateUtils.replacePlaceholders(this.schematic);
this.replaced = true;
}
SchematicPlacer.place(this.schematic, world, pos);
this.generateRandomBits(world, pos);
}
@ -55,7 +57,7 @@ public abstract class SchematicV2Gateway implements Gateway {
* Generates randomized portions of the gateway structure (e.g. rubble, foliage)
*
* @param world - the world in which to generate the gateway
* @param pos - the position at which the schematic is placed
* @param pos - the position at which the schematic is placed
*/
protected void generateRandomBits(StructureWorldAccess world, BlockPos pos) {
}

View file

@ -9,12 +9,12 @@ 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.ModBiomes;
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;
@ -118,7 +118,7 @@ public class LimboChunkGenerator extends ChunkGenerator {
this.random.consume(2620);
this.densityNoise = new OctavePerlinNoiseSampler(this.random, IntStream.rangeClosed(-15, 0));
if (generationShapeConfig.hasIslandNoiseOverride()) {
ChunkRandom chunkRandom = new ChunkRandom(worldSeed);
ChunkRandom chunkRandom = new ChunkRandom(this.worldSeed);
chunkRandom.consume(17292);
this.islandNoise = new SimplexNoiseSampler(chunkRandom);
} else {

View file

@ -10,9 +10,6 @@ import java.util.Random;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.dimdev.dimdoors.ModConfig;
import com.google.common.collect.ImmutableMap;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
@ -20,15 +17,9 @@ import com.google.gson.JsonObject;
import com.mojang.serialization.Codec;
import com.mojang.serialization.JsonOps;
import com.mojang.serialization.codecs.UnboundedMapCodec;
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;
import static org.dimdev.dimdoors.block.ModBlocks.GOLD_DIMENSIONAL_DOOR;
import static org.dimdev.dimdoors.block.ModBlocks.GOLD_DOOR;
import static org.dimdev.dimdoors.block.ModBlocks.IRON_DIMENSIONAL_DOOR;
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 org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.dimdev.dimdoors.ModConfig;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
@ -93,6 +84,15 @@ import static net.minecraft.block.Blocks.SPRUCE_PLANKS;
import static net.minecraft.block.Blocks.SPRUCE_WOOD;
import static net.minecraft.block.Blocks.STONE;
import static net.minecraft.block.Blocks.STONE_BRICKS;
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;
import static org.dimdev.dimdoors.block.ModBlocks.GOLD_DIMENSIONAL_DOOR;
import static org.dimdev.dimdoors.block.ModBlocks.GOLD_DOOR;
import static org.dimdev.dimdoors.block.ModBlocks.IRON_DIMENSIONAL_DOOR;
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;
/**
* Provides methods for applying Limbo decay. Limbo decay refers to the effect that most blocks placed in Limbo

View file

@ -1,10 +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.dimdoors.util.Codecs;
import org.dimdev.dimdoors.util.EntityUtils;
import net.minecraft.entity.Entity;
import net.minecraft.text.TranslatableText;
@ -49,15 +49,15 @@ public final class Pocket {
public Pocket(int id, RegistryKey<World> world, int x, int z) {
this.id = id;
this.world = world;
box = new BlockBox(x * 16, 0, z * 16, (x + 1) * 16, 0, (z + 1) * 16);
this.box = new BlockBox(x * 16, 0, z * 16, (x + 1) * 16, 0, (z + 1) * 16);
}
boolean isInBounds(BlockPos pos) {
return box.contains(pos);
return this.box.contains(pos);
}
public BlockPos getOrigin() {
return new BlockPos(box.minX, box.minY, box.minZ);
return new BlockPos(this.box.minX, this.box.minY, this.box.minZ);
}
public boolean addDye(Entity entity, DyeColor dyeColor) {
@ -71,19 +71,19 @@ public final class Pocket {
}
if (this.nextDyeColor != null && this.nextDyeColor == color) {
if (count + 1 > amountOfDyeRequiredToColor(this)) {
if (this.count + 1 > amountOfDyeRequiredToColor(this)) {
this.dyeColor = color;
this.nextDyeColor = PocketColor.NONE;
count = 0;
this.count = 0;
EntityUtils.chat(entity, new TranslatableText("dimdoors.pocket.pocketHasBeenDyed", dyeColor));
} else {
count++;
EntityUtils.chat(entity, new TranslatableText("dimdoors.pocket.remainingNeededDyes", count, maxDye, color));
this.count++;
EntityUtils.chat(entity, new TranslatableText("dimdoors.pocket.remainingNeededDyes", this.count, maxDye, color));
}
} else {
this.nextDyeColor = color;
count = 1;
EntityUtils.chat(entity, new TranslatableText("dimdoors.pocket.remainingNeededDyes", count, maxDye, color));
this.count = 1;
EntityUtils.chat(entity, new TranslatableText("dimdoors.pocket.remainingNeededDyes", this.count, maxDye, color));
}
return true;
}
@ -122,11 +122,11 @@ public final class Pocket {
}
public void setSize(int x, int y, int z) {
box = new BlockBox(box.minX, box.minY, box.minZ, box.minX + x, box.minY + y, box.minZ + z);
this.box = new BlockBox(this.box.minX, this.box.minY, this.box.minZ, this.box.minX + x, this.box.minY + y, this.box.minZ + z);
}
public Vector3i getSize() {
Vec3i dimensions = box.getDimensions();
Vec3i dimensions = this.box.getDimensions();
return new Vector3i(dimensions.getX(), dimensions.getY(), dimensions.getZ());
}
@ -160,11 +160,11 @@ public final class Pocket {
}
public DyeColor getColor() {
return color;
return this.color;
}
public Integer getId() {
return id;
return this.id;
}
public static PocketColor from(DyeColor color) {

View file

@ -3,12 +3,12 @@ package org.dimdev.dimdoors.world.pocket;
import java.util.HashMap;
import java.util.Map;
import com.mojang.serialization.Codec;
import org.dimdev.dimdoors.DimensionalDoorsInitializer;
import org.dimdev.dimdoors.ModConfig;
import org.dimdev.dimdoors.util.NbtUtil;
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;

View file

@ -2,12 +2,12 @@ package org.dimdev.dimdoors.world.pocket;
import java.util.UUID;
import org.dimdev.dimdoors.DimensionalDoorsInitializer;
import org.dimdev.dimdoors.util.NbtUtil;
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.dimdoors.DimensionalDoorsInitializer;
import org.dimdev.dimdoors.util.NbtUtil;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.util.dynamic.DynamicSerializableUuid;

View file

@ -1,11 +1,11 @@
package org.dimdev.dimdoors.world.pocket;
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
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;