Various stuff related to Personal Pockets
This commit is contained in:
parent
0cebae0524
commit
ababfe669c
20 changed files with 110 additions and 77 deletions
|
@ -0,0 +1,16 @@
|
|||
package org.dimdev.dimdoors.block;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.Material;
|
||||
import net.minecraft.util.DyeColor;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
|
||||
public class AncientFabricBlock extends Block {
|
||||
public AncientFabricBlock(DyeColor color) {
|
||||
super(FabricBlockSettings.of(Material.STONE, color).strength(-1.0F, 3600000.0F).dropsNothing());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,8 @@
|
|||
package org.dimdev.dimdoors.block;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Material;
|
||||
|
@ -15,8 +18,9 @@ import net.minecraft.util.math.BlockPos;
|
|||
import net.minecraft.world.World;
|
||||
|
||||
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
||||
import org.dimdev.dimdoors.util.InstanceMap;
|
||||
|
||||
class FabricBlock extends Block {
|
||||
public class FabricBlock extends Block {
|
||||
FabricBlock(DyeColor color) {
|
||||
super(FabricBlockSettings.of(Material.STONE, color).lightLevel(15));
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package org.dimdev.dimdoors.block;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
@ -18,6 +19,9 @@ import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
|
|||
|
||||
public final class ModBlocks {
|
||||
private static final Map<String, Block> BLOCKS = Maps.newLinkedHashMap();
|
||||
private static final Map<DyeColor, Block> FABRIC_BLOCKS = new HashMap<>();
|
||||
private static final Map<DyeColor, Block> ANCIENT_FABRIC_BLOCKS = new HashMap<>();
|
||||
|
||||
public static final Block GOLD_DOOR = register("dimdoors:gold_door", new DoorBlock(FabricBlockSettings.of(Material.METAL, MaterialColor.GOLD).nonOpaque()));
|
||||
public static final Block QUARTZ_DOOR = register("dimdoors:quartz_door", new DoorBlock(FabricBlockSettings.of(Material.STONE, MaterialColor.QUARTZ).nonOpaque()));
|
||||
public static final Block OAK_DIMENSIONAL_DOOR = register("dimdoors:oak_dimensional_door", new DimensionalDoorBlock(FabricBlockSettings.of(Material.WOOD, MaterialColor.WOOD).nonOpaque().lightLevel(state -> ((DimensionalDoorBlock) state.getBlock()).hasBlockEntity(state) ? 10 : 0)));
|
||||
|
@ -74,11 +78,15 @@ public final class ModBlocks {
|
|||
}
|
||||
|
||||
private static Block registerAncientFabric(String id, DyeColor color) {
|
||||
return register(id, new Block(FabricBlockSettings.of(Material.STONE, color).strength(-1.0F, 3600000.0F).dropsNothing()));
|
||||
Block block = new AncientFabricBlock(color);
|
||||
ANCIENT_FABRIC_BLOCKS.put(color, block);
|
||||
return register(id, block);
|
||||
}
|
||||
|
||||
private static Block registerFabric(String id, DyeColor color) {
|
||||
return register(id, new FabricBlock(color));
|
||||
Block block = new FabricBlock(color);
|
||||
FABRIC_BLOCKS.put(color, block);
|
||||
return register(id, block);
|
||||
}
|
||||
|
||||
public static void init() {
|
||||
|
@ -93,6 +101,14 @@ public final class ModBlocks {
|
|||
BlockRenderLayerMap.INSTANCE.putBlocks(RenderLayer.getCutout(), ModBlocks.OAK_DIMENSIONAL_DOOR, ModBlocks.GOLD_DIMENSIONAL_DOOR, ModBlocks.IRON_DIMENSIONAL_DOOR, ModBlocks.OAK_DIMENSIONAL_TRAPDOOR, ModBlocks.QUARTZ_DIMENSIONAL_DOOR, ModBlocks.QUARTZ_DOOR);
|
||||
}
|
||||
|
||||
public static Block ancientFabricFromDye(DyeColor color) {
|
||||
return ANCIENT_FABRIC_BLOCKS.get(color);
|
||||
}
|
||||
|
||||
public static Block fabricFromDye(DyeColor color) {
|
||||
return FABRIC_BLOCKS.get(color);
|
||||
}
|
||||
|
||||
private static class DoorBlock extends net.minecraft.block.DoorBlock {
|
||||
public DoorBlock(Settings settings) {
|
||||
super(settings);
|
||||
|
|
|
@ -47,7 +47,7 @@ public final class PocketGenerator {
|
|||
}
|
||||
|
||||
public static Pocket generatePrivatePocketV2(VirtualLocation virtualLocation) {
|
||||
return generateRandomPocketFromGroupV2(DimensionalDoorsInitializer.getWorld(ModDimensions.PUBLIC), "private", virtualLocation, null, null);
|
||||
return generateRandomPocketFromGroupV2(DimensionalDoorsInitializer.getWorld(ModDimensions.PERSONAL), "private", virtualLocation, null, null);
|
||||
}
|
||||
|
||||
// TODO: size of public pockets should increase with depth
|
||||
|
|
|
@ -10,6 +10,8 @@ import java.util.*;
|
|||
|
||||
import com.google.common.collect.*;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.mojang.serialization.JsonOps;
|
||||
|
||||
import net.minecraft.nbt.*;
|
||||
import net.minecraft.util.Identifier;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
|
@ -36,21 +38,12 @@ public class SchematicV2Handler {
|
|||
long startTime = System.currentTimeMillis();
|
||||
Set<String> names = ImmutableSet.of("default_private", "default_public");
|
||||
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) {
|
||||
String line = reader.readLine();
|
||||
if (line == null) {
|
||||
break;
|
||||
}
|
||||
result.add(line);
|
||||
}
|
||||
|
||||
try {
|
||||
List<String> result = Files.readAllLines(Paths.get(SchematicV2Handler.class.getResource(String.format("/data/dimdoors/pockets/json/v2/%s.json", name)).toURI()));
|
||||
CompoundTag groupTag = StringNbtReader.parse(String.join("", result));
|
||||
PocketGroup type = new PocketGroup().fromTag(groupTag);
|
||||
type.init();
|
||||
this.pocketGroups.put(type.getGroup(), type);
|
||||
|
||||
} catch (IOException | URISyntaxException | CommandSyntaxException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
|
@ -13,9 +13,10 @@ import org.apache.logging.log4j.Logger;
|
|||
|
||||
import org.dimdev.dimdoors.util.GraphUtils;
|
||||
import org.dimdev.dimdoors.util.Location;
|
||||
import org.dimdev.dimdoors.world.level.DimensionalRegistry;
|
||||
import org.dimdev.dimdoors.world.pocket.Pocket;
|
||||
import org.dimdev.dimdoors.world.pocket.PocketDirectory;
|
||||
import org.dimdev.dimdoors.world.pocket.PrivatePocketData;
|
||||
import org.dimdev.dimdoors.world.pocket.PrivateRegistry;
|
||||
import org.jgrapht.graph.DefaultDirectedGraph;
|
||||
import org.jgrapht.graph.DefaultEdge;
|
||||
|
||||
|
@ -308,7 +309,7 @@ public class RiftRegistry {
|
|||
if (entrance != null) return entrance.location;
|
||||
|
||||
// If there was no last used private entrance, get the first player's private pocket entrance
|
||||
return this.getPocketEntrance(PrivatePocketData.instance().getPrivatePocket(playerUUID));
|
||||
return this.getPocketEntrance(DimensionalRegistry.getPrivateRegistry().getPrivatePocket(playerUUID));
|
||||
}
|
||||
|
||||
private void setPlayerRiftPointer(UUID playerUUID, Location rift, Map<UUID, PlayerRiftPointer> map) {
|
||||
|
|
|
@ -10,7 +10,7 @@ import org.dimdev.dimdoors.util.RGBA;
|
|||
import org.dimdev.dimdoors.world.ModDimensions;
|
||||
import org.dimdev.dimdoors.world.pocket.Pocket;
|
||||
import org.dimdev.dimdoors.world.pocket.PocketDirectory;
|
||||
import org.dimdev.dimdoors.world.pocket.PrivatePocketData;
|
||||
import org.dimdev.dimdoors.world.pocket.PrivateRegistry;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
|
@ -30,8 +30,8 @@ public class PrivatePocketExitTarget extends VirtualTarget implements EntityTarg
|
|||
UUID uuid = EntityUtils.getOwner(entity).getUuid();
|
||||
if (uuid != null) {
|
||||
destLoc = DimensionalRegistry.getRiftRegistry().getPrivatePocketExit(uuid);
|
||||
Pocket pocket = PrivatePocketData.instance().getPrivatePocket(uuid);
|
||||
if (ModDimensions.isPocketDimension(this.location.getWorld()) && pocket != null && DimensionalRegistry.getPocketDirectory(pocket.world).getPocketAt(this.location.pos).equals(pocket)) {
|
||||
Pocket pocket = DimensionalRegistry.getPrivateRegistry().getPrivatePocket(uuid);
|
||||
if (ModDimensions.isPersonalPocketDimension(this.location.getWorld()) && pocket != null && DimensionalRegistry.getPocketDirectory(pocket.world).getPocketAt(this.location.pos).equals(pocket)) {
|
||||
DimensionalRegistry.getRiftRegistry().setLastPrivatePocketEntrance(uuid, this.location); // Remember which exit was used for next time the pocket is entered
|
||||
}
|
||||
if (destLoc == null || !(destLoc.getBlockEntity() instanceof RiftBlockEntity)) {
|
||||
|
|
|
@ -10,7 +10,7 @@ import org.dimdev.dimdoors.util.EntityUtils;
|
|||
import org.dimdev.dimdoors.util.Location;
|
||||
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.PrivateRegistry;
|
||||
import org.dimdev.dimdoors.world.pocket.VirtualLocation;
|
||||
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
|
@ -33,12 +33,12 @@ public class PrivatePocketTarget extends VirtualTarget implements EntityTarget {
|
|||
UUID uuid = EntityUtils.getOwner(entity).getUuid();
|
||||
VirtualLocation virtualLocation = VirtualLocation.fromLocation(this.location);
|
||||
if (uuid != null) {
|
||||
Pocket pocket = PrivatePocketData.instance().getPrivatePocket(uuid);
|
||||
Pocket pocket = DimensionalRegistry.getPrivateRegistry().getPrivatePocket(uuid);
|
||||
if (pocket == null) { // generate the private pocket and get its entrances
|
||||
// set to where the pocket was first created
|
||||
pocket = PocketGenerator.generatePrivatePocketV2(new VirtualLocation(virtualLocation.getWorld(), virtualLocation.getX(), virtualLocation.getZ(), -1));
|
||||
|
||||
PrivatePocketData.instance().setPrivatePocketID(uuid, pocket);
|
||||
DimensionalRegistry.getPrivateRegistry().setPrivatePocketID(uuid, pocket);
|
||||
BlockEntity be = DimensionalRegistry.getRiftRegistry().getPocketEntrance(pocket).getBlockEntity();
|
||||
this.processEntity(pocket, be, entity, uuid, yawOffset);
|
||||
} else {
|
||||
|
@ -49,7 +49,7 @@ public class PrivatePocketTarget extends VirtualTarget implements EntityTarget {
|
|||
LOGGER.info("All entrances are gone, creating a new private pocket!");
|
||||
pocket = PocketGenerator.generatePrivatePocketV2(new VirtualLocation(virtualLocation.getWorld(), virtualLocation.getX(), virtualLocation.getZ(), -1));
|
||||
|
||||
PrivatePocketData.instance().setPrivatePocketID(uuid, pocket);
|
||||
DimensionalRegistry.getPrivateRegistry().setPrivatePocketID(uuid, pocket);
|
||||
destLoc = DimensionalRegistry.getRiftRegistry().getPocketEntrance(pocket);
|
||||
}
|
||||
|
||||
|
@ -66,8 +66,11 @@ public class PrivatePocketTarget extends VirtualTarget implements EntityTarget {
|
|||
Item item = ((ItemEntity) entity).getStack().getItem();
|
||||
|
||||
if (item instanceof DyeItem) {
|
||||
pocket.addDye(EntityUtils.getOwner(entity), ((DyeItem) item).getColor());
|
||||
entity.remove();
|
||||
if(pocket.addDye(EntityUtils.getOwner(entity), ((DyeItem) item).getColor())) {
|
||||
entity.remove();
|
||||
} else {
|
||||
((EntityTarget) blockEntity).receiveEntity(entity, relativeYaw);
|
||||
}
|
||||
} else {
|
||||
((EntityTarget) blockEntity).receiveEntity(entity, relativeYaw);
|
||||
}
|
||||
|
|
|
@ -50,9 +50,11 @@ public final class ModDimensions {
|
|||
return isPocketDimension(world.getRegistryKey());
|
||||
}
|
||||
|
||||
public static boolean isPocketDimension(RegistryKey<World> type) {
|
||||
System.out.println("Type: " + type);
|
||||
public static boolean isPersonalPocketDimension(World world) {
|
||||
return isPocketDimension(world.getRegistryKey());
|
||||
}
|
||||
|
||||
public static boolean isPocketDimension(RegistryKey<World> type) {
|
||||
return Objects.equals(type, PERSONAL) || Objects.equals(type, PUBLIC) || Objects.equals(type, DUNGEON);
|
||||
}
|
||||
|
||||
|
|
|
@ -15,18 +15,20 @@ import dev.onyxstudios.cca.api.v3.component.ComponentV3;
|
|||
import org.dimdev.dimdoors.rift.registry.RiftRegistry;
|
||||
import org.dimdev.dimdoors.world.ModDimensions;
|
||||
import org.dimdev.dimdoors.world.pocket.PocketDirectory;
|
||||
import org.dimdev.dimdoors.world.pocket.PrivateRegistry;
|
||||
import static org.dimdev.dimdoors.DimensionalDoorsInitializer.getServer;
|
||||
|
||||
public class DimensionalRegistry implements ComponentV3 {
|
||||
public Map<RegistryKey<World>, PocketDirectory> pocketRegistry = new HashMap<>();
|
||||
RiftRegistry riftRegistry = new RiftRegistry();
|
||||
PrivateRegistry privateRegistry = new PrivateRegistry();
|
||||
|
||||
@Override
|
||||
public void readFromNbt(CompoundTag tag) {
|
||||
CompoundTag pocketRegistryTag = tag.getCompound("pocketRegistry");
|
||||
pocketRegistry = pocketRegistryTag.getKeys().stream().collect(Collectors.toMap(a -> RegistryKey.of(Registry.DIMENSION, new Identifier(a)), a -> PocketDirectory.readFromNbt(a, pocketRegistryTag.getCompound(a))));
|
||||
|
||||
riftRegistry = RiftRegistry.fromTag(pocketRegistry, tag.getCompound("riftRegistry"));
|
||||
privateRegistry.fromTag(tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -36,6 +38,7 @@ public class DimensionalRegistry implements ComponentV3 {
|
|||
|
||||
tag.put("pocketRegistry", pocketRegistryTag);
|
||||
tag.put("riftRegistry", riftRegistry.toTag());
|
||||
privateRegistry.toTag(tag);
|
||||
}
|
||||
|
||||
public static DimensionalRegistry instance() {
|
||||
|
@ -46,6 +49,10 @@ public class DimensionalRegistry implements ComponentV3 {
|
|||
return instance().riftRegistry;
|
||||
}
|
||||
|
||||
public static PrivateRegistry getPrivateRegistry() {
|
||||
return instance().privateRegistry;
|
||||
}
|
||||
|
||||
public static PocketDirectory getPocketDirectory(RegistryKey<World> key) {
|
||||
if (!(ModDimensions.isPocketDimension(key))) {
|
||||
throw new UnsupportedOperationException("PocketRegistry is only available for pocket dimensions!");
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package org.dimdev.dimdoors.world.pocket;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.stream.IntStream;
|
||||
|
@ -7,25 +9,32 @@ import java.util.stream.IntStream;
|
|||
import com.flowpowered.math.vector.Vector3i;
|
||||
import com.mojang.serialization.Codec;
|
||||
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import org.dimdev.dimdoors.DimensionalDoorsInitializer;
|
||||
import org.dimdev.dimdoors.block.AncientFabricBlock;
|
||||
import org.dimdev.dimdoors.block.FabricBlock;
|
||||
import org.dimdev.dimdoors.block.ModBlocks;
|
||||
import org.dimdev.dimdoors.world.level.DimensionalRegistry;
|
||||
import org.dimdev.dimdoors.util.EntityUtils;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
import net.minecraft.util.DyeColor;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.BlockBox;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Box;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.util.math.Vec3i;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.registry.RegistryKey;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public final class Pocket {
|
||||
private static final int BLOCKS_PAINTED_PER_DYE = 1106;
|
||||
private static final int BLOCKS_PAINTED_PER_DYE = 1000000;
|
||||
|
||||
// TODO: please someone make all these private and add a getter & setter where needed
|
||||
public final int id;
|
||||
|
@ -37,13 +46,14 @@ public final class Pocket {
|
|||
|
||||
public RegistryKey<World> world;
|
||||
|
||||
private Pocket(int id, BlockBox box, VirtualLocation virtualLocation, PocketColor dyeColor, PocketColor nextDyeColor, int count) {
|
||||
private Pocket(int id, BlockBox box, VirtualLocation virtualLocation, PocketColor dyeColor, PocketColor nextDyeColor, int count, RegistryKey<World> world) {
|
||||
this.id = id;
|
||||
this.box = box;
|
||||
this.virtualLocation = virtualLocation;
|
||||
this.dyeColor = dyeColor;
|
||||
this.nextDyeColor = nextDyeColor;
|
||||
this.count = count;
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
public Pocket(int id, RegistryKey<World> world, int x, int z) {
|
||||
|
@ -76,8 +86,9 @@ public final class Pocket {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (this.nextDyeColor != null && this.nextDyeColor == color) {
|
||||
if (this.count + 1 > amountOfDyeRequiredToColor(this)) {
|
||||
if (this.nextDyeColor != PocketColor.NONE && this.nextDyeColor == color) {
|
||||
if (this.count + 1 > maxDye) {
|
||||
repaint(dyeColor);
|
||||
this.dyeColor = color;
|
||||
this.nextDyeColor = PocketColor.NONE;
|
||||
this.count = 0;
|
||||
|
@ -94,37 +105,25 @@ public final class Pocket {
|
|||
return true;
|
||||
}
|
||||
|
||||
// private void repaint(DyeColor dyeColor) {
|
||||
// BlockPos origin = getOrigin();
|
||||
// World world = WorldUtils.getWorld(dim);
|
||||
// BlockState innerWall = ModBlocks.getDefaultState()..withProperty(..., dyeColor); // <-- forgot the exact name of the color property
|
||||
// BlockState outerWall = ModBlocks.ETERNAL_FABRIC.getDefaultState().withProperty(..., dyeColor);
|
||||
//
|
||||
// for (int x = origin.getX(); x < origin.getX() + size; x++) {
|
||||
// for (int y = origin.getY(); y < origin.getY() + size; y++) {
|
||||
// for (int z = origin.getZ(); z < origin.getZ() + size; z++) {
|
||||
// int layer = Collections.min(Arrays.asList(x, y, z, size - 1 - x, size - 1 - y, size - 1 - z));
|
||||
// if (layer == 0) {
|
||||
// if (world.getBlockState(x, y, z).getBlock() == ModBlocks.ETERNAL_FABRIC) {
|
||||
// world.setBlockState(x, y, z, outerWall);
|
||||
// }
|
||||
// } else if (layer < 5) {
|
||||
// if (world.getBlockState(x, y, z).getBlock() == ModBlocks.FABRIC) {
|
||||
// world.setBlockState(x, y, z, innerWall);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return schematic;
|
||||
// }
|
||||
private void repaint(DyeColor dyeColor) {
|
||||
ServerWorld serverWorld = DimensionalDoorsInitializer.getWorld(world);
|
||||
BlockState innerWall = ModBlocks.fabricFromDye(dyeColor).getDefaultState();
|
||||
BlockState outerWall = ModBlocks.ancientFabricFromDye(dyeColor).getDefaultState();
|
||||
|
||||
BlockPos.stream(box).forEach(pos -> {
|
||||
if (serverWorld.getBlockState(pos).getBlock() instanceof AncientFabricBlock) {
|
||||
serverWorld.setBlockState(pos, outerWall);
|
||||
} else if (serverWorld.getBlockState(pos).getBlock() instanceof FabricBlock) {
|
||||
serverWorld.setBlockState(pos, innerWall);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static int amountOfDyeRequiredToColor(Pocket pocket) {
|
||||
int outerVolume = pocket.box.getBlockCountX() * pocket.box.getBlockCountY() * pocket.box.getBlockCountZ();
|
||||
int innerVolume = (pocket.box.getBlockCountX() - 5) * (pocket.box.getBlockCountY() - 5) * (pocket.box.getBlockCountZ() - 5);
|
||||
|
||||
return (outerVolume - innerVolume) / BLOCKS_PAINTED_PER_DYE;
|
||||
return Math.min((outerVolume - innerVolume) / BLOCKS_PAINTED_PER_DYE, 1);
|
||||
}
|
||||
|
||||
public void setSize(int x, int y, int z) {
|
||||
|
@ -144,6 +143,7 @@ public final class Pocket {
|
|||
tag.putInt("dyeColor", this.dyeColor.getId());
|
||||
tag.putInt("nextDyeColor", this.nextDyeColor.getId());
|
||||
tag.putInt("count", this.count);
|
||||
tag.putString("world", world.getValue().toString());
|
||||
return tag;
|
||||
}
|
||||
|
||||
|
@ -155,7 +155,8 @@ public final class Pocket {
|
|||
VirtualLocation.fromTag(tag.getCompound("virtualLocation")),
|
||||
PocketColor.from(tag.getInt("dyeColor")),
|
||||
PocketColor.from(tag.getInt("nextDyeColor")),
|
||||
tag.getInt("count")
|
||||
tag.getInt("count"),
|
||||
RegistryKey.of(Registry.DIMENSION, new Identifier(tag.getString("world")))
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,8 @@ import java.util.UUID;
|
|||
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
|
||||
import dev.onyxstudios.cca.api.v3.component.ComponentV3;
|
||||
import org.dimdev.dimdoors.DimensionalDoorsInitializer;
|
||||
import org.dimdev.dimdoors.world.level.DimensionalRegistry;
|
||||
|
||||
|
@ -17,7 +19,7 @@ import net.minecraft.world.World;
|
|||
|
||||
import static net.minecraft.world.World.OVERWORLD;
|
||||
|
||||
public class PrivatePocketData extends PersistentState {
|
||||
public class PrivateRegistry {
|
||||
protected static class PocketInfo {
|
||||
public final RegistryKey<World> world;
|
||||
public final int id;
|
||||
|
@ -46,19 +48,9 @@ public class PrivatePocketData extends PersistentState {
|
|||
|
||||
protected BiMap<UUID, PocketInfo> privatePocketMap = HashBiMap.create(); // Player UUID -> Pocket Info TODO: fix AnnotatedNBT and use UUID rather than String
|
||||
|
||||
public PrivatePocketData(String name) {
|
||||
super(name);
|
||||
public PrivateRegistry() {
|
||||
}
|
||||
|
||||
public PrivatePocketData() {
|
||||
super(DATA_NAME);
|
||||
}
|
||||
|
||||
public static PrivatePocketData instance() {
|
||||
return DimensionalDoorsInitializer.getWorld(OVERWORLD).getPersistentStateManager().getOrCreate(PrivatePocketData::new, DATA_NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromTag(CompoundTag nbt) {
|
||||
CompoundTag tag = nbt.getCompound("privatePocketMap");
|
||||
|
||||
|
@ -69,7 +61,6 @@ public class PrivatePocketData extends PersistentState {
|
|||
this.privatePocketMap = bm;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag toTag(CompoundTag nbt) {
|
||||
CompoundTag tag = new CompoundTag();
|
||||
for (Map.Entry<UUID, PocketInfo> entry : this.privatePocketMap.entrySet()) {
|
||||
|
@ -88,7 +79,6 @@ public class PrivatePocketData extends PersistentState {
|
|||
|
||||
public void setPrivatePocketID(UUID playerUUID, Pocket pocket) {
|
||||
this.privatePocketMap.put(playerUUID, new PocketInfo(pocket.world, pocket.id));
|
||||
this.markDirty();
|
||||
}
|
||||
|
||||
public UUID getPrivatePocketOwner(Pocket pocket) {
|
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.
Loading…
Reference in a new issue