Registry rewrite part 3
This commit is contained in:
parent
f248ac7fcb
commit
15eccab45a
44 changed files with 497 additions and 278 deletions
src/main
java/com/zixiken/dimdoors
DimDoors.java
client
DDProxyClient.javaTileEntityFloatingRiftRenderer.javaTileEntityHorizontalEntranceRiftRenderer.javaTileEntityVerticalEntranceRiftRenderer.java
shared
DDProxyCommon.javaSchematicHandler.javaTeleporterDimDoors.javaVirtualLocation.java
blocks
commands
pockets
rifts
tileentities
util
resources
|
@ -5,6 +5,7 @@ import com.zixiken.dimdoors.shared.commands.TeleportCommand;
|
|||
import com.zixiken.dimdoors.shared.DDConfig;
|
||||
import com.zixiken.dimdoors.shared.DDProxyCommon;
|
||||
import com.zixiken.dimdoors.shared.items.ModItems;
|
||||
import com.zixiken.dimdoors.shared.util.DefaultSchematicGenerator;
|
||||
import com.zixiken.dimdoors.shared.world.gateways.GatewayGenerator;
|
||||
import lombok.Getter;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
|
@ -61,8 +62,6 @@ public class DimDoors {
|
|||
@Mod.EventHandler
|
||||
public void serverLoad(FMLServerStartingEvent event) {
|
||||
registerCommands(event);
|
||||
// RiftRegistry.INSTANCE.reset();
|
||||
//DefaultSchematicGenerator.tempGenerateDefaultSchematics();
|
||||
}
|
||||
|
||||
private void registerCommands(FMLServerStartingEvent event) {
|
||||
|
|
|
@ -37,9 +37,9 @@ public class DDProxyClient extends DDProxyCommon {
|
|||
}
|
||||
|
||||
public void registerRenderers() {
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityVerticalEntranceRift.class, new RenderVerticalEntranceRift());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityHorizontalEntranceRift.class, new RenderHorizontalEntranceRift());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityFloatingRift.class, new RenderRift());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityVerticalEntranceRift.class, new TileEntityVerticalEntranceRiftRenderer());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityHorizontalEntranceRift.class, new TileEntityHorizontalEntranceRiftRenderer());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityFloatingRift.class, new TileEntityFloatingRiftRenderer());
|
||||
RenderingRegistry.registerEntityRenderingHandler(MobMonolith.class, manager -> new RenderMobObelisk(manager, 0.5f));
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ import net.minecraft.util.ResourceLocation;
|
|||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
|
||||
public class RenderRift extends TileEntitySpecialRenderer<TileEntityFloatingRift> {
|
||||
public class TileEntityFloatingRiftRenderer extends TileEntitySpecialRenderer<TileEntityFloatingRift> {
|
||||
private static ResourceLocation tesseract_path = new ResourceLocation(DimDoors.MODID + ":textures/other/tesseract.png");
|
||||
|
||||
private static Vector4f[] tesseract = {
|
|
@ -22,7 +22,7 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
|||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class RenderHorizontalEntranceRift extends TileEntitySpecialRenderer<TileEntityHorizontalEntranceRift> {
|
||||
public class TileEntityHorizontalEntranceRiftRenderer extends TileEntitySpecialRenderer<TileEntityHorizontalEntranceRift> {
|
||||
|
||||
private FloatBuffer buffer = GLAllocation.createDirectFloatBuffer(16);
|
||||
private ResourceLocation riftPath = new ResourceLocation(DimDoors.MODID + ":textures/other/rift.png");
|
|
@ -22,7 +22,7 @@ import net.minecraft.util.ResourceLocation;
|
|||
|
||||
import static org.lwjgl.opengl.GL11.*;
|
||||
|
||||
public class RenderVerticalEntranceRift extends TileEntitySpecialRenderer<TileEntityVerticalEntranceRift> {
|
||||
public class TileEntityVerticalEntranceRiftRenderer extends TileEntitySpecialRenderer<TileEntityVerticalEntranceRift> {
|
||||
|
||||
private FloatBuffer buffer = GLAllocation.createDirectFloatBuffer(16);
|
||||
private ResourceLocation warpPath = new ResourceLocation(DimDoors.MODID + ":textures/other/warp.png");
|
|
@ -6,6 +6,7 @@ import com.zixiken.dimdoors.shared.blocks.ModBlocks;
|
|||
import com.zixiken.dimdoors.shared.entities.MobMonolith;
|
||||
import com.zixiken.dimdoors.shared.items.ModItems;
|
||||
import com.zixiken.dimdoors.shared.tileentities.*;
|
||||
import com.zixiken.dimdoors.shared.util.DefaultSchematicGenerator;
|
||||
import com.zixiken.dimdoors.shared.world.DimDoorDimensions;
|
||||
import net.minecraft.block.BlockDoor;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
|
@ -41,5 +42,6 @@ public abstract class DDProxyCommon implements IDDProxy {
|
|||
@Override
|
||||
public void onInitialization(FMLInitializationEvent event) {
|
||||
SchematicHandler.INSTANCE.loadSchematics();
|
||||
DefaultSchematicGenerator.generateDefaultSchematics();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -286,7 +286,7 @@ public class SchematicHandler { // TODO: make this more general (not dimdoors-re
|
|||
}
|
||||
|
||||
public PocketTemplate getPublicPocketTemplate() {
|
||||
return getRandomTemplate("private", -1, DDConfig.getMaxPocketSize(), true); // TODO: config option for getLargest
|
||||
return getRandomTemplate("public", -1, DDConfig.getMaxPocketSize(), true); // TODO: config option for getLargest
|
||||
}
|
||||
|
||||
public void saveSchematic(Schematic schematic, String name) {
|
||||
|
|
|
@ -17,7 +17,7 @@ import net.minecraft.server.management.PlayerList;
|
|||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
|
||||
//ref: https://github.com/WayofTime/BloodMagic/blob/1.11/src/main/java/WayofTime/bloodmagic/ritual/portal/Teleports.java
|
||||
public class TeleporterDimDoors extends Teleporter {
|
||||
public class TeleporterDimDoors extends Teleporter { // TODO
|
||||
|
||||
/**
|
||||
* Teleporter isn't static, so TeleporterDimDoors can't be static, so we're
|
||||
|
@ -80,7 +80,7 @@ public class TeleporterDimDoors extends Teleporter {
|
|||
int oldDimID = entity.dimension;
|
||||
WorldServer oldWorldserver = DimDoors.proxy.getWorldServer(oldDimID);
|
||||
WorldServer newWorldserver = DimDoors.proxy.getWorldServer(newDimID);
|
||||
if (entity instanceof EntityPlayerMP) { // TODO: this was EntityPlayer, but I changed this to EntityPlayerMP because that's what the cast assumes
|
||||
if (entity instanceof EntityPlayerMP) {
|
||||
DimDoors.log(TeleporterDimDoors.class, "Teleporting Player to new dimension.");
|
||||
EntityPlayerMP player = (EntityPlayerMP) entity;
|
||||
float playerRotationYaw = player.rotationYaw; //@todo make this a parameter?
|
||||
|
@ -137,7 +137,7 @@ public class TeleporterDimDoors extends Teleporter {
|
|||
private void teleportLocal(Entity entity, BlockPos pos) {
|
||||
WorldServer worldserver = (WorldServer) entity.world;
|
||||
|
||||
if (entity instanceof EntityPlayerMP) { // TODO: this was EntityPlayer, but I changed this to EntityPlayerMP because that's what the cast assumes
|
||||
if (entity instanceof EntityPlayerMP) {
|
||||
DimDoors.log(TeleporterDimDoors.class,
|
||||
"Teleporting Player within same dimension.");
|
||||
EntityPlayerMP player = (EntityPlayerMP) entity;
|
||||
|
|
|
@ -8,7 +8,7 @@ import lombok.Value;
|
|||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
@Value @ToString @AllArgsConstructor @Builder(toBuilder = true)
|
||||
public class VirtualLocation {
|
||||
public class VirtualLocation { // TODO: use BlockPos/Location
|
||||
int dimID;
|
||||
int x;
|
||||
int y;
|
||||
|
|
|
@ -3,10 +3,18 @@ package com.zixiken.dimdoors.shared.blocks;
|
|||
import java.util.Random;
|
||||
|
||||
import com.zixiken.dimdoors.DimDoors;
|
||||
import com.zixiken.dimdoors.shared.VirtualLocation;
|
||||
import com.zixiken.dimdoors.shared.pockets.Pocket;
|
||||
import com.zixiken.dimdoors.shared.pockets.PocketRegistry;
|
||||
import com.zixiken.dimdoors.shared.pockets.PocketTemplate;
|
||||
import com.zixiken.dimdoors.shared.rifts.RiftRegistry;
|
||||
import com.zixiken.dimdoors.shared.tileentities.TileEntityEntranceRift;
|
||||
import com.zixiken.dimdoors.shared.tileentities.TileEntityFloatingRift;
|
||||
import com.zixiken.dimdoors.shared.tileentities.TileEntityVerticalEntranceRift;
|
||||
import com.zixiken.dimdoors.shared.rifts.TileEntityRift;
|
||||
import com.zixiken.dimdoors.shared.util.Location;
|
||||
import com.zixiken.dimdoors.shared.util.WorldUtils;
|
||||
import com.zixiken.dimdoors.shared.world.DimDoorDimensions;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockDoor;
|
||||
import net.minecraft.block.ITileEntityProvider;
|
||||
|
@ -23,7 +31,8 @@ import net.minecraft.util.EnumHand;
|
|||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public abstract class BlockDimDoorBase extends BlockDoor implements ITileEntityProvider { // TODO: implement RiftProvider as an interface of both doors and trapdoors
|
||||
public abstract class BlockDimDoorBase extends BlockDoor implements ITileEntityProvider {
|
||||
// TODO: implement RiftProvider as an interface of both doors and trapdoors
|
||||
|
||||
public BlockDimDoorBase(Material material) {
|
||||
super(material);
|
||||
|
@ -31,6 +40,7 @@ public abstract class BlockDimDoorBase extends BlockDoor implements ITileEntityP
|
|||
|
||||
@Override
|
||||
public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn) {
|
||||
if (worldIn.isRemote) return;
|
||||
if (state.getValue(HALF) == EnumDoorHalf.UPPER) pos = pos.down();
|
||||
IBlockState doorState = worldIn.getBlockState(pos);
|
||||
if (!(doorState.getBlock() instanceof BlockDoor)) return;
|
||||
|
@ -104,17 +114,37 @@ public abstract class BlockDimDoorBase extends BlockDoor implements ITileEntityP
|
|||
|
||||
@Override
|
||||
public TileEntityVerticalEntranceRift createNewTileEntity(World worldIn, int meta) {
|
||||
return new TileEntityVerticalEntranceRift();
|
||||
TileEntityVerticalEntranceRift rift = new TileEntityVerticalEntranceRift();
|
||||
rift.orientation = getStateFromMeta(meta).getValue(BlockDoor.FACING).getOpposite();
|
||||
return rift;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state) {
|
||||
super.onBlockAdded(worldIn, pos, state);
|
||||
if (hasTileEntity(state)) {
|
||||
if (hasTileEntity(state) && !PocketTemplate.schematicBeingPlaced) { // TODO: better check for schematicBeingPlaced (support other plugins such as WorldEdit, support doors being placed while schematics are being placed)
|
||||
TileEntityVerticalEntranceRift rift = createNewTileEntity(worldIn, getMetaFromState(state));
|
||||
rift.orientation = state.getValue(BlockDoor.FACING).getOpposite();
|
||||
worldIn.setTileEntity(pos, rift);
|
||||
|
||||
// Set the virtual location based on where the door was placed
|
||||
VirtualLocation virtualLocation = null;
|
||||
if (DimDoorDimensions.isPocketDimension(WorldUtils.getDim(worldIn))) {
|
||||
Pocket pocket = PocketRegistry.getForDim(WorldUtils.getDim(worldIn)).getPocketFromLocation(pos.getY(), pos.getY(), pos.getZ());
|
||||
if (pocket != null) {
|
||||
virtualLocation = pocket.getVirtualLocation();
|
||||
} else {
|
||||
virtualLocation = new VirtualLocation(0, 0, 0, 0, 0); // TODO: door was placed in a pocket dim but outside of a pocket...
|
||||
}
|
||||
}
|
||||
if (virtualLocation == null) {
|
||||
virtualLocation = new VirtualLocation(WorldUtils.getDim(worldIn), pos.getX(), pos.getY(), pos.getZ(), 0);
|
||||
}
|
||||
rift.setVirtualLocation(virtualLocation);
|
||||
|
||||
// Configure the rift to its default functionality
|
||||
setupRift(rift);
|
||||
|
||||
// Set the tile entity and register it
|
||||
worldIn.setTileEntity(pos, rift);
|
||||
rift.markDirty();
|
||||
rift.register();
|
||||
}
|
||||
|
@ -125,9 +155,10 @@ public abstract class BlockDimDoorBase extends BlockDoor implements ITileEntityP
|
|||
if (!hasTileEntity(state)) return;
|
||||
TileEntityEntranceRift rift = getRift(worldIn, pos, state);
|
||||
super.breakBlock(worldIn, pos, state);
|
||||
if (rift.isPlaceRiftOnBreak()) {
|
||||
if (rift.isPlaceRiftOnBreak() || rift.isRegistered() && RiftRegistry.getRiftInfo(new Location(worldIn, pos)).getSources().size() > 0 && !rift.isAlwaysDelete()) {
|
||||
TileEntityRift newRift = new TileEntityFloatingRift();
|
||||
newRift.copyFrom(rift);
|
||||
newRift.updateAvailableLinks();
|
||||
worldIn.setBlockState(rift.getPos(), ModBlocks.RIFT.getDefaultState());
|
||||
worldIn.setTileEntity(rift.getPos(), newRift);
|
||||
} else {
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.zixiken.dimdoors.shared.blocks;
|
|||
|
||||
import com.zixiken.dimdoors.DimDoors;
|
||||
import com.zixiken.dimdoors.shared.items.ModItems;
|
||||
import com.zixiken.dimdoors.shared.rifts.RiftDestination;
|
||||
import com.zixiken.dimdoors.shared.tileentities.TileEntityVerticalEntranceRift;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.item.Item;
|
||||
|
@ -26,6 +27,7 @@ public class BlockDimDoorIron extends BlockDimDoorBase {
|
|||
|
||||
@Override
|
||||
protected void setupRift(TileEntityVerticalEntranceRift rift) {
|
||||
// TODO
|
||||
RiftDestination.NewPublicDestination destination = RiftDestination.NewPublicDestination.builder().build();
|
||||
rift.setSingleDestination(destination);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.zixiken.dimdoors.shared.blocks;
|
|||
|
||||
import com.zixiken.dimdoors.DimDoors;
|
||||
import com.zixiken.dimdoors.shared.items.ModItems;
|
||||
import com.zixiken.dimdoors.shared.rifts.RiftDestination;
|
||||
import com.zixiken.dimdoors.shared.tileentities.TileEntityVerticalEntranceRift;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.item.Item;
|
||||
|
@ -27,6 +28,7 @@ public class BlockDimDoorPersonal extends BlockDimDoorBase {
|
|||
|
||||
@Override
|
||||
protected void setupRift(TileEntityVerticalEntranceRift rift) {
|
||||
// TODO
|
||||
RiftDestination.PrivateDestination destination = RiftDestination.PrivateDestination.builder().build();
|
||||
rift.setSingleDestination(destination);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ public class PocketCommand extends CommandBase {
|
|||
PocketTemplate template = SchematicHandler.INSTANCE.getTemplate(args[0], args[1]);
|
||||
Pocket pocket = PocketGenerator.generatePocketFromTemplate(dim, 0, template, new VirtualLocation(0, 0, 0, 0,0));
|
||||
// TODO: options for linking back/not setting entrance
|
||||
pocket.selectEntrance();
|
||||
pocket.setup();
|
||||
TileEntityRift entrance = (TileEntityRift) player.world.getTileEntity(pocket.getEntrance().getPos());
|
||||
entrance.teleportTo(player);
|
||||
} else {
|
||||
|
|
|
@ -12,11 +12,8 @@ import com.zixiken.dimdoors.shared.util.MathUtils;
|
|||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagInt;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.nbt.NBTTagString;
|
||||
import net.minecraft.nbt.*;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -27,14 +24,13 @@ public class Pocket { // TODO: better visibilities
|
|||
@Getter int id; // Not saved
|
||||
@Getter /*private*/ int dimID; // Not saved
|
||||
|
||||
@Getter private int x; // Grid x
|
||||
@Getter private int x; // Grid x TODO: rename to gridX and gridY
|
||||
@Getter private int z; // Grid y
|
||||
@Getter private int depth;
|
||||
@Getter @Setter private int size; // In chunks TODO: non chunk-based size, better bounds such as minX, minZ, maxX, maxZ, etc.
|
||||
@Getter @Setter private VirtualLocation virtualLocation; // The non-pocket dimension from which this dungeon was created
|
||||
private List<Integer> riftIDs;
|
||||
private List<String> playerUUIDs;
|
||||
@Getter Location entrance;
|
||||
@Getter List<Location> riftLocations;
|
||||
|
||||
private Pocket() {}
|
||||
|
||||
|
@ -43,59 +39,54 @@ public class Pocket { // TODO: better visibilities
|
|||
this.dimID = dimID;
|
||||
this.x = x;
|
||||
this.z = z;
|
||||
this.depth = depth;
|
||||
riftIDs = new ArrayList<>();
|
||||
playerUUIDs = new ArrayList<>();
|
||||
riftLocations = new ArrayList<>();
|
||||
}
|
||||
|
||||
static Pocket readFromNBT(NBTTagCompound pocketNBT) {
|
||||
static Pocket readFromNBT(NBTTagCompound nbt) {
|
||||
Pocket pocket = new Pocket();
|
||||
pocket.id = pocketNBT.getInteger("id");
|
||||
pocket.x = pocketNBT.getInteger("x");
|
||||
pocket.z = pocketNBT.getInteger("z");
|
||||
pocket.depth = pocketNBT.getInteger("depth");
|
||||
pocket.size = pocketNBT.getInteger("size");
|
||||
pocket.virtualLocation = VirtualLocation.readFromNBT(pocketNBT.getCompoundTag("originalDim"));
|
||||
pocket.id = nbt.getInteger("id");
|
||||
pocket.x = nbt.getInteger("x");
|
||||
pocket.z = nbt.getInteger("z");
|
||||
pocket.size = nbt.getInteger("size");
|
||||
if (nbt.hasKey("virtualLocation")) pocket.virtualLocation = VirtualLocation.readFromNBT(nbt.getCompoundTag("virtualLocation"));
|
||||
|
||||
pocket.riftIDs = new ArrayList<>();
|
||||
NBTTagList riftIDsTagList = (NBTTagList) pocketNBT.getTag("riftIDs");
|
||||
for (int i = 0; i < riftIDsTagList.tagCount(); i++) {
|
||||
pocket.riftIDs.add(riftIDsTagList.getIntAt(i));
|
||||
pocket.playerUUIDs = new ArrayList<>();
|
||||
NBTTagList playerUUIDsNBT = (NBTTagList) nbt.getTag("playerUUIDs");
|
||||
for (int i = 0; i < playerUUIDsNBT.tagCount(); i++) { // TODO: convert to foreach
|
||||
pocket.playerUUIDs.add(playerUUIDsNBT.getStringTagAt(i));
|
||||
}
|
||||
|
||||
pocket.playerUUIDs = new ArrayList<>();
|
||||
NBTTagList playersTagList = (NBTTagList) pocketNBT.getTag("playerUUIDs");
|
||||
for (int i = 0; i < playersTagList.tagCount(); i++) {
|
||||
pocket.playerUUIDs.add(playersTagList.getStringTagAt(i));
|
||||
pocket.riftLocations = new ArrayList<>();
|
||||
NBTTagList riftLocationsNBT = (NBTTagList) nbt.getTag("riftLocations");
|
||||
for (NBTBase riftLocationNBT : riftLocationsNBT) {
|
||||
pocket.riftLocations.add(Location.readFromNBT((NBTTagCompound) riftLocationNBT));
|
||||
}
|
||||
|
||||
return pocket;
|
||||
}
|
||||
|
||||
static NBTBase writeToNBT(Pocket pocket) {
|
||||
NBTTagCompound pocketNBT = new NBTTagCompound();
|
||||
pocketNBT.setInteger("id", pocket.id);
|
||||
pocketNBT.setInteger("x", pocket.x);
|
||||
pocketNBT.setInteger("z", pocket.z);
|
||||
pocketNBT.setInteger("depth", pocket.depth);
|
||||
pocketNBT.setInteger("size", pocket.size);
|
||||
pocketNBT.setTag("originalDim", pocket.virtualLocation.writeToNBT());
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
nbt.setInteger("id", pocket.id);
|
||||
nbt.setInteger("x", pocket.x);
|
||||
nbt.setInteger("z", pocket.z);
|
||||
nbt.setInteger("size", pocket.size);
|
||||
if (pocket.virtualLocation != null) nbt.setTag("virtualLocation", pocket.virtualLocation.writeToNBT());
|
||||
|
||||
NBTTagList riftIDsTagList = new NBTTagList();
|
||||
for (int i = 0; i < pocket.riftIDs.size(); i++) {
|
||||
NBTTagInt doorTag = new NBTTagInt(pocket.riftIDs.get(i));
|
||||
riftIDsTagList.appendTag(doorTag);
|
||||
}
|
||||
pocketNBT.setTag("riftIDs", riftIDsTagList);
|
||||
|
||||
NBTTagList playersTagList = new NBTTagList();
|
||||
NBTTagList playerUUIDsNBT = new NBTTagList();
|
||||
for (int i = 0; i < pocket.playerUUIDs.size(); i++) {
|
||||
NBTTagString playerTag = new NBTTagString(pocket.playerUUIDs.get(i));
|
||||
playersTagList.appendTag(playerTag);
|
||||
playerUUIDsNBT.appendTag(new NBTTagString(pocket.playerUUIDs.get(i)));
|
||||
}
|
||||
pocketNBT.setTag("playerUUIDs", playersTagList);
|
||||
nbt.setTag("playerUUIDs", playerUUIDsNBT);
|
||||
|
||||
return pocketNBT;
|
||||
NBTTagList riftLocationsNBT = new NBTTagList();
|
||||
for (Location loc : pocket.riftLocations) {
|
||||
riftLocationsNBT.appendTag(Location.writeToNBT(loc));
|
||||
}
|
||||
nbt.setTag("riftLocations", riftLocationsNBT);
|
||||
|
||||
return nbt;
|
||||
}
|
||||
|
||||
boolean isLocationWithinPocketBounds(int locX, int locY, int locZ, int gridSize) {
|
||||
|
@ -121,10 +112,19 @@ public class Pocket { // TODO: better visibilities
|
|||
}
|
||||
|
||||
public List<TileEntityRift> getRifts() {
|
||||
return null; // TODO
|
||||
List<TileEntityRift> rifts = new ArrayList<>(riftLocations.size()); // TODO: make immutable
|
||||
for (Location riftLocation : riftLocations) {
|
||||
TileEntity tileEntity = riftLocation.getWorld().getTileEntity(riftLocation.getPos());
|
||||
if (tileEntity instanceof TileEntityRift) {
|
||||
rifts.add((TileEntityRift) tileEntity);
|
||||
} else {
|
||||
throw new RuntimeException("The rift locations array was wrong, check the schematic placing function to see why!");
|
||||
}
|
||||
}
|
||||
return rifts;
|
||||
}
|
||||
|
||||
public void selectEntrance() { // Always call after creating a pocket except when building the pocket TODO: more general setup method
|
||||
public void setup() { // Always call after creating a pocket except when building the pocket
|
||||
List<TileEntityRift> rifts = getRifts();
|
||||
|
||||
HashMap<Integer, Float> entranceIndexWeights = new HashMap<>();
|
||||
|
@ -142,9 +142,10 @@ public class Pocket { // TODO: better visibilities
|
|||
if (entranceIndexWeights.size() == 0) return;
|
||||
int selectedEntranceIndex = MathUtils.weightedRandom(entranceIndexWeights);
|
||||
|
||||
// Replace entrances with appropriate destinations
|
||||
index = 0;
|
||||
for (TileEntityRift rift : rifts) { // Replace entrances with appropriate items
|
||||
Iterator<WeightedRiftDestination> destIterator = rift.getDestinations().iterator();
|
||||
for (TileEntityRift rift : rifts) {
|
||||
ListIterator<WeightedRiftDestination> destIterator = rift.getDestinations().listIterator();
|
||||
while (destIterator.hasNext()) {
|
||||
WeightedRiftDestination wdest = destIterator.next();
|
||||
RiftDestination dest = wdest.getDestination();
|
||||
|
@ -154,32 +155,43 @@ public class Pocket { // TODO: better visibilities
|
|||
entrance = new Location(rift.getWorld(), rift.getPos());
|
||||
List<WeightedRiftDestination> ifDestinations = ((RiftDestination.PocketEntranceDestination) dest).getIfDestinations();
|
||||
for (WeightedRiftDestination ifDestination : ifDestinations) {
|
||||
rift.addDestination(ifDestination.getDestination(), ifDestination.getWeight() / wdest.getWeight(), ifDestination.getGroup());
|
||||
destIterator.add(new WeightedRiftDestination(ifDestination.getDestination(), ifDestination.getWeight() / wdest.getWeight(), ifDestination.getGroup()));
|
||||
destIterator.previous(); // An entrance destination shouldn't be in an if/otherwise destination, but just in case, pass over it too
|
||||
}
|
||||
} else {
|
||||
List<WeightedRiftDestination> otherwiseDestinations = ((RiftDestination.PocketEntranceDestination) dest).getOtherwiseDestinations();
|
||||
for (WeightedRiftDestination otherwiseDestination : otherwiseDestinations) {
|
||||
rift.addDestination(otherwiseDestination.getDestination(), otherwiseDestination.getWeight() / wdest.getWeight(), otherwiseDestination.getGroup());
|
||||
destIterator.add(new WeightedRiftDestination(otherwiseDestination.getDestination(), otherwiseDestination.getWeight() / wdest.getWeight(), otherwiseDestination.getGroup()));
|
||||
destIterator.previous(); // An entrance destination shouldn't be in an if/otherwise destination, but just in case, pass over it too
|
||||
}
|
||||
}
|
||||
index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// set virtual locations and register rifts
|
||||
for (TileEntityRift rift : rifts) {
|
||||
// TODO: put a rift on door break?
|
||||
rift.setVirtualLocation(virtualLocation);
|
||||
rift.register();
|
||||
}
|
||||
}
|
||||
|
||||
public void linkPocketTo(RiftDestination linkTo) {
|
||||
List<TileEntityRift> rifts = getRifts();
|
||||
|
||||
for (TileEntityRift rift : rifts) { // Link pocket exits back
|
||||
Iterator<WeightedRiftDestination> destIterator = rift.getDestinations().iterator();
|
||||
// Link pocket exits back
|
||||
for (TileEntityRift rift : rifts) {
|
||||
ListIterator<WeightedRiftDestination> destIterator = rift.getDestinations().listIterator();
|
||||
while (destIterator.hasNext()) {
|
||||
WeightedRiftDestination wdest = destIterator.next();
|
||||
RiftDestination dest = wdest.getDestination();
|
||||
if (dest.getType() == RiftDestination.EnumType.POCKET_EXIT) {
|
||||
destIterator.remove();
|
||||
linkTo.withOldDestination(dest);
|
||||
rift.addDestination(linkTo, wdest.getWeight(), wdest.getGroup());
|
||||
destIterator.add(new WeightedRiftDestination(linkTo.withOldDestination(dest), wdest.getWeight(), wdest.getGroup()));
|
||||
rift.notifyStateChanged();
|
||||
rift.markDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,8 +24,8 @@ public class PocketGenerator {
|
|||
}
|
||||
|
||||
public static Pocket generatePublicPocket(VirtualLocation virtualLocation) {
|
||||
PocketTemplate pocketTemplate = SchematicHandler.INSTANCE.getPersonalPocketTemplate();
|
||||
return generatePocketFromTemplate(DimDoorDimensions.getPrivateDimID(), 0, pocketTemplate, virtualLocation);
|
||||
PocketTemplate pocketTemplate = SchematicHandler.INSTANCE.getPublicPocketTemplate();
|
||||
return generatePocketFromTemplate(DimDoorDimensions.getPublicDimID(), 0, pocketTemplate, virtualLocation);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.zixiken.dimdoors.shared.pockets;
|
|||
|
||||
import com.zixiken.dimdoors.shared.tileentities.TileEntityVerticalEntranceRift;
|
||||
import com.zixiken.dimdoors.shared.rifts.TileEntityRift;
|
||||
import com.zixiken.dimdoors.shared.util.Location;
|
||||
import com.zixiken.dimdoors.shared.util.Schematic;
|
||||
import com.zixiken.dimdoors.DimDoors;
|
||||
import com.zixiken.dimdoors.shared.blocks.BlockDimDoorBase;
|
||||
|
@ -33,6 +34,7 @@ public class PocketTemplate { //there is exactly one pocket placer for each diff
|
|||
@Getter private final int minDepth;
|
||||
@Getter private final int maxDepth;
|
||||
private final float[] weights; //weights for chanced generation of dungeons per depth level | weights[0] is the weight for depth "minDepth"
|
||||
public static boolean schematicBeingPlaced = false;
|
||||
|
||||
//this class should contain the actual schematic info, as well as some of the Json info (placement of Rifts and stuff)
|
||||
public PocketTemplate(String groupName, String name, Schematic schematic, int size, int minDepth, int maxDepth, float[] weights) {
|
||||
|
@ -57,8 +59,8 @@ public class PocketTemplate { //there is exactly one pocket placer for each diff
|
|||
return weights[weights.length - 1]; // return last weight
|
||||
}
|
||||
|
||||
public Pocket place(Pocket pocket, int yBase) { //returns the riftID of the entrance DimDoor
|
||||
pocket.setSize(size); // TODO: check that this works properly
|
||||
public Pocket place(Pocket pocket, int yBase) { //returns the riftID of the entrance DimDoor TODO: use place method in schematic
|
||||
pocket.setSize(size);
|
||||
int gridSize = PocketRegistry.getForDim(pocket.dimID).getGridSize();
|
||||
int dimID = pocket.dimID;
|
||||
int xBase = pocket.getX() * gridSize * 16;
|
||||
|
@ -74,6 +76,7 @@ public class PocketTemplate { //there is exactly one pocket placer for each diff
|
|||
WorldServer world = DimDoors.proxy.getWorldServer(dimID);
|
||||
|
||||
//Place the Dungeon content structure
|
||||
schematicBeingPlaced = true; // TODO: Find a better system. What happens if the world is left before schematic is placed and this static field stays true?
|
||||
List<IBlockState> palette = schematic.getPallette();
|
||||
int[][][] blockData = schematic.getBlockData();
|
||||
for (int x = 0; x < blockData.length; x++) {
|
||||
|
@ -83,32 +86,27 @@ public class PocketTemplate { //there is exactly one pocket placer for each diff
|
|||
}
|
||||
}
|
||||
}
|
||||
schematicBeingPlaced = false;
|
||||
|
||||
//Load TileEntity Data
|
||||
List<TileEntityRift> rifts = new ArrayList<>();
|
||||
List<Location> riftLocations = new ArrayList<>();
|
||||
for (NBTTagCompound tileEntityNBT : schematic.getTileEntities()) {
|
||||
BlockPos pos = new BlockPos(xBase + tileEntityNBT.getInteger("x"), yBase + tileEntityNBT.getInteger("y"), zBase + tileEntityNBT.getInteger("z"));
|
||||
DimDoors.log(getClass(), "Re-loading tile-entity at blockPos: " + pos);
|
||||
TileEntity tileEntity = world.getTileEntity(pos);
|
||||
if (tileEntity != null) {
|
||||
if (tileEntity instanceof TileEntityRift) {
|
||||
DimDoors.log(getClass(), "Rift found in schematic: " + pos);
|
||||
TileEntityRift rift = (TileEntityRift) tileEntity;
|
||||
rifts.add(rift);
|
||||
} else {
|
||||
try {
|
||||
tileEntity.readFromNBT(tileEntityNBT); //this reads in the wrong blockPos
|
||||
} catch(Exception e) {
|
||||
DimDoors.warn(getClass(), "Loading in the data for TileEntity of type " + tileEntity + " went wrong. Details: " + e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
tileEntity.readFromNBT(tileEntityNBT);
|
||||
tileEntity.setWorld(world); // TODO: necessary?
|
||||
tileEntity.setPos(pos); //correct the position
|
||||
|
||||
if (tileEntity instanceof TileEntityRift) {
|
||||
DimDoors.log(getClass(), "Rift found in schematic at " + pos);
|
||||
riftLocations.add(new Location(world, pos));
|
||||
}
|
||||
tileEntity.markDirty();
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: rifts!
|
||||
|
||||
pocket.riftLocations = riftLocations;
|
||||
return pocket;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,28 +1,56 @@
|
|||
package com.zixiken.dimdoors.shared.rifts;
|
||||
|
||||
import com.zixiken.dimdoors.shared.util.INBTStorable;
|
||||
import com.zixiken.dimdoors.shared.util.Location;
|
||||
import com.zixiken.dimdoors.shared.util.NBTUtils;
|
||||
import lombok.*;
|
||||
import lombok.experimental.Wither;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3i;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@Getter @ToString @EqualsAndHashCode @AllArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public /*abstract*/ class RiftDestination implements INBTStorable { // TODO: fix lombok and make this abstract
|
||||
@Getter private EnumType type;
|
||||
@Wither @Getter private RiftDestination oldDestination;
|
||||
@Getter protected RiftDestination oldDestination;
|
||||
|
||||
public enum EnumType {
|
||||
RELATIVE, LOCAL, GLOBAL, NEW_PUBLIC, PRIVATE, LIMBO, RANDOM_RIFT_LINK, POCKET_ENTRANCE, POCKET_EXIT, PRIVATE_POCKET_EXIT, ESCAPE;
|
||||
RELATIVE, LOCAL, GLOBAL, NEW_PUBLIC, PRIVATE, LIMBO, AVAILABLE_LINK, POCKET_ENTRANCE, POCKET_EXIT, PRIVATE_POCKET_EXIT, ESCAPE;
|
||||
}
|
||||
|
||||
private RiftDestination() {}
|
||||
private RiftDestination() {
|
||||
if (this instanceof RelativeDestination) {
|
||||
type = EnumType.RELATIVE;
|
||||
} else if (this instanceof LocalDestination) {
|
||||
type = EnumType.LOCAL;
|
||||
} else if (this instanceof GlobalDestination) {
|
||||
type = EnumType.GLOBAL;
|
||||
} else if (this instanceof NewPublicDestination) {
|
||||
type = EnumType.NEW_PUBLIC;
|
||||
} else if (this instanceof PrivateDestination) {
|
||||
type = EnumType.PRIVATE;
|
||||
} else if (this instanceof LimboDestination) {
|
||||
type = EnumType.LIMBO;
|
||||
} else if (this instanceof AvailableLinkDestination) {
|
||||
type = EnumType.AVAILABLE_LINK;
|
||||
} else if (this instanceof PocketEntranceDestination) {
|
||||
type = EnumType.POCKET_ENTRANCE;
|
||||
} else if (this instanceof PocketExitDestination) {
|
||||
type = EnumType.POCKET_EXIT;
|
||||
} else if (this instanceof PrivatePocketExitDestination) {
|
||||
type = EnumType.PRIVATE_POCKET_EXIT;
|
||||
} else if (this instanceof EscapeDestination) {
|
||||
type = EnumType.ESCAPE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static RiftDestination readDestinationNBT(NBTTagCompound nbt) { // TODO: store old RANDOM_RIFT_LINK
|
||||
public static RiftDestination readDestinationNBT(NBTTagCompound nbt) { // TODO: store old AVAILABLE_LINK
|
||||
RiftDestination destination = null;
|
||||
EnumType type = EnumType.valueOf(nbt.getString("type"));
|
||||
switch (type) {
|
||||
|
@ -32,6 +60,9 @@ public /*abstract*/ class RiftDestination implements INBTStorable { // TODO: fix
|
|||
case LOCAL:
|
||||
destination = new LocalDestination();
|
||||
break;
|
||||
case GLOBAL:
|
||||
destination = new GlobalDestination();
|
||||
break;
|
||||
case NEW_PUBLIC:
|
||||
destination = new NewPublicDestination();
|
||||
break;
|
||||
|
@ -41,8 +72,8 @@ public /*abstract*/ class RiftDestination implements INBTStorable { // TODO: fix
|
|||
case LIMBO:
|
||||
destination = new LimboDestination();
|
||||
break;
|
||||
case RANDOM_RIFT_LINK:
|
||||
destination = new RandomRiftLinkDestination();
|
||||
case AVAILABLE_LINK:
|
||||
destination = new AvailableLinkDestination();
|
||||
break;
|
||||
case POCKET_ENTRANCE:
|
||||
destination = new PocketEntranceDestination();
|
||||
|
@ -62,6 +93,45 @@ public /*abstract*/ class RiftDestination implements INBTStorable { // TODO: fix
|
|||
return destination;
|
||||
}
|
||||
|
||||
public RiftDestination withOldDestination(RiftDestination oldDestination) {
|
||||
RiftDestination dest = null;
|
||||
if (this instanceof RelativeDestination) { // TODO: use type switch
|
||||
dest = ((RelativeDestination) this).toBuilder().build();
|
||||
dest.oldDestination = oldDestination;
|
||||
} else if (this instanceof LocalDestination) {
|
||||
dest = ((LocalDestination) this).toBuilder().build();
|
||||
dest.oldDestination = oldDestination;
|
||||
} else if (this instanceof GlobalDestination) {
|
||||
dest = ((GlobalDestination) this).toBuilder().build();
|
||||
dest.oldDestination = oldDestination;
|
||||
} else if (this instanceof NewPublicDestination) {
|
||||
dest = ((NewPublicDestination) this).toBuilder().build();
|
||||
dest.oldDestination = oldDestination;
|
||||
} else if (this instanceof PrivateDestination) {
|
||||
dest = ((PrivateDestination) this).toBuilder().build();
|
||||
dest.oldDestination = oldDestination;
|
||||
} else if (this instanceof LimboDestination) {
|
||||
dest = ((LimboDestination) this).toBuilder().build();
|
||||
dest.oldDestination = oldDestination;
|
||||
} else if (this instanceof AvailableLinkDestination) {
|
||||
dest = ((AvailableLinkDestination) this).toBuilder().build();
|
||||
dest.oldDestination = oldDestination;
|
||||
} else if (this instanceof PocketEntranceDestination) {
|
||||
dest = ((PocketEntranceDestination) this).toBuilder().build();
|
||||
dest.oldDestination = oldDestination;
|
||||
} else if (this instanceof PocketExitDestination) {
|
||||
dest = ((PocketExitDestination) this).toBuilder().build();
|
||||
dest.oldDestination = oldDestination;
|
||||
} else if (this instanceof PrivatePocketExitDestination) {
|
||||
dest = ((PrivatePocketExitDestination) this).toBuilder().build();
|
||||
dest.oldDestination = oldDestination;
|
||||
} else if (this instanceof EscapeDestination) {
|
||||
dest = ((EscapeDestination) this).toBuilder().build();
|
||||
dest.oldDestination = oldDestination;
|
||||
}
|
||||
return dest;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
if (nbt.hasKey("oldDestination")) oldDestination = readDestinationNBT(nbt.getCompoundTag("oldDestination"));
|
||||
|
@ -70,97 +140,73 @@ public /*abstract*/ class RiftDestination implements INBTStorable { // TODO: fix
|
|||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
||||
if (oldDestination != null) nbt.setTag("oldDestination", oldDestination.writeToNBT(new NBTTagCompound()));
|
||||
nbt.setString("type", type.name());
|
||||
return nbt;
|
||||
}
|
||||
|
||||
|
||||
@Getter @AllArgsConstructor @lombok.Builder(toBuilder = true)
|
||||
public static class RelativeDestination extends RiftDestination { // TODO: use Vec3i
|
||||
private int xOffset;
|
||||
private int yOffset;
|
||||
private int zOffset;
|
||||
private Vec3i offset;
|
||||
|
||||
private RelativeDestination() {}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
xOffset = nbt.getInteger("xOffset");
|
||||
yOffset = nbt.getInteger("yOffset");
|
||||
zOffset = nbt.getInteger("zOffset");
|
||||
offset = NBTUtils.readVec3i(nbt.getCompoundTag("offset"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
||||
nbt = super.writeToNBT(nbt);
|
||||
nbt.setString("type", EnumType.RELATIVE.name());
|
||||
nbt.setInteger("xOffset", xOffset);
|
||||
nbt.setInteger("yOffset", yOffset);
|
||||
nbt.setInteger("yOffset", zOffset);
|
||||
nbt.setTag("offset", NBTUtils.writeVec3i(offset));
|
||||
return nbt;
|
||||
}
|
||||
}
|
||||
|
||||
@Getter @AllArgsConstructor @lombok.Builder(toBuilder = true)
|
||||
public static class LocalDestination extends RiftDestination { // TODO: use BlockPos
|
||||
private int x;
|
||||
private int y;
|
||||
private int z;
|
||||
private BlockPos pos;
|
||||
|
||||
private LocalDestination() {}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
x = nbt.getInteger("x");
|
||||
y = nbt.getInteger("y");
|
||||
z = nbt.getInteger("z");
|
||||
pos = new BlockPos(NBTUtils.readVec3i(nbt.getCompoundTag("pos")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
||||
nbt = super.writeToNBT(nbt);
|
||||
nbt.setString("type", EnumType.LOCAL.name());
|
||||
nbt.setInteger("x", x);
|
||||
nbt.setInteger("y", y);
|
||||
nbt.setInteger("y", z);
|
||||
nbt.setTag("pos", NBTUtils.writeVec3i(pos));
|
||||
return nbt;
|
||||
}
|
||||
}
|
||||
|
||||
@Getter @AllArgsConstructor @lombok.Builder(toBuilder = true)
|
||||
public static class GlobalDestination extends RiftDestination { // TODO: use Location
|
||||
private int dim;
|
||||
private int x;
|
||||
private int y;
|
||||
private int z;
|
||||
public static class GlobalDestination extends RiftDestination { // TODO: location directly in nbt like minecraft?
|
||||
private Location loc;
|
||||
|
||||
private GlobalDestination() {};
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
dim = nbt.getInteger("dim");
|
||||
x = nbt.getInteger("x");
|
||||
y = nbt.getInteger("y");
|
||||
z = nbt.getInteger("z");
|
||||
loc = Location.readFromNBT(nbt.getCompoundTag("loc"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
||||
nbt = super.writeToNBT(nbt);
|
||||
nbt.setString("type", EnumType.GLOBAL.name());
|
||||
nbt.setInteger("dim", dim);
|
||||
nbt.setInteger("x", x);
|
||||
nbt.setInteger("y", y);
|
||||
nbt.setInteger("y", z);
|
||||
nbt.setTag("loc", Location.writeToNBT(loc));
|
||||
return nbt;
|
||||
}
|
||||
}
|
||||
|
||||
@Getter @AllArgsConstructor @lombok.Builder(toBuilder = true)
|
||||
public static class NewPublicDestination extends RiftDestination {
|
||||
|
||||
public static class NewPublicDestination extends RiftDestination { // TODO: more config options such as non-default size, etc.
|
||||
//private NewPublicDestination() {}
|
||||
|
||||
@Override
|
||||
|
@ -171,7 +217,6 @@ public /*abstract*/ class RiftDestination implements INBTStorable { // TODO: fix
|
|||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
||||
nbt = super.writeToNBT(nbt);
|
||||
nbt.setString("type", EnumType.NEW_PUBLIC.name());
|
||||
return nbt;
|
||||
}
|
||||
}
|
||||
|
@ -189,7 +234,6 @@ public /*abstract*/ class RiftDestination implements INBTStorable { // TODO: fix
|
|||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
||||
nbt = super.writeToNBT(nbt);
|
||||
nbt.setString("type", EnumType.PRIVATE.name());
|
||||
return nbt;
|
||||
}
|
||||
}
|
||||
|
@ -207,13 +251,12 @@ public /*abstract*/ class RiftDestination implements INBTStorable { // TODO: fix
|
|||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
||||
nbt = super.writeToNBT(nbt);
|
||||
nbt.setString("type", EnumType.PRIVATE.name());
|
||||
return nbt;
|
||||
}
|
||||
}
|
||||
|
||||
@Getter @AllArgsConstructor @lombok.Builder(toBuilder = true)
|
||||
public static class RandomRiftLinkDestination extends RiftDestination { // TODO
|
||||
public static class AvailableLinkDestination extends RiftDestination { // TODO
|
||||
private float newDungeonRiftProbability;
|
||||
private float depthPenalization; // TODO: these make the equation assymetric
|
||||
private float distancePenalization;
|
||||
|
@ -224,9 +267,14 @@ public /*abstract*/ class RiftDestination implements INBTStorable { // TODO: fix
|
|||
private boolean unstable;
|
||||
private float entranceLinkWeight;
|
||||
private float floatingRiftWeight;
|
||||
|
||||
private boolean noLinkBack;
|
||||
// private int maxLinks;
|
||||
|
||||
@Builder.Default private UUID uuid = UUID.randomUUID();
|
||||
// TODO: add a "safe" option to link only to a rift destination that has a non-zero weight
|
||||
|
||||
private RandomRiftLinkDestination() {}
|
||||
private AvailableLinkDestination() {}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
|
@ -238,12 +286,14 @@ public /*abstract*/ class RiftDestination implements INBTStorable { // TODO: fix
|
|||
dungeonRiftsOnly = nbt.getBoolean("dungeonRiftsOnly");
|
||||
overworldRifts = nbt.getBoolean("overworldRifts");
|
||||
unstable = nbt.getBoolean("unstable");
|
||||
noLinkBack = nbt.getBoolean("noLinkBack");
|
||||
// maxLinks = nbt.getInteger("maxLinks");
|
||||
uuid = nbt.getUniqueId("uuid");
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
||||
nbt = super.writeToNBT(nbt);
|
||||
nbt.setString("type", EnumType.RANDOM_RIFT_LINK.name());
|
||||
nbt.setFloat("newDungeonRiftProbability", newDungeonRiftProbability);
|
||||
nbt.setFloat("depthPenalization", depthPenalization);
|
||||
nbt.setFloat("distancePenalization", distancePenalization);
|
||||
|
@ -251,6 +301,9 @@ public /*abstract*/ class RiftDestination implements INBTStorable { // TODO: fix
|
|||
nbt.setBoolean("dungeonRiftsOnly", dungeonRiftsOnly);
|
||||
nbt.setBoolean("overworldRifts", overworldRifts);
|
||||
nbt.setBoolean("unstable", unstable);
|
||||
nbt.setBoolean("noLinkBack", noLinkBack);
|
||||
// nbt.setInteger("maxLinks", maxLinks);
|
||||
nbt.setUniqueId("uuid", uuid);
|
||||
return nbt;
|
||||
}
|
||||
}
|
||||
|
@ -258,8 +311,8 @@ public /*abstract*/ class RiftDestination implements INBTStorable { // TODO: fix
|
|||
@Getter @AllArgsConstructor @lombok.Builder(toBuilder = true)
|
||||
public static class PocketEntranceDestination extends RiftDestination {
|
||||
private float weight;
|
||||
private List<WeightedRiftDestination> ifDestinations = new LinkedList<>();
|
||||
private List<WeightedRiftDestination> otherwiseDestinations = new LinkedList<>();
|
||||
@Builder.Default private List<WeightedRiftDestination> ifDestinations = new LinkedList<>(); // TODO addIfDestination method in builder
|
||||
@Builder.Default private List<WeightedRiftDestination> otherwiseDestinations = new LinkedList<>(); // TODO addIfDestination method in builder
|
||||
|
||||
private PocketEntranceDestination() {}
|
||||
|
||||
|
@ -268,13 +321,15 @@ public /*abstract*/ class RiftDestination implements INBTStorable { // TODO: fix
|
|||
super.readFromNBT(nbt);
|
||||
weight = nbt.getFloat("weight");
|
||||
|
||||
ifDestinations = new LinkedList<>();
|
||||
NBTTagList ifDestinationsNBT = (NBTTagList) nbt.getTag("ifDestinations");
|
||||
for (NBTBase ifDestinationNBT : ifDestinationsNBT) {
|
||||
WeightedRiftDestination ifDestination = new WeightedRiftDestination();
|
||||
ifDestination.readFromNBT((NBTTagCompound) ifDestinationNBT);
|
||||
otherwiseDestinations.add(ifDestination);
|
||||
ifDestinations.add(ifDestination);
|
||||
}
|
||||
|
||||
otherwiseDestinations = new LinkedList<>();
|
||||
NBTTagList otherwiseDestinationsNBT = (NBTTagList) nbt.getTag("otherwiseDestinations");
|
||||
for (NBTBase otherwiseDestinationNBT : otherwiseDestinationsNBT) {
|
||||
WeightedRiftDestination otherwiseDestination = new WeightedRiftDestination();
|
||||
|
@ -286,7 +341,6 @@ public /*abstract*/ class RiftDestination implements INBTStorable { // TODO: fix
|
|||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
||||
nbt = super.writeToNBT(nbt);
|
||||
nbt.setString("type", EnumType.POCKET_ENTRANCE.name());
|
||||
nbt.setFloat("weight", weight);
|
||||
|
||||
NBTTagList ifDestinationsNBT = new NBTTagList();
|
||||
|
@ -318,7 +372,6 @@ public /*abstract*/ class RiftDestination implements INBTStorable { // TODO: fix
|
|||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
||||
nbt = super.writeToNBT(nbt);
|
||||
nbt.setString("type", EnumType.POCKET_EXIT.name());
|
||||
return nbt;
|
||||
}
|
||||
}
|
||||
|
@ -336,7 +389,6 @@ public /*abstract*/ class RiftDestination implements INBTStorable { // TODO: fix
|
|||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
||||
nbt = super.writeToNBT(nbt);
|
||||
nbt.setString("type", EnumType.PRIVATE_POCKET_EXIT.name());
|
||||
return nbt;
|
||||
}
|
||||
}
|
||||
|
@ -352,7 +404,6 @@ public /*abstract*/ class RiftDestination implements INBTStorable { // TODO: fix
|
|||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
||||
nbt = super.writeToNBT(nbt);
|
||||
nbt.setString("type", EnumType.ESCAPE.name());
|
||||
return nbt;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,10 +6,7 @@ import com.zixiken.dimdoors.shared.rifts.RiftRegistry.RiftInfo.AvailableLinkInfo
|
|||
import com.zixiken.dimdoors.shared.util.INBTStorable;
|
||||
import com.zixiken.dimdoors.shared.util.Location;
|
||||
import com.zixiken.dimdoors.shared.util.WorldUtils;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.*;
|
||||
import lombok.experimental.Wither;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
@ -33,35 +30,47 @@ public class RiftRegistry extends WorldSavedData {
|
|||
@Getter private int dim;
|
||||
private World world;
|
||||
|
||||
@lombok.AllArgsConstructor @lombok.NoArgsConstructor @lombok.EqualsAndHashCode
|
||||
@lombok.AllArgsConstructor @lombok.EqualsAndHashCode @lombok.Builder(toBuilder = true)
|
||||
public static class RiftInfo implements com.zixiken.dimdoors.shared.util.INBTStorable {
|
||||
@Getter private List<AvailableLinkInfo> availableLinks = new LinkedList<>();
|
||||
@Getter private Set<Location> sources = new HashSet<>();
|
||||
@Getter private Set<Location> destinations = new HashSet<>();
|
||||
@Builder.Default @Getter private Set<AvailableLinkInfo> availableLinks = new HashSet<>(); // ignore intellij warnings, builder needs these
|
||||
@Builder.Default @Getter private Set<Location> sources = new HashSet<>();
|
||||
@Builder.Default @Getter private Set<Location> destinations = new HashSet<>();
|
||||
|
||||
@AllArgsConstructor @NoArgsConstructor @EqualsAndHashCode
|
||||
@AllArgsConstructor @NoArgsConstructor @EqualsAndHashCode @Builder(toBuilder = true)
|
||||
public static class AvailableLinkInfo implements INBTStorable {
|
||||
@Getter private float weight;
|
||||
@Getter @Setter private float weight;
|
||||
@Getter private VirtualLocation virtualLocation;
|
||||
@Getter @Wither private Location location;
|
||||
@Getter private UUID uuid;
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
weight = nbt.getFloat("weight");
|
||||
virtualLocation = VirtualLocation.readFromNBT(nbt.getCompoundTag("virtualLocation"));
|
||||
uuid = nbt.getUniqueId("uuid");
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
||||
nbt.setFloat("weight", weight);
|
||||
nbt.setTag("virtualLocation", virtualLocation.writeToNBT());
|
||||
nbt.setUniqueId("uuid", uuid);
|
||||
return nbt;
|
||||
}
|
||||
}
|
||||
|
||||
public RiftInfo() {
|
||||
availableLinks = new HashSet<>();
|
||||
sources = new HashSet<>();
|
||||
destinations = new HashSet<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
NBTTagList availableLinksNBT = (NBTTagList) nbt.getTag("availableLinks");
|
||||
if (availableLinksNBT == null) {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
for (NBTBase availableLinkNBT : availableLinksNBT) {
|
||||
AvailableLinkInfo link = new AvailableLinkInfo();
|
||||
link.readFromNBT((NBTTagCompound) availableLinkNBT);
|
||||
|
@ -147,7 +156,7 @@ public class RiftRegistry extends WorldSavedData {
|
|||
NBTTagCompound riftNBTC = (NBTTagCompound) riftNBT;
|
||||
Location location = Location.readFromNBT(riftNBTC.getCompoundTag("location"));
|
||||
RiftInfo riftInfo = new RiftInfo();
|
||||
riftInfo.readFromNBT(nbt);
|
||||
riftInfo.readFromNBT(riftNBTC);
|
||||
rifts.put(location, riftInfo);
|
||||
}
|
||||
}
|
||||
|
@ -210,7 +219,7 @@ public class RiftRegistry extends WorldSavedData {
|
|||
destinationRegistry.rifts.get(destination).sources.remove(rift);
|
||||
destinationRegistry.markDirty();
|
||||
TileEntityRift riftEntity = (TileEntityRift) destinationRegistry.world.getTileEntity(destination.getPos());
|
||||
riftEntity.checkIfNeeded();
|
||||
riftEntity.allSourcesGone();
|
||||
}
|
||||
registry.markDirty();
|
||||
}
|
||||
|
@ -239,12 +248,28 @@ public class RiftRegistry extends WorldSavedData {
|
|||
registry.markDirty();
|
||||
}
|
||||
|
||||
public void removeAvailableLink(Location rift, AvailableLinkInfo link) {
|
||||
public static void removeAvailableLink(Location rift, AvailableLinkInfo link) {
|
||||
RiftRegistry registry = getRegistry(rift);
|
||||
registry.rifts.get(rift).availableLinks.remove(link);
|
||||
registry.markDirty();
|
||||
}
|
||||
|
||||
public static void clearAvailableLinks(Location rift) {
|
||||
RiftRegistry registry = getRegistry(rift);
|
||||
registry.rifts.get(rift).availableLinks.clear();
|
||||
registry.markDirty();
|
||||
}
|
||||
|
||||
public static void removeAvailableLinkByUUID(Location rift, UUID uuid) {
|
||||
RiftRegistry registry = getRegistry(rift);
|
||||
for (AvailableLinkInfo link : registry.rifts.get(rift).availableLinks) {
|
||||
if (link.uuid.equals(uuid)) {
|
||||
removeAvailableLink(rift, link);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static RiftRegistry getRegistry(Location rift) {
|
||||
return getForDim(rift.getDimID());
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.zixiken.dimdoors.shared.rifts;
|
||||
|
||||
import com.zixiken.dimdoors.DimDoors;
|
||||
import com.zixiken.dimdoors.shared.TeleporterDimDoors;
|
||||
import com.zixiken.dimdoors.shared.VirtualLocation;
|
||||
import com.zixiken.dimdoors.shared.pockets.Pocket;
|
||||
import com.zixiken.dimdoors.shared.pockets.PocketGenerator;
|
||||
|
@ -16,6 +17,7 @@ import net.minecraft.block.state.IBlockState;
|
|||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.IEntityOwnable;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
|
@ -26,28 +28,26 @@ import net.minecraft.util.ITickable;
|
|||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.*;
|
||||
|
||||
public abstract class TileEntityRift extends TileEntity implements ITickable { // TODO: implement ITeleportSource and ITeleportDestination
|
||||
|
||||
@Getter protected VirtualLocation virtualLocation; // location can be null
|
||||
@Getter protected List<WeightedRiftDestination> destinations; // must be non-null //
|
||||
@Getter protected boolean makeDestinationPermanent; //
|
||||
@Getter protected int freeLinks;
|
||||
@Getter protected boolean preserveRotation; //
|
||||
@Getter protected float yaw; //
|
||||
@Getter protected float pitch; //
|
||||
@Getter protected boolean alwaysDelete; //
|
||||
@Getter protected VirtualLocation virtualLocation;
|
||||
@Nonnull @Getter protected List<WeightedRiftDestination> destinations;
|
||||
@Getter protected boolean makeDestinationPermanent;
|
||||
@Getter protected boolean preserveRotation;
|
||||
@Getter protected float yaw;
|
||||
@Getter protected float pitch;
|
||||
@Getter protected boolean alwaysDelete; // Delete the rift when an entrance rift is broken even if the state was changed or destinations link there.
|
||||
@Getter protected float chaosWeight;
|
||||
// TODO: option to convert to door on teleportTo?
|
||||
// TODO: chaos door link weights?
|
||||
|
||||
protected boolean riftStateChanged; // not saved
|
||||
|
||||
|
||||
public TileEntityRift() {
|
||||
destinations = new ArrayList<>();
|
||||
makeDestinationPermanent = true;
|
||||
freeLinks = 1;
|
||||
preserveRotation = true;
|
||||
pitch = 0;
|
||||
alwaysDelete = false;
|
||||
|
@ -57,7 +57,6 @@ public abstract class TileEntityRift extends TileEntity implements ITickable { /
|
|||
virtualLocation = oldRift.virtualLocation;
|
||||
destinations = oldRift.destinations;
|
||||
makeDestinationPermanent = oldRift.makeDestinationPermanent;
|
||||
freeLinks = oldRift.freeLinks;
|
||||
preserveRotation = oldRift.preserveRotation;
|
||||
yaw = oldRift.yaw;
|
||||
pitch = oldRift.pitch;
|
||||
|
@ -65,10 +64,6 @@ public abstract class TileEntityRift extends TileEntity implements ITickable { /
|
|||
markDirty();
|
||||
}
|
||||
|
||||
public boolean isEntrance() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
|
@ -87,6 +82,8 @@ public abstract class TileEntityRift extends TileEntity implements ITickable { /
|
|||
preserveRotation = nbt.getBoolean("preserveRotation");
|
||||
yaw = nbt.getFloat("yaw");
|
||||
pitch = nbt.getFloat("pitch");
|
||||
alwaysDelete = nbt.getBoolean("alwaysDelete");
|
||||
chaosWeight = nbt.getFloat("chaosWeight");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -97,7 +94,7 @@ public abstract class TileEntityRift extends TileEntity implements ITickable { /
|
|||
|
||||
NBTTagList destinationsNBT = new NBTTagList();
|
||||
for (WeightedRiftDestination destination : destinations) {
|
||||
destinationsNBT.appendTag(destination.writeToNBT(nbt));
|
||||
destinationsNBT.appendTag(destination.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
nbt.setTag("destinations", destinationsNBT);
|
||||
|
||||
|
@ -105,12 +102,16 @@ public abstract class TileEntityRift extends TileEntity implements ITickable { /
|
|||
nbt.setBoolean("preserveRotation", preserveRotation);
|
||||
nbt.setFloat("yaw", yaw);
|
||||
nbt.setFloat("pitch", pitch);
|
||||
nbt.setBoolean("alwaysDelete", alwaysDelete);
|
||||
nbt.setFloat("chaosWeight", chaosWeight);
|
||||
|
||||
return nbt;
|
||||
}
|
||||
|
||||
public void setVirtualLocation(VirtualLocation virtualLocation) {
|
||||
this.virtualLocation = virtualLocation;
|
||||
updateAvailableLinks();
|
||||
// TODO: update available link virtual locations
|
||||
markDirty();
|
||||
}
|
||||
|
||||
|
@ -137,32 +138,9 @@ public abstract class TileEntityRift extends TileEntity implements ITickable { /
|
|||
Iterator<WeightedRiftDestination> destinationIterator = destinations.iterator();
|
||||
while (destinationIterator.hasNext()) {
|
||||
RiftDestination dest = destinationIterator.next().getDestination();
|
||||
if (dest.getType() == EnumType.GLOBAL) {
|
||||
GlobalDestination globalDest = (GlobalDestination) dest;
|
||||
if (globalDest.getDim() == location.getDimID()
|
||||
&& globalDest.getX() == location.getPos().getX()
|
||||
&& globalDest.getY() == location.getPos().getY()
|
||||
&& globalDest.getZ() == location.getPos().getZ()) {
|
||||
unregisterDest(dest);
|
||||
destinationIterator.remove();
|
||||
}
|
||||
if (location.getDimID() == WorldUtils.getDim(world)) {
|
||||
if (dest.getType() == EnumType.LOCAL) {
|
||||
LocalDestination localDest = (LocalDestination) dest;
|
||||
if (localDest.getX() == location.getPos().getX()
|
||||
&& localDest.getY() == location.getPos().getY()
|
||||
&& localDest.getZ() == location.getPos().getZ()) {
|
||||
unregisterDest(dest);
|
||||
destinationIterator.remove();
|
||||
}
|
||||
} else if (dest.getType() == EnumType.RELATIVE) {
|
||||
RelativeDestination relativeDest = (RelativeDestination) dest;
|
||||
if (location.getPos().equals(pos.add(relativeDest.getXOffset(), relativeDest.getYOffset(), relativeDest.getZOffset()))) {
|
||||
unregisterDest(dest);
|
||||
destinationIterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (destinationToLocation(dest).equals(location)) {
|
||||
destinationIterator.remove();
|
||||
unregisterDest(dest);
|
||||
}
|
||||
}
|
||||
markDirty();
|
||||
|
@ -172,7 +150,7 @@ public abstract class TileEntityRift extends TileEntity implements ITickable { /
|
|||
for (WeightedRiftDestination wdest : destinations) {
|
||||
unregisterDest(wdest.getDestination());
|
||||
}
|
||||
destinations = new ArrayList<>();
|
||||
destinations.clear();
|
||||
markDirty();
|
||||
}
|
||||
|
||||
|
@ -181,32 +159,65 @@ public abstract class TileEntityRift extends TileEntity implements ITickable { /
|
|||
addDestination(destination, 1, 0);
|
||||
}
|
||||
|
||||
public Location translateDestCoordinates(RiftDestination dest) {
|
||||
public Location destinationToLocation(RiftDestination dest) {
|
||||
switch (dest.getType()) { // TODO: these need a superclass and a single translation method
|
||||
case RELATIVE:
|
||||
RelativeDestination relativeDest = (RelativeDestination) dest;
|
||||
return new Location(world, pos.add(relativeDest.getXOffset(), relativeDest.getYOffset(), relativeDest.getZOffset()));
|
||||
return new Location(world, pos.add(relativeDest.getOffset()));
|
||||
case LOCAL:
|
||||
LocalDestination localDest = (LocalDestination) dest;
|
||||
return new Location(world, new BlockPos(localDest.getX(), localDest.getY(), localDest.getZ()));
|
||||
return new Location(world, localDest.getPos());
|
||||
case GLOBAL:
|
||||
GlobalDestination globalDest = (GlobalDestination) dest;
|
||||
return new Location(globalDest.getDim(), new BlockPos(globalDest.getX(), globalDest.getY(), globalDest.getZ()));
|
||||
return globalDest.getLoc();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void registerDest(RiftDestination dest) {
|
||||
Location destLoc = translateDestCoordinates(dest);
|
||||
if (!isRegistered()) return;
|
||||
Location destLoc = destinationToLocation(dest);
|
||||
if (destLoc != null) RiftRegistry.addLink(new Location(world, pos), destLoc);
|
||||
if (dest.getType() == EnumType.AVAILABLE_LINK) {
|
||||
AvailableLinkDestination linkDest = (AvailableLinkDestination) dest;
|
||||
AvailableLinkInfo linkInfo = AvailableLinkInfo.builder()
|
||||
.weight(isEntrance() ? linkDest.getEntranceLinkWeight() : linkDest.getFloatingRiftWeight())
|
||||
.virtualLocation(virtualLocation)
|
||||
.uuid(linkDest.getUuid())
|
||||
.build();
|
||||
RiftRegistry.addAvailableLink(new Location(world, pos), linkInfo);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateAvailableLinks() {
|
||||
if (!isRegistered()) return;
|
||||
RiftRegistry.clearAvailableLinks(new Location(world, pos));
|
||||
for (WeightedRiftDestination wdest : destinations) {
|
||||
RiftDestination dest = wdest.getDestination();
|
||||
if (dest.getType() == EnumType.AVAILABLE_LINK) {
|
||||
AvailableLinkDestination linkDest = (AvailableLinkDestination) dest;
|
||||
AvailableLinkInfo linkInfo = AvailableLinkInfo.builder()
|
||||
.weight(isEntrance() ? linkDest.getEntranceLinkWeight() : linkDest.getFloatingRiftWeight())
|
||||
.virtualLocation(virtualLocation)
|
||||
.uuid(linkDest.getUuid())
|
||||
.build();
|
||||
RiftRegistry.addAvailableLink(new Location(world, pos), linkInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void unregisterDest(RiftDestination dest) {
|
||||
Location destLoc = translateDestCoordinates(dest);
|
||||
if (!isRegistered()) return;
|
||||
Location destLoc = destinationToLocation(dest);
|
||||
if (destLoc != null) RiftRegistry.removeLink(new Location(world, pos), destLoc);
|
||||
}
|
||||
|
||||
public void register() { // registers or reregisters the rift
|
||||
public boolean isRegistered() {
|
||||
return world != null && RiftRegistry.getRiftInfo(new Location(world, pos)) != null;
|
||||
}
|
||||
|
||||
// Make sure virtualLocation != null before calling!
|
||||
public void register() { // registers or reregisters the rift TODO: what if it's already registered?
|
||||
Location loc = new Location(world, pos);
|
||||
RiftRegistry.addRift(loc);
|
||||
for (WeightedRiftDestination weightedDest : destinations) {
|
||||
|
@ -215,17 +226,20 @@ public abstract class TileEntityRift extends TileEntity implements ITickable { /
|
|||
}
|
||||
|
||||
public void unregister() {
|
||||
if (!isRegistered()) return;
|
||||
RiftRegistry.removeRift(new Location(world, pos));
|
||||
// TODO: inform pocket that entrance was destroyed (we'll probably need an isPrivate field on the pocket)
|
||||
}
|
||||
|
||||
public void teleportTo(Entity entity) { // TODO: new velocity angle if !preserveRotation?
|
||||
entity.setWorld(world);
|
||||
if (preserveRotation) {
|
||||
entity.setPosition(pos.getX(), pos.getY(), pos.getZ());
|
||||
} else {
|
||||
entity.setPositionAndRotation(pos.getX(), pos.getY(), pos.getZ(), yaw, pitch);
|
||||
float newYaw = entity.rotationYaw;
|
||||
float newPitch = entity.rotationYaw;
|
||||
if (!preserveRotation) {
|
||||
newYaw = yaw;
|
||||
newPitch = pitch;
|
||||
}
|
||||
TeleporterDimDoors.instance().teleport(entity, new Location(world, pos));
|
||||
entity.setPositionAndRotation(pos.getX(), pos.getY(), pos.getZ(), newYaw, newPitch);
|
||||
|
||||
int dim = WorldUtils.getDim(world);
|
||||
if (entity instanceof EntityPlayer && DimDoorDimensions.isPocketDimension(dim)) { // TODO
|
||||
|
@ -233,7 +247,7 @@ public abstract class TileEntityRift extends TileEntity implements ITickable { /
|
|||
}
|
||||
}
|
||||
|
||||
public boolean teleport(Entity entity) {
|
||||
public boolean teleport(Entity entity) { try { // TODO: return failiure message string rather than boolean
|
||||
riftStateChanged = false;
|
||||
if (destinations.size() == 0) return false;
|
||||
|
||||
|
@ -244,37 +258,25 @@ public abstract class TileEntityRift extends TileEntity implements ITickable { /
|
|||
WeightedRiftDestination weightedDestination = MathUtils.weightedRandom(weightMap);
|
||||
int group = weightedDestination.getGroup();
|
||||
if(makeDestinationPermanent) {
|
||||
List<WeightedRiftDestination> list = new ArrayList<>();
|
||||
for (WeightedRiftDestination otherDestination : destinations) {
|
||||
if (otherDestination.getGroup() == group) {
|
||||
list.add(otherDestination);
|
||||
}
|
||||
}
|
||||
destinations = list;
|
||||
destinations.removeIf(wdest -> wdest.getGroup() != group);
|
||||
markDirty();
|
||||
}
|
||||
|
||||
RiftDestination dest = weightedDestination.getDestination();
|
||||
Location destLoc;
|
||||
GlobalDestination destHere = new GlobalDestination(WorldUtils.getDim(world), pos.getX(), pos.getY(), pos.getZ());
|
||||
GlobalDestination destHere = new GlobalDestination(new Location(world, pos)); // TODO: local if possible
|
||||
switch (dest.getType()) {
|
||||
case RELATIVE:
|
||||
RelativeDestination relativeDest = (RelativeDestination) dest;
|
||||
destLoc = new Location(world, pos.add(relativeDest.getXOffset(), relativeDest.getYOffset(), relativeDest.getZOffset()));
|
||||
break;
|
||||
case LOCAL:
|
||||
LocalDestination localDest = (LocalDestination) dest;
|
||||
destLoc = new Location(world, localDest.getX(), localDest.getY(), localDest.getZ());
|
||||
break;
|
||||
case GLOBAL:
|
||||
GlobalDestination globalDest = (GlobalDestination) dest;
|
||||
destLoc = new Location(globalDest.getDim(), globalDest.getX(), globalDest.getY(), globalDest.getZ());
|
||||
destLoc = destinationToLocation(dest);
|
||||
break;
|
||||
case NEW_PUBLIC:
|
||||
Pocket publicPocket = PocketGenerator.generatePublicPocket(virtualLocation.toBuilder().depth(-1).build()); // TODO: random transform
|
||||
publicPocket.selectEntrance();
|
||||
Pocket publicPocket = PocketGenerator.generatePublicPocket(virtualLocation != null ? virtualLocation.toBuilder().depth(-1).build() : null); // TODO: random transform
|
||||
publicPocket.setup();
|
||||
publicPocket.linkPocketTo(destHere);
|
||||
destLoc = publicPocket.getEntrance();
|
||||
makeDestinationPermanent(weightedDestination, destLoc);
|
||||
if (destLoc != null) makeDestinationPermanent(weightedDestination, destLoc);
|
||||
break;
|
||||
case PRIVATE: // TODO: move logic to PrivatePocketTeleportDestination
|
||||
String uuid = null;
|
||||
|
@ -285,8 +287,8 @@ public abstract class TileEntityRift extends TileEntity implements ITickable { /
|
|||
RiftRegistry privateRiftRegistry = RiftRegistry.getForDim(DimDoorDimensions.getPrivateDimID());
|
||||
Pocket privatePocket = privatePocketRegistry.getPocket(privatePocketRegistry.getPrivatePocketID(uuid));
|
||||
if (privatePocket == null) { // generate the private pocket and get its entrance
|
||||
privatePocket = PocketGenerator.generatePrivatePocket(virtualLocation.toBuilder().depth(-2).build()); // set to where the pocket was first created TODO: private pocket deletion
|
||||
privatePocket.selectEntrance();
|
||||
privatePocket = PocketGenerator.generatePrivatePocket(virtualLocation != null ? virtualLocation.toBuilder().depth(-2).build() : null); // set to where the pocket was first created TODO: private pocket deletion
|
||||
privatePocket.setup();
|
||||
destLoc = privatePocket.getEntrance();
|
||||
} else {
|
||||
destLoc = privateRiftRegistry.getPrivatePocketEntrance(uuid); // get the last used entrance
|
||||
|
@ -314,26 +316,45 @@ public abstract class TileEntityRift extends TileEntity implements ITickable { /
|
|||
break;
|
||||
case LIMBO: // TODO: move logic to LimboTeleportDestination
|
||||
throw new RuntimeException("Not yet implemented!"); // TODO: random coordinates based on VirtualLocation
|
||||
case RANDOM_RIFT_LINK: // TODO: chaos door
|
||||
RandomRiftLinkDestination randomDest = (RandomRiftLinkDestination) dest;
|
||||
Map<Location, Float> possibleDestWeightMap = new HashMap<>();
|
||||
case AVAILABLE_LINK: // TODO: chaos door
|
||||
AvailableLinkDestination linkDest = (AvailableLinkDestination) dest;
|
||||
Map<AvailableLinkInfo, Float> possibleDestWeightMap = new HashMap<>();
|
||||
|
||||
for (AvailableLinkInfo link : RiftRegistry.getAvailableLinks()) {
|
||||
VirtualLocation otherVLoc = link.getVirtualLocation();
|
||||
float weight2 = link.getWeight();
|
||||
if (weight2 == 0) continue;
|
||||
double depthDiff = Math.abs(virtualLocation.getDepth() - otherVLoc.getDepth());
|
||||
double distanceSq = new BlockPos(virtualLocation.getX(), virtualLocation.getY(), virtualLocation.getZ())
|
||||
.distanceSq(new BlockPos(otherVLoc.getX(), otherVLoc.getY(), otherVLoc.getZ()));
|
||||
float distanceExponent = randomDest.getDistancePenalization();
|
||||
float depthExponent = randomDest.getDepthPenalization();
|
||||
float closenessExponent = randomDest.getClosenessPenalization();
|
||||
float weight2 = link.getWeight();
|
||||
float distanceExponent = linkDest.getDistancePenalization();
|
||||
float depthExponent = linkDest.getDepthPenalization();
|
||||
float closenessExponent = linkDest.getClosenessPenalization();
|
||||
float weight = (float) Math.abs(weight2/(Math.pow(depthDiff, depthExponent) * Math.pow(distanceSq, 0.5 * distanceExponent))); // TODO: fix formula
|
||||
float currentWeight = possibleDestWeightMap.get(link.getLocation());
|
||||
possibleDestWeightMap.put(link.getLocation(), currentWeight + weight);
|
||||
float currentWeight = possibleDestWeightMap.get(link);
|
||||
possibleDestWeightMap.put(link, currentWeight + weight);
|
||||
}
|
||||
|
||||
destLoc = MathUtils.weightedRandom(possibleDestWeightMap);
|
||||
if (!randomDest.isUnstable()) makeDestinationPermanent(weightedDestination, destLoc);
|
||||
AvailableLinkInfo selectedLink = MathUtils.weightedRandom(possibleDestWeightMap);
|
||||
destLoc = selectedLink.getLocation();
|
||||
if (!linkDest.isUnstable()) makeDestinationPermanent(weightedDestination, destLoc);
|
||||
|
||||
TileEntityRift destRift = (TileEntityRift) destLoc.getWorld().getTileEntity(destLoc.getPos()); // Link the other rift back if necessary
|
||||
ListIterator<WeightedRiftDestination> wdestIterator = destRift.destinations.listIterator();
|
||||
WeightedRiftDestination selectedWDest = null;
|
||||
while (wdestIterator.hasNext()) {
|
||||
WeightedRiftDestination wdest = wdestIterator.next();
|
||||
RiftDestination otherDest = wdest.getDestination();
|
||||
if (otherDest.getType() == EnumType.AVAILABLE_LINK && ((AvailableLinkDestination) otherDest).getUuid() == selectedLink.getUuid()) {
|
||||
selectedWDest = wdest;
|
||||
wdestIterator.remove();
|
||||
break;
|
||||
}
|
||||
}
|
||||
AvailableLinkDestination selectedAvailableLinkDest = (AvailableLinkDestination) selectedWDest.getDestination();
|
||||
if (!selectedAvailableLinkDest.isNoLinkBack()) {
|
||||
destRift.makeDestinationPermanent(selectedWDest, new Location(world, pos));
|
||||
}
|
||||
break;
|
||||
case POCKET_ENTRANCE:
|
||||
case POCKET_EXIT:
|
||||
|
@ -344,26 +365,54 @@ public abstract class TileEntityRift extends TileEntity implements ITickable { /
|
|||
default:
|
||||
throw new RuntimeException("That rift type is not implemented in TileRiftEntity.teleport, this is a bug.");
|
||||
}
|
||||
if (destLoc == null) {
|
||||
if (entity instanceof EntityPlayer) DimDoors.chat((EntityPlayer) entity, "The destination was null. Either this is a bug in TileEntityRift.java, or the pocket does not have an entrance!");
|
||||
return false;
|
||||
}
|
||||
TileEntity tileEntityAtLoc = destLoc.getWorld().getTileEntity(destLoc.getPos());
|
||||
if (!(tileEntityAtLoc instanceof TileEntityRift)) throw new RuntimeException("The rift referenced by this rift does not exist, this is a bug.");
|
||||
TileEntityRift destRift = (TileEntityRift) tileEntityAtLoc;
|
||||
destRift.teleportTo(entity);
|
||||
return true;
|
||||
|
||||
} catch (Exception e) {
|
||||
if (entity instanceof EntityPlayer) DimDoors.chat((EntityPlayer) entity, "There was an exception while teleporting!");
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void makeDestinationPermanent(WeightedRiftDestination weightedDestination, Location destLoc) {
|
||||
riftStateChanged = true;
|
||||
GlobalDestination newDest = new GlobalDestination(destLoc.getDimID(), destLoc.getPos().getX(), destLoc.getPos().getY(), destLoc.getPos().getZ()); // TODO: RelativeDestination instead?
|
||||
destinations.add(new WeightedRiftDestination(newDest, weightedDestination.getWeight(), weightedDestination.getGroup()));
|
||||
RiftDestination newDest;
|
||||
if (WorldUtils.getDim(world) == destLoc.getDimID()) {
|
||||
newDest = new LocalDestination(destLoc.getPos()); // TODO: RelativeDestination instead?
|
||||
} else {
|
||||
newDest = new GlobalDestination(destLoc);
|
||||
}
|
||||
newDest = newDest.withOldDestination(weightedDestination.getDestination());
|
||||
destinations.remove(weightedDestination);
|
||||
destinations.add(new WeightedRiftDestination(newDest, weightedDestination.getWeight(), weightedDestination.getGroup()));
|
||||
markDirty();
|
||||
}
|
||||
|
||||
public void destinationGone(Location loc) {
|
||||
destinations.removeIf(weightedRiftDestination -> loc.equals(translateDestCoordinates(weightedRiftDestination.getDestination())));
|
||||
ListIterator<WeightedRiftDestination> wdestIterator = destinations.listIterator();
|
||||
while (wdestIterator.hasNext()) {
|
||||
WeightedRiftDestination wdest = wdestIterator.next();
|
||||
RiftDestination dest = wdest.getDestination();
|
||||
if (loc.equals(destinationToLocation(dest))) {
|
||||
wdestIterator.remove();
|
||||
RiftDestination oldDest = dest.getOldDestination();
|
||||
if (oldDest != null) {
|
||||
wdestIterator.add(new WeightedRiftDestination(oldDest, wdest.getWeight(), wdest.getGroup()));
|
||||
}
|
||||
}
|
||||
}
|
||||
destinations.removeIf(weightedRiftDestination -> loc.equals(destinationToLocation(weightedRiftDestination.getDestination())));
|
||||
}
|
||||
|
||||
public void checkIfNeeded() {
|
||||
public void allSourcesGone() {
|
||||
// TODO
|
||||
}
|
||||
|
||||
|
@ -382,6 +431,11 @@ public abstract class TileEntityRift extends TileEntity implements ITickable { /
|
|||
deserializeNBT(tag);
|
||||
}
|
||||
|
||||
public void notifyStateChanged() {
|
||||
riftStateChanged = true;
|
||||
markDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SPacketUpdateTileEntity getUpdatePacket() {
|
||||
return new SPacketUpdateTileEntity(getPos(), 1, serializeNBT());
|
||||
|
@ -391,4 +445,6 @@ public abstract class TileEntityRift extends TileEntity implements ITickable { /
|
|||
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) {
|
||||
deserializeNBT(pkt.getNbtCompound());
|
||||
}
|
||||
|
||||
public abstract boolean isEntrance(); // TODO: replace with chooseWeight function
|
||||
}
|
||||
|
|
|
@ -6,22 +6,25 @@ import lombok.Getter;
|
|||
import lombok.NoArgsConstructor;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@NoArgsConstructor @AllArgsConstructor
|
||||
public class WeightedRiftDestination implements INBTStorable {
|
||||
public class
|
||||
WeightedRiftDestination implements INBTStorable { // TODO: generics
|
||||
@Getter private RiftDestination destination;
|
||||
@Getter private float weight;
|
||||
@Getter private int group;
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
destination = RiftDestination.readDestinationNBT(nbt.getCompoundTag("destination"));
|
||||
destination = RiftDestination.readDestinationNBT(nbt); // TODO: subtag?
|
||||
weight = nbt.getFloat("weight");
|
||||
group = nbt.getInteger("group");
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbt) {
|
||||
nbt.setTag("destination", destination.writeToNBT(nbt));
|
||||
nbt = destination.writeToNBT(nbt);
|
||||
nbt.setFloat("weight", weight);
|
||||
nbt.setInteger("group", group);
|
||||
return nbt;
|
||||
|
|
|
@ -45,15 +45,10 @@ public abstract class TileEntityEntranceRift extends TileEntityRift {
|
|||
|
||||
public void setPlaceRiftOnBreak(boolean placeRiftOnBreak) { this.placeRiftOnBreak = placeRiftOnBreak; markDirty(); }
|
||||
|
||||
@Override
|
||||
public boolean isEntrance() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean teleport(Entity entity) {
|
||||
boolean status = super.teleport(entity);
|
||||
if (riftStateChanged /*|| TODO: get links from registry */) {
|
||||
if (riftStateChanged && !alwaysDelete) {
|
||||
placeRiftOnBreak = true;
|
||||
markDirty();
|
||||
}
|
||||
|
@ -76,4 +71,9 @@ public abstract class TileEntityEntranceRift extends TileEntityRift {
|
|||
}
|
||||
return new RGBA(red, green, blue, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEntrance() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -124,4 +124,9 @@ public class TileEntityFloatingRift extends TileEntityRift implements ITickable
|
|||
|
||||
return nbt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEntrance() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.zixiken.dimdoors.shared.tileentities;
|
||||
|
||||
import com.zixiken.dimdoors.shared.TeleporterDimDoors;
|
||||
import com.zixiken.dimdoors.shared.util.Location;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
@ -36,6 +38,4 @@ public class TileEntityVerticalEntranceRift extends TileEntityEntranceRift { //
|
|||
BlockPos offsetPos = entity.getPosition().offset(orientation);
|
||||
entity.setPositionAndRotation(offsetPos.getX(), offsetPos.getY(), offsetPos.getZ(), orientation.getHorizontalAngle(), 0); // TODO: let TileEntityRift handle rotation?
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -4,6 +4,9 @@ import com.zixiken.dimdoors.DimDoors;
|
|||
import com.zixiken.dimdoors.shared.SchematicHandler;
|
||||
import com.zixiken.dimdoors.shared.blocks.BlockFabric;
|
||||
import com.zixiken.dimdoors.shared.blocks.ModBlocks;
|
||||
import com.zixiken.dimdoors.shared.rifts.RiftDestination;
|
||||
import com.zixiken.dimdoors.shared.rifts.TileEntityRift;
|
||||
import com.zixiken.dimdoors.shared.rifts.WeightedRiftDestination;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockDoor;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
|
@ -18,14 +21,14 @@ import java.util.ArrayList;
|
|||
* @author Robijnvogel
|
||||
*/
|
||||
public class DefaultSchematicGenerator {
|
||||
public static void tempGenerateDefaultSchematics() {
|
||||
public static void generateDefaultSchematics() {
|
||||
for (int pocketSize = 0; pocketSize < 8; pocketSize++) {
|
||||
generateDefaultSchematic("defaultPublic", pocketSize, ModBlocks.FABRIC.getDefaultState().withProperty(BlockFabric.TYPE, BlockFabric.EnumType.REALITY), ModBlocks.DIMENSIONAL_DOOR);
|
||||
generateDefaultSchematic("defaultPrivate", pocketSize, ModBlocks.FABRIC.getDefaultState().withProperty(BlockFabric.TYPE, BlockFabric.EnumType.ALTERED), ModBlocks.PERSONAL_DIMENSIONAL_DOOR);
|
||||
generateDefaultSchematic("defaultPublic", pocketSize, ModBlocks.FABRIC.getDefaultState().withProperty(BlockFabric.TYPE, BlockFabric.EnumType.REALITY), ModBlocks.DIMENSIONAL_DOOR, RiftDestination.PocketExitDestination.builder().build());
|
||||
generateDefaultSchematic("defaultPrivate", pocketSize, ModBlocks.FABRIC.getDefaultState().withProperty(BlockFabric.TYPE, BlockFabric.EnumType.ALTERED), ModBlocks.PERSONAL_DIMENSIONAL_DOOR, RiftDestination.PrivatePocketExitDestination.builder().build());
|
||||
}
|
||||
}
|
||||
|
||||
private static void generateDefaultSchematic(String baseName, int pocketSize, IBlockState innerWallBlockState, Block doorBlock) {
|
||||
private static void generateDefaultSchematic(String baseName, int pocketSize, IBlockState innerWallBlockState, Block doorBlock, RiftDestination exitDest) {
|
||||
int maxbound = (pocketSize + 1) * 16 - 1;
|
||||
|
||||
Schematic schematic = new Schematic();
|
||||
|
@ -74,11 +77,14 @@ public class DefaultSchematicGenerator {
|
|||
}
|
||||
|
||||
schematic.tileEntities = new ArrayList<>();
|
||||
// TODO: DimDoors.proxy.getDefWorld() prevents running this before world load
|
||||
TileEntity tileEntity = doorBlock.createTileEntity(DimDoors.proxy.getWorldServer(0), doorBlock.getDefaultState());
|
||||
NBTTagCompound tileNBT = tileEntity.serializeNBT();
|
||||
TileEntityRift rift = (TileEntityRift) doorBlock.createTileEntity(null, doorBlock.getDefaultState());
|
||||
rift.setSingleDestination(RiftDestination.PocketEntranceDestination.builder()
|
||||
.ifDestinations(MathUtils.listFrom(new WeightedRiftDestination(exitDest, 1, 0)))
|
||||
.build());
|
||||
|
||||
NBTTagCompound tileNBT = rift.serializeNBT();
|
||||
tileNBT.setInteger("x", (maxbound - 1) / 2);
|
||||
tileNBT.setInteger("y", 6);
|
||||
tileNBT.setInteger("y", 5);
|
||||
tileNBT.setInteger("z", 4);
|
||||
schematic.tileEntities.add(tileNBT);
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.zixiken.dimdoors.shared.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
|
@ -73,4 +75,10 @@ public class MathUtils {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static <T> List<T> listFrom(T element) {
|
||||
List<T> list = new ArrayList<>();
|
||||
list.add(element);
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.zixiken.dimdoors.shared.util;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.math.Vec3i;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
@ -20,4 +21,16 @@ public class NBTUtils {
|
|||
}
|
||||
return tagCompound;
|
||||
}
|
||||
|
||||
public static Vec3i readVec3i(NBTTagCompound nbt) {
|
||||
return new Vec3i(nbt.getInteger("x"), nbt.getInteger("y"), nbt.getInteger("z"));
|
||||
}
|
||||
|
||||
public static NBTTagCompound writeVec3i(Vec3i vec) {
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
nbt.setInteger("x", vec.getX());
|
||||
nbt.setInteger("y", vec.getY());
|
||||
nbt.setInteger("z", vec.getZ());
|
||||
return nbt;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,17 @@
|
|||
package com.zixiken.dimdoors.shared.util;
|
||||
|
||||
import com.zixiken.dimdoors.DimDoors;
|
||||
import com.zixiken.dimdoors.shared.world.DimDoorDimensions;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
|
||||
public class WorldUtils {
|
||||
public static World getWorld(int dim) {
|
||||
return DimensionManager.getWorld(dim);
|
||||
World world = DimDoors.proxy.getWorldServer(dim);
|
||||
if (world == null) {
|
||||
throw new RuntimeException("Something went wrong!");
|
||||
}
|
||||
return world;
|
||||
}
|
||||
|
||||
public static int getDim(World world) {
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -12,7 +12,7 @@
|
|||
"mcversion": "1.12.2",
|
||||
"url": "https://github.com/DimensionalDevelopment/DimDoors",
|
||||
"updateUrl": "",
|
||||
"authorList": [ "StevenRS11", "SenseiKiwi", "Zixiken", "WaterPicker", "Robijnvogel" ],
|
||||
"authorList": [ "StevenRS11", "SenseiKiwi", "Zixiken", "WaterPicker", "Robijnvogel", "ZombieHDGaming", "Runemoro" ],
|
||||
"parent":"",
|
||||
"screenshots": [],
|
||||
"dependencies": [ "forge" ]
|
||||
|
|
Loading…
Add table
Reference in a new issue