This commit is contained in:
Runemoro 2020-03-16 07:20:56 -04:00
parent a1a7c090ed
commit b0b45d79c8
56 changed files with 614 additions and 649 deletions

View file

@ -0,0 +1,7 @@
package org.dimdev;
public class Test {
public static void main(String[] args) {
System.out.println("a");
}
}

View file

@ -1,23 +1,22 @@
package org.dimdev.dimdoors;
import net.fabricmc.api.ModInitializer;
import net.minecraft.entity.Entity;
import net.minecraft.text.TranslatableText;
import org.dimdev.dimdoors.block.ModBlocks;
import org.dimdev.dimdoors.entity.ModEntityTypes;
import org.dimdev.dimdoors.item.ModItems;
import org.dimdev.dimdoors.pockets.SchematicHandler;
import org.dimdev.dimdoors.rift.targets.*;
import org.dimdev.dimdoors.world.ModBiomes;
import org.dimdev.dimdoors.world.ModDimensions;
public class DimDoors implements ModInitializer {
public static String getConfigurationFolder() {
return "config"; // TODO
}
public class DimensionalDoorsInitializer implements ModInitializer {
@Override
public void onInitialize() {
ModBlocks.init();
ModItems.init();
ModDimensions.init();
ModEntityTypes.init();
ModBiomes.init();
VirtualTarget.registry.put("available_link", RandomTarget.class);
VirtualTarget.registry.put("escape", EscapeTarget.class);
@ -32,5 +31,7 @@ public class DimDoors implements ModInitializer {
VirtualTarget.registry.put("relative", RelativeReference.class);
Targets.registerDefaultTargets();
SchematicHandler.INSTANCE.loadSchematics();
}
}

View file

@ -10,6 +10,7 @@ import net.minecraft.client.MinecraftClient;
import net.minecraft.entity.EntityContext;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes;
import net.minecraft.world.BlockView;
import net.minecraft.world.IWorld;
import net.minecraft.world.World;
@ -45,7 +46,7 @@ public class DetachedRiftBlock extends Block implements RiftProvider<DetachedRif
@Override
public VoxelShape getOutlineShape(BlockState blockState, BlockView blockView, BlockPos blockPos, EntityContext entityContext) {
return null; // TODO: show in creative
return VoxelShapes.empty();
}
@Override

View file

@ -19,6 +19,6 @@ public class EternalFluidBlock extends FluidBlock {
@Override
public void onEntityCollision(BlockState blockState, World world, BlockPos blockPos, Entity entity) {
TARGET.receiveEntity(entity, entity.yaw, 0);
TARGET.receiveEntity(entity, entity.yaw);
}
}

View file

@ -10,11 +10,11 @@ import net.minecraft.util.registry.Registry;
public final class ModBlocks {
public static final Block GOLD_DOOR = register("dimdoors:gold_door", new DoorBlock(FabricBlockSettings.of(Material.METAL, MaterialColor.GOLD).build()));
public static final Block QUARTZ_DOOR = register("dimdoors:quartz_door", new DoorBlock(FabricBlockSettings.of(Material.STONE, MaterialColor.QUARTZ).build()));
public static final Block WOOD_DIMENSIONAL_DOOR = register("dimdoors:wood_dimensional_door", new DimensionalDoorBlock(FabricBlockSettings.of(Material.WOOD, MaterialColor.WOOD).build()));
public static final Block OAK_DIMENSIONAL_DOOR = register("dimdoors:oak_dimensional_door", new DimensionalDoorBlock(FabricBlockSettings.of(Material.WOOD, MaterialColor.WOOD).build()));
public static final Block IRON_DIMENSIONAL_DOOR = register("dimdoors:iron_dimensional_door", new DimensionalDoorBlock(FabricBlockSettings.of(Material.METAL, MaterialColor.IRON).build()));
public static final Block GOLD_DIMENSIONAL_DOOR = register("dimdoors:gold_dimensional_door", new DimensionalDoorBlock(FabricBlockSettings.of(Material.METAL, MaterialColor.GOLD).build()));
public static final Block QUARTZ_DIMENSIONAL_DOOR = register("dimdoors:quartz_dimensional_door", new DimensionalDoorBlock(FabricBlockSettings.of(Material.STONE, MaterialColor.QUARTZ).build()));
public static final Block WOOD_DIMENSIONAL_TRAPDOOR = register("dimdoors:wood_dimensional_trapdoor", new DimensionalTrapdoorBlock(FabricBlockSettings.of(Material.WOOD, MaterialColor.WOOD).build()));
public static final Block OAK_DIMENSIONAL_TRAPDOOR = register("dimdoors:wood_dimensional_trapdoor", new DimensionalTrapdoorBlock(FabricBlockSettings.of(Material.WOOD, MaterialColor.WOOD).build()));
public static final Block DIMENSIONAL_PORTAL = register("dimdoors:dimensional_portal", new DimensionalPortalBlock(FabricBlockSettings.of(Material.AIR).collidable(false).dropsNothing().build()));
public static final Block DETACHED_RIFT = register("dimdoors:detached_rift", new DetachedRiftBlock(FabricBlockSettings.of(Material.AIR).nonOpaque().build()));
@ -53,10 +53,10 @@ public final class ModBlocks {
public static final Block RED_ANCIENT_FABRIC = register("dimdoors:red_ancient_fabric", new Block(FabricBlockSettings.of(Material.STONE, DyeColor.RED).strength(-1.0F, 3600000.0F).dropsNothing().build()));
public static final Block BLACK_ANCIENT_FABRIC = register("dimdoors:black_ancient_fabric", new Block(FabricBlockSettings.of(Material.STONE, DyeColor.BLACK).strength(-1.0F, 3600000.0F).dropsNothing().build()));
public static final Block ETERNAL_FABRIC = new EternalFluidBlock(FabricBlockSettings.of(Material.STONE, MaterialColor.RED).build());
public static final Block UNRAVELLED_FABRIC = new UnravelledFabricBlock(FabricBlockSettings.of(Material.STONE, MaterialColor.BLACK).build());
public static final Block ETERNAL_FLUID = register("dimdoors:eternal_fluid", new EternalFluidBlock(FabricBlockSettings.of(Material.STONE, MaterialColor.RED).build()));
public static final Block UNRAVELLED_FABRIC = register("dimdoors:unravelled_fabric", new UnravelledFabricBlock(FabricBlockSettings.of(Material.STONE, MaterialColor.BLACK).build()));
public static final Block MARKING_PLATE = new MarkingPlateBlock(FabricBlockSettings.of(Material.METAL, DyeColor.BLACK).build());
public static final Block MARKING_PLATE = register("dimdoors:marking_plate", new MarkingPlateBlock(FabricBlockSettings.of(Material.METAL, DyeColor.BLACK).build()));
private static Block register(String string, Block block) {
return Registry.register(Registry.BLOCK, string, block);

View file

@ -7,13 +7,11 @@ import net.minecraft.entity.EntityType;
import net.minecraft.entity.SpawnType;
import net.minecraft.entity.mob.EndermanEntity;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.Tickable;
import org.dimdev.annotatednbt.AnnotatedNbt;
import org.dimdev.annotatednbt.Saved;
import org.dimdev.dimdoors.ModConfig;
import org.dimdev.dimdoors.block.ModBlocks;
import org.dimdev.util.Location;
import org.dimdev.util.TeleportUtil;
import java.util.Random;
@ -98,8 +96,8 @@ public class DetachedRiftBlockEntity extends RiftBlockEntity implements Tickable
}
@Override
public boolean receiveEntity(Entity entity, float relativeYaw, float relativePitch) {
TeleportUtil.teleport(entity, new Location((ServerWorld) world, pos), entity.yaw, entity.pitch);
public boolean receiveEntity(Entity entity, float yawOffset) {
TeleportUtil.teleport(entity, world, pos, 0);
return true;
}

View file

@ -42,10 +42,10 @@ public class EntranceRiftBlockEntity extends RiftBlockEntity {
}
@Override
public boolean receiveEntity(Entity entity, float relativeYaw, float relativePitch) {
public boolean receiveEntity(Entity entity, float yawOffset) {
Vec3d targetPos = Vec3d.method_24953(pos).add(Vec3d.method_24954(getOrientation().getVector()).multiply(ModConfig.GENERAL.teleportOffset + 0.5));
TeleportUtil.teleport(entity, world, targetPos.x, targetPos.y, targetPos.z, entity.yaw + relativeYaw, entity.pitch + relativePitch);
TeleportUtil.teleport(entity, world, targetPos, yawOffset);
return true;
}

View file

@ -19,7 +19,7 @@ public class ModBlockEntityTypes {
public static final BlockEntityType<EntranceRiftBlockEntity> ENTRANCE_RIFT = register(
"dimdoors:entrance_rift",
EntranceRiftBlockEntity::new,
new Block[]{ModBlocks.WOOD_DIMENSIONAL_DOOR, ModBlocks.IRON_DIMENSIONAL_DOOR, ModBlocks.GOLD_DIMENSIONAL_DOOR, ModBlocks.QUARTZ_DIMENSIONAL_DOOR}
new Block[]{ModBlocks.OAK_DIMENSIONAL_DOOR, ModBlocks.IRON_DIMENSIONAL_DOOR, ModBlocks.GOLD_DIMENSIONAL_DOOR, ModBlocks.QUARTZ_DIMENSIONAL_DOOR}
);
private static <E extends BlockEntity> BlockEntityType<E> register(String id, Supplier<? extends E> supplier, Block[] blocks) {

View file

@ -91,7 +91,7 @@ public abstract class RiftBlockEntity extends BlockEntity implements BlockEntity
}
public boolean isRegistered() {
return !PocketTemplate.isReplacingPlaceholders() && RiftRegistry.instance().isRiftAt(new Location((ServerWorld) world, pos));
return !PocketTemplate.isReplacingPlaceholders() && RiftRegistry.instance(world).isRiftAt(new Location((ServerWorld) world, pos));
}
public void register() {
@ -100,26 +100,26 @@ public abstract class RiftBlockEntity extends BlockEntity implements BlockEntity
}
Location loc = new Location((ServerWorld) world, pos);
RiftRegistry.instance().addRift(loc);
RiftRegistry.instance(world).addRift(loc);
if (destination != null) destination.register();
updateProperties();
updateColor();
}
public void updateProperties() {
if (isRegistered()) RiftRegistry.instance().setProperties(new Location((ServerWorld) world, pos), properties);
if (isRegistered()) RiftRegistry.instance(world).setProperties(new Location((ServerWorld) world, pos), properties);
markDirty();
}
public void unregister() {
if (isRegistered()) {
RiftRegistry.instance().removeRift(new Location((ServerWorld) world, pos));
RiftRegistry.instance(world).removeRift(new Location((ServerWorld) world, pos));
}
}
public void updateType() {
if (!isRegistered()) return;
Rift rift = RiftRegistry.instance().getRift(new Location((ServerWorld) world, pos));
Rift rift = RiftRegistry.instance(world).getRift(new Location((ServerWorld) world, pos));
rift.isDetached = isDetached();
rift.markDirty();
}
@ -153,7 +153,7 @@ public abstract class RiftBlockEntity extends BlockEntity implements BlockEntity
try {
EntityTarget target = getTarget().as(Targets.ENTITY);
if (target.receiveEntity(entity, entity.yaw, entity.pitch)) {
if (target.receiveEntity(entity, entity.yaw)) {
VirtualLocation vloc = VirtualLocation.fromLocation(new Location((ServerWorld) entity.world, entity.getSenseCenterPos()));
entity.sendMessage(new TranslatableText("You are at x = " + vloc.x + ", y = ?, z = " + vloc.z + ", w = " + vloc.depth));
return true;

View file

@ -0,0 +1,20 @@
package org.dimdev.dimdoors.entity;
import net.fabricmc.fabric.api.client.rendereregistry.v1.EntityRendererRegistry;
import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.render.entity.EntityRenderer;
import net.minecraft.util.Identifier;
public class MaskRenderer extends EntityRenderer<MaskEntity> {
private final EntityRendererRegistry.Context context;
protected MaskRenderer(EntityRenderDispatcher dispatcher, EntityRendererRegistry.Context context) {
super(dispatcher);
this.context = context;
}
@Override
public Identifier getTexture(MaskEntity entity) {
return new Identifier("dimdoors:mask");
}
}

View file

@ -1,5 +1,7 @@
package org.dimdev.dimdoors.entity;
import net.fabricmc.fabric.api.client.rendereregistry.v1.EntityRendererRegistry;
import net.fabricmc.fabric.impl.object.builder.FabricEntityType;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityCategory;
import net.minecraft.entity.EntityDimensions;
@ -33,6 +35,11 @@ public class ModEntityTypes {
new EntityDimensions(1, 1, false)
);
public static void init() {
EntityRendererRegistry.INSTANCE.register(MONOLITH, MonolithRenderer::new);
EntityRendererRegistry.INSTANCE.register(MASK, MaskRenderer::new);
}
private static <E extends Entity> EntityType<E> register(String id, EntityType.EntityFactory<E> factory, EntityCategory category, boolean canSpawnFar, boolean saveable, boolean summonable, boolean immuneToFire, int i, int j, EntityDimensions dimensions) {
return Registry.register(Registry.ENTITY_TYPE, id, new EntityType<>(factory, category, canSpawnFar, saveable, summonable, immuneToFire, i, j, dimensions));
}

View file

@ -0,0 +1,20 @@
package org.dimdev.dimdoors.entity;
import net.fabricmc.fabric.api.client.rendereregistry.v1.EntityRendererRegistry;
import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.render.entity.EntityRenderer;
import net.minecraft.util.Identifier;
public class MonolithRenderer extends EntityRenderer<MonolithEntity> {
private final EntityRendererRegistry.Context context;
protected MonolithRenderer(EntityRenderDispatcher dispatcher, EntityRendererRegistry.Context context) {
super(dispatcher);
this.context = context;
}
@Override
public Identifier getTexture(MonolithEntity entity) {
return new Identifier("dimdoors:monolith");
}
}

View file

@ -0,0 +1,154 @@
package org.dimdev.dimdoors.fluid;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.block.BlockState;
import net.minecraft.block.FluidBlock;
import net.minecraft.fluid.*;
import net.minecraft.item.Item;
import net.minecraft.item.Items;
import net.minecraft.state.StateManager;
import net.minecraft.tag.FluidTags;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.BlockView;
import net.minecraft.world.IWorld;
import net.minecraft.world.World;
import net.minecraft.world.WorldView;
import org.dimdev.dimdoors.block.ModBlocks;
import java.util.Random;
public abstract class EternalFluid extends BaseFluid {
@Override
public Fluid getFlowing() {
return Fluids.FLOWING_LAVA;
}
@Override
public Fluid getStill() {
return Fluids.LAVA;
}
@Override
public Item getBucketItem() {
return Items.LAVA_BUCKET;
}
@Override
@Environment(EnvType.CLIENT)
public void randomDisplayTick(World world, BlockPos blockPos, FluidState fluidState, Random random) {
}
@Override
public void onRandomTick(World world, BlockPos blockPos, FluidState fluidState, Random random) {
}
@Override
protected void beforeBreakingBlock(IWorld iWorld, BlockPos blockPos, BlockState blockState) {
}
@Override
public int method_15733(WorldView worldView) {
return worldView.getDimension().doesWaterVaporize() ? 4 : 2;
}
@Override
public BlockState toBlockState(FluidState fluidState) {
return ModBlocks.ETERNAL_FLUID.getDefaultState().with(FluidBlock.LEVEL, method_15741(fluidState));
}
@Override
public boolean matchesType(Fluid fluid) {
return fluid == ModFluids.ETERNAL_FLUID || fluid == ModFluids.FLOWING_ETERNAL_FLUID;
}
@Override
public int getLevelDecreasePerBlock(WorldView worldView) {
return worldView.getDimension().doesWaterVaporize() ? 1 : 2;
}
@Override
public boolean canBeReplacedWith(FluidState fluidState, BlockView blockView, BlockPos blockPos, Fluid fluid, Direction direction) {
return fluidState.getHeight(blockView, blockPos) >= 0.44444445F && fluid.isIn(FluidTags.WATER);
}
@Override
public int getTickRate(WorldView worldView) {
return worldView.getDimension().isNether() ? 10 : 30;
}
@Override
public int getNextTickDelay(World world, BlockPos blockPos, FluidState fluidState, FluidState fluidState2) {
int tickDelay = getTickRate(world);
if (!fluidState.isEmpty() && !fluidState2.isEmpty() && !fluidState.get(FALLING) && !fluidState2.get(FALLING) && fluidState2.getHeight(world, blockPos) > fluidState.getHeight(world, blockPos) && world.getRandom().nextInt(4) != 0) {
tickDelay *= 4;
}
return tickDelay;
}
@Override
protected boolean isInfinite() {
return false;
}
@Override
protected void flow(IWorld world, BlockPos pos, BlockState blockState, Direction direction, FluidState fluidState) {
if (direction == Direction.DOWN) {
if (world.getFluidState(pos).matches(FluidTags.WATER)) {
if (blockState.getBlock() instanceof FluidBlock) {
world.setBlockState(pos, ModBlocks.BLACK_ANCIENT_FABRIC.getDefaultState(), 3);
}
return;
}
}
super.flow(world, pos, blockState, direction, fluidState);
}
@Override
protected boolean hasRandomTicks() {
return true;
}
@Override
protected float getBlastResistance() {
return 100000;
}
public static class Flowing extends LavaFluid {
@Override
protected void appendProperties(StateManager.Builder<Fluid, FluidState> builder) {
super.appendProperties(builder);
builder.add(LEVEL);
}
@Override
public int getLevel(FluidState fluidState) {
return fluidState.get(LEVEL);
}
@Override
public boolean isStill(FluidState fluidState) {
return false;
}
}
public static class Still extends LavaFluid {
@Override
public int getLevel(FluidState fluidState) {
return 8;
}
@Override
public boolean isStill(FluidState fluidState) {
return true;
}
}
}

View file

@ -1,79 +0,0 @@
package org.dimdev.dimdoors.fluid;
import net.minecraft.block.BlockState;
import net.minecraft.fluid.BaseFluid;
import net.minecraft.fluid.Fluid;
import net.minecraft.fluid.FluidState;
import net.minecraft.item.Item;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.BlockView;
import net.minecraft.world.IWorld;
import net.minecraft.world.WorldView;
public class EternalLiquidFluid extends BaseFluid { // TODO
@Override
public Fluid getFlowing() {
return null;
}
@Override
public Fluid getStill() {
return null;
}
@Override
protected boolean isInfinite() {
return false;
}
@Override
protected void beforeBreakingBlock(IWorld iWorld, BlockPos blockPos, BlockState blockState) {
}
@Override
protected int method_15733(WorldView worldView) {
return 0;
}
@Override
protected int getLevelDecreasePerBlock(WorldView worldView) {
return 0;
}
@Override
public Item getBucketItem() {
return null;
}
@Override
protected boolean canBeReplacedWith(FluidState fluidState, BlockView blockView, BlockPos blockPos, Fluid fluid, Direction direction) {
return false;
}
@Override
public int getTickRate(WorldView worldView) {
return 0;
}
@Override
protected float getBlastResistance() {
return 0;
}
@Override
protected BlockState toBlockState(FluidState fluidState) {
return null;
}
@Override
public boolean isStill(FluidState fluidState) {
return false;
}
@Override
public int getLevel(FluidState fluidState) {
return 0;
}
}

View file

@ -5,7 +5,8 @@ import net.minecraft.fluid.Fluid;
import net.minecraft.util.registry.Registry;
public class ModFluids {
public static final BaseFluid ETERNAL_FLUID = register("dimdoors:eternal_fluid", new EternalLiquidFluid());
public static final BaseFluid ETERNAL_FLUID = register("dimdoors:eternal_fluid", new EternalFluid.Still());
public static final BaseFluid FLOWING_ETERNAL_FLUID = register("dimdoors:flowing_eternal_fluid", new EternalFluid.Flowing());
private static <T extends Fluid> T register(String string, T fluid) {
return (T) Registry.register(Registry.FLUID, string, fluid);

View file

@ -16,9 +16,9 @@ public final class ModItemGroups {
new ItemStack(ModItems.GOLD_DOOR),
new ItemStack(ModItems.GOLD_DIMENSIONAL_DOOR),
new ItemStack(ModItems.IRON_DIMENSIONAL_DOOR),
new ItemStack(ModItems.WOOD_DIMENSIONAL_DOOR),
new ItemStack(ModItems.UNSTABLE_DIMENSIONAL_DOOR),
new ItemStack(ModItems.WOOD_DIMENSIONAL_TRAPDOOR),
new ItemStack(ModItems.OAK_DIMENSIONAL_DOOR),
// new ItemStack(ModItems.UNSTABLE_DIMENSIONAL_DOOR),
new ItemStack(ModItems.OAK_DIMENSIONAL_TRAPDOOR),
new ItemStack(ModItems.WORLD_THREAD),
new ItemStack(ModItems.RIFT_CONFIGURATION_TOOL),
new ItemStack(ModItems.RIFT_BLADE),

View file

@ -63,16 +63,16 @@ public final class ModItems {
}
));
public static final Item UNSTABLE_DIMENSIONAL_DOOR = register(new DimensionalDoorItem(
ModBlocks.IRON_DIMENSIONAL_DOOR,
new Item.Settings().group(ModItemGroups.DIMENSIONAL_DOORS).maxCount(1),
rift -> {
// TODO
}
));
// public static final Item UNSTABLE_DIMENSIONAL_DOOR = register( new DimensionalDoorItem(
// ModBlocks.IRON_DIMENSIONAL_DOOR,
// new Item.Settings().group(ModItemGroups.DIMENSIONAL_DOORS).maxCount(1),
// rift -> {
// TODO
// }
// ));
public static final Item WOOD_DIMENSIONAL_DOOR = register(new DimensionalDoorItem(
ModBlocks.WOOD_DIMENSIONAL_DOOR,
public static final Item OAK_DIMENSIONAL_DOOR = register(new DimensionalDoorItem(
ModBlocks.OAK_DIMENSIONAL_DOOR,
new Item.Settings().group(ModItemGroups.DIMENSIONAL_DOORS).maxCount(1),
rift -> rift.setDestination(
RandomTarget
@ -86,8 +86,8 @@ public final class ModItems {
)
));
public static final Item WOOD_DIMENSIONAL_TRAPDOOR = register(new DimensionalTrapdoorItem(
ModBlocks.WOOD_DIMENSIONAL_DOOR,
public static final Item OAK_DIMENSIONAL_TRAPDOOR = register(new DimensionalTrapdoorItem(
ModBlocks.OAK_DIMENSIONAL_TRAPDOOR,
new Item.Settings().group(ModItemGroups.DIMENSIONAL_DOORS).maxCount(1),
rift -> rift.setDestination(new EscapeTarget(false))
));
@ -126,7 +126,7 @@ public final class ModItems {
public static final Item RED_ANCIENT_FABRIC = register(ModBlocks.RED_ANCIENT_FABRIC);
public static final Item BLACK_ANCIENT_FABRIC = register(ModBlocks.BLACK_ANCIENT_FABRIC);
public static final Item ETERNAL_FABRIC = register(ModBlocks.ETERNAL_FABRIC);
public static final Item ETERNAL_FABRIC = register(ModBlocks.ETERNAL_FLUID);
public static final Item UNRAVELLED_FABRIC = register(ModBlocks.UNRAVELLED_FABRIC);
public static final Item MARKING_PLATE = register(ModBlocks.MARKING_PLATE);

View file

@ -65,9 +65,10 @@ public class RiftBladeItem extends SwordItem {
Vec3d offsetDirection = playerVec.subtract(entityVec).normalize();
offsetDirection = offsetDirection.rotateY((float) (offsetRotationYaw * Math.PI) / 180);
BlockPos tpPos = new BlockPos(entityVec.add(offsetDirection.multiply(offsetDistance)));
while (world.getBlockState(tpPos).getMaterial().blocksMovement()) tpPos = tpPos.up(); // TODO: move to ddutils
TeleportUtil.teleport(player, new Location((ServerWorld) world, tpPos), (player.yaw - (float) offsetRotationYaw) % 360, player.pitch);
BlockPos teleportPosition = new BlockPos(entityVec.add(offsetDirection.multiply(offsetDistance)));
while (world.getBlockState(teleportPosition).getMaterial().blocksMovement()) teleportPosition = teleportPosition.up();
player.teleport(teleportPosition.getX(), teleportPosition.getY(), teleportPosition.getZ());
player.setYaw((float) (Math.random() * 2 * Math.PI));
stack.damage(1, player, a -> {});
return new TypedActionResult<>(ActionResult.SUCCESS, stack);

View file

@ -1,7 +1,6 @@
package org.dimdev.dimdoors.pockets;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.world.World;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.dimdev.dimdoors.ModConfig;
@ -11,7 +10,6 @@ import org.dimdev.dimdoors.world.ModDimensions;
import org.dimdev.pocketlib.Pocket;
import org.dimdev.pocketlib.PocketRegistry;
import org.dimdev.pocketlib.VirtualLocation;
import org.dimdev.util.WorldUtils;
import java.util.Random;
@ -41,13 +39,13 @@ public final class PocketGenerator {
public static Pocket generatePrivatePocket(VirtualLocation virtualLocation) {
PocketTemplate pocketTemplate = SchematicHandler.INSTANCE.getPersonalPocketTemplate();
return generatePocketFromTemplate(WorldUtils.getWorld(ModDimensions.PERSONAL), pocketTemplate, virtualLocation, true);
return generatePocketFromTemplate(virtualLocation.world.getServer().getWorld(ModDimensions.PERSONAL), pocketTemplate, virtualLocation, true);
}
// TODO: size of public pockets should increase with depth
public static Pocket generatePublicPocket(VirtualLocation virtualLocation, VirtualTarget linkTo, LinkProperties linkProperties) {
PocketTemplate pocketTemplate = SchematicHandler.INSTANCE.getPublicPocketTemplate();
return generatePocketFromTemplate(WorldUtils.getWorld(ModDimensions.PUBLIC), pocketTemplate, virtualLocation, linkTo, linkProperties);
return generatePocketFromTemplate(virtualLocation.world.getServer().getWorld(ModDimensions.PUBLIC), pocketTemplate, virtualLocation, linkTo, linkProperties);
}
/**
@ -63,6 +61,6 @@ public final class PocketGenerator {
String group = random.nextFloat() < netherProbability ? "nether" : "ruins";
PocketTemplate pocketTemplate = SchematicHandler.INSTANCE.getRandomTemplate(group, depth, ModConfig.POCKETS.maxPocketSize, false);
return generatePocketFromTemplate(WorldUtils.getWorld(ModDimensions.DUNGEON), pocketTemplate, virtualLocation, linkTo, linkProperties);
return generatePocketFromTemplate(virtualLocation.world.getServer().getWorld(ModDimensions.DUNGEON), pocketTemplate, virtualLocation, linkTo, linkProperties);
}
}

View file

@ -261,7 +261,7 @@ public class PocketTemplate {
PocketRegistry.instance(world).markDirty();
rift.setDestination(((PocketEntranceMarker) dest).getIfDestination());
rift.register();
RiftRegistry.instance().addPocketEntrance(pocket, new Location((ServerWorld) rift.getWorld(), rift.getPos()));
RiftRegistry.instance(world).addPocketEntrance(pocket, new Location((ServerWorld) rift.getWorld(), rift.getPos()));
} else {
rift.setDestination(((PocketEntranceMarker) dest).getOtherwiseDestination());
}

View file

@ -11,7 +11,7 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.dimdev.util.math.MathUtil;
import org.dimdev.util.schem.Schematic;
import org.dimdev.dimdoors.DimDoors;
import org.dimdev.dimdoors.DimensionalDoorsInitializer;
import org.dimdev.dimdoors.ModConfig;
import java.io.*;
@ -30,6 +30,10 @@ public class SchematicHandler { // TODO: parts of this should be moved to the or
private static final String SAVED_POCKETS_GROUP_NAME = "saved_pockets";
public static final SchematicHandler INSTANCE = new SchematicHandler();
private static String getFolder() {
return "config"; // TODO
}
public Schematic loadSchematicFromByteArray(byte[] schematicBytecode) {
Schematic schematic = null;
try {
@ -54,7 +58,7 @@ public class SchematicHandler { // TODO: parts of this should be moved to the or
String[] names = {"default_dungeon_nether", "default_dungeon_normal", "default_private", "default_public", "default_blank"}; // TODO: don't hardcode
for (String name : names) {
try {
URL resource = DimDoors.class.getResource("/assets/dimdoors/pockets/json/" + name + ".json");
URL resource = DimensionalDoorsInitializer.class.getResource("/assets/dimdoors/pockets/json/" + name + ".json");
String jsonString = IOUtils.toString(resource, StandardCharsets.UTF_8);
templates.addAll(loadTemplatesFromJson(jsonString));
} catch (IOException e) {
@ -63,12 +67,12 @@ public class SchematicHandler { // TODO: parts of this should be moved to the or
}
// Init json config folder
File jsonFolder = new File(DimDoors.getConfigurationFolder(), "/jsons");
File jsonFolder = new File(getFolder(), "/jsons");
if (!jsonFolder.exists()) {
jsonFolder.mkdirs();
}
// Init schematics config folder
File schematicFolder = new File(DimDoors.getConfigurationFolder(), "/schematics");
File schematicFolder = new File(getFolder(), "/schematics");
if (!schematicFolder.exists()) {
schematicFolder.mkdirs();
}
@ -85,7 +89,7 @@ public class SchematicHandler { // TODO: parts of this should be moved to the or
}
// Load saved schematics
File saveFolder = new File(DimDoors.getConfigurationFolder(), "/schematics/saved");
File saveFolder = new File(getFolder(), "/schematics/saved");
if (saveFolder.exists()) {
for (File file : saveFolder.listFiles()) {
if (file.isDirectory() || !file.getName().endsWith(".schem")) continue;
@ -107,7 +111,7 @@ public class SchematicHandler { // TODO: parts of this should be moved to the or
private static List<PocketTemplate> loadTemplatesFromJson(String jsonString) {
String schematicJarDirectory = "/assets/dimdoors/pockets/schematic/";
File schematicFolder = new File(DimDoors.getConfigurationFolder(), "/schematics");
File schematicFolder = new File(getFolder(), "/schematics");
JsonParser parser = new JsonParser();
JsonElement jsonElement = parser.parse(jsonString);
@ -123,7 +127,7 @@ public class SchematicHandler { // TODO: parts of this should be moved to the or
String extendedTemplatelocation = subDirectory.equals("") ? template.getId() : subDirectory + "/" + template.getId() + ".schem"; //transform the filename accordingly
//Initialising the possible locations/formats for the schematic file
InputStream schematicStream = DimDoors.class.getResourceAsStream(schematicJarDirectory + extendedTemplatelocation);
InputStream schematicStream = DimensionalDoorsInitializer.class.getResourceAsStream(schematicJarDirectory + extendedTemplatelocation);
File schematicFile = new File(schematicFolder, "/" + extendedTemplatelocation);
//determine which location to load the schematic file from (and what format)
@ -305,7 +309,7 @@ public class SchematicHandler { // TODO: parts of this should be moved to the or
public static void saveSchematic(Schematic schematic, String id) {
CompoundTag schematicNBT = schematic.saveToNBT();
File saveFolder = new File(DimDoors.getConfigurationFolder(), "/schematics/saved");
File saveFolder = new File(getFolder(), "/schematics/saved");
if (!saveFolder.exists()) {
saveFolder.mkdirs();
}

View file

@ -52,8 +52,8 @@ public class Rift extends RegistryVertex {
public void markDirty() {
((RiftBlockEntity) location.getBlockEntity()).updateColor();
for (Location location : RiftRegistry.instance().getSources(location)) {
RiftRegistry.instance().getRift(location).targetChanged(this);
for (Location location : RiftRegistry.instance(world).getSources(location)) {
RiftRegistry.instance(world).getRift(location).targetChanged(this);
}
}

View file

@ -3,8 +3,9 @@ package org.dimdev.dimdoors.rift.registry;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.Tag;
import net.minecraft.util.Identifier;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.PersistentState;
import net.minecraft.world.World;
import net.minecraft.world.dimension.DimensionType;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@ -13,7 +14,6 @@ import org.dimdev.pocketlib.PocketRegistry;
import org.dimdev.pocketlib.PrivatePocketData;
import org.dimdev.util.GraphUtils;
import org.dimdev.util.Location;
import org.dimdev.util.WorldUtils;
import org.jgrapht.graph.DefaultDirectedGraph;
import org.jgrapht.graph.DefaultEdge;
@ -32,17 +32,19 @@ public class RiftRegistry extends PersistentState {
protected Map<UUID, PlayerRiftPointer> lastPrivatePocketEntrances = new HashMap<>(); // Player UUID -> last rift used to exit pocket
protected Map<UUID, PlayerRiftPointer> lastPrivatePocketExits = new HashMap<>(); // Player UUID -> last rift used to enter pocket
protected Map<UUID, PlayerRiftPointer> overworldRifts = new HashMap<>(); // Player UUID -> rift used to exit the overworld
private final World overworld;
public RiftRegistry() {
public RiftRegistry(World overworld) {
super(DATA_NAME);
this.overworld = overworld;
}
public RiftRegistry(String s) {
super(s);
public static RiftRegistry instance(World world) {
return instance(world.getServer());
}
public static RiftRegistry instance() {
return WorldUtils.getWorld(DimensionType.OVERWORLD).getPersistentStateManager().get(RiftRegistry::new, DATA_NAME);
private static RiftRegistry instance(MinecraftServer server) {
return server.getWorld(DimensionType.OVERWORLD).getPersistentStateManager().getOrCreate(() -> new RiftRegistry(server.getWorld(DimensionType.OVERWORLD)), DATA_NAME);
}
@Override
@ -308,7 +310,7 @@ public class RiftRegistry extends PersistentState {
if (entrance != null) return entrance.location;
// If there was no last used private entrance, get the first player's private pocket entrance
return getPocketEntrance(PrivatePocketData.instance().getPrivatePocket(playerUUID));
return getPocketEntrance(PrivatePocketData.instance(overworld).getPrivatePocket(playerUUID));
}
private void setPlayerRiftPointer(UUID playerUUID, Location rift, Map<UUID, PlayerRiftPointer> map) {

View file

@ -3,5 +3,5 @@ package org.dimdev.dimdoors.rift.targets;
import net.minecraft.entity.Entity;
public interface EntityTarget extends Target {
boolean receiveEntity(Entity entity, float relativeYaw, float relativePitch);
boolean receiveEntity(Entity entity, float yawOffset);
}

View file

@ -1,5 +1,6 @@
package org.dimdev.dimdoors.rift.targets;
import net.fabricmc.fabric.api.dimension.v1.FabricDimensions;
import net.minecraft.entity.Entity;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.server.world.ServerWorld;
@ -33,7 +34,7 @@ public class EscapeTarget extends VirtualTarget implements EntityTarget { // TOD
}
@Override
public boolean receiveEntity(Entity entity, float relativeYaw, float relativePitch) {
public boolean receiveEntity(Entity entity, float yawOffset) {
if (!ModDimensions.isDimDoorsPocketDimension(entity.world) && !(entity.world.dimension instanceof LimboDimension)) {
entity.sendMessage(new TranslatableText("rifts.destinations.escape.not_in_pocket_dim"));
return false;
@ -45,9 +46,10 @@ public class EscapeTarget extends VirtualTarget implements EntityTarget { // TOD
UUID uuid = entity.getUuid();
if (uuid != null) {
Location destLoc = RiftRegistry.instance().getOverworldRift(uuid);
Location destLoc = RiftRegistry.instance(entity.world).getOverworldRift(uuid);
if (destLoc != null && destLoc.getBlockEntity() instanceof RiftBlockEntity || canEscapeLimbo) {
TeleportUtil.teleport(entity, VirtualLocation.fromLocation(new Location((ServerWorld) entity.world, entity.getSenseCenterPos())).projectToWorld(false));
Location location = VirtualLocation.fromLocation(new Location((ServerWorld) entity.world, entity.getSenseCenterPos())).projectToWorld(false);
TeleportUtil.teleport(entity, location.world, location.pos, 0);
return true;
} else {
if (destLoc == null) {
@ -55,7 +57,7 @@ public class EscapeTarget extends VirtualTarget implements EntityTarget { // TOD
} else {
entity.sendMessage(new TranslatableText("rifts.destinations.escape.rift_has_closed"));
}
TeleportUtil.teleport(entity, LimboDimension.getLimboSkySpawn(entity));
FabricDimensions.teleport(entity, ModDimensions.LIMBO);
return true;
}
} else {

View file

@ -1,9 +1,9 @@
package org.dimdev.dimdoors.rift.targets;
import net.fabricmc.fabric.api.dimension.v1.FabricDimensions;
import net.minecraft.entity.Entity;
import net.minecraft.nbt.CompoundTag;
import org.dimdev.dimdoors.world.limbo.LimboDimension;
import org.dimdev.util.TeleportUtil;
import org.dimdev.dimdoors.world.ModDimensions;
public class LimboTarget extends VirtualTarget implements EntityTarget {
public LimboTarget() {}
@ -20,8 +20,8 @@ public class LimboTarget extends VirtualTarget implements EntityTarget {
}
@Override
public boolean receiveEntity(Entity entity, float relativeYaw, float relativePitch) {
TeleportUtil.teleport(entity, LimboDimension.getLimboSkySpawn(entity));
public boolean receiveEntity(Entity entity, float yawOffset) {
FabricDimensions.teleport(entity, ModDimensions.LIMBO);
return true;
}
}

View file

@ -21,11 +21,11 @@ public class MessageTarget implements EntityTarget {
}
@Override
public boolean receiveEntity(Entity entity, float relativeYaw, float relativePitch) {
public boolean receiveEntity(Entity entity, float yawOffset) {
entity.sendMessage(new TranslatableText(message, messageParams));
if (forwardTo != null) {
forwardTo.as(Targets.ENTITY).receiveEntity(entity, relativeYaw, relativePitch);
forwardTo.as(Targets.ENTITY).receiveEntity(entity, yawOffset);
return true;
} else {
return false;

View file

@ -40,7 +40,7 @@ public class PocketEntranceMarker extends VirtualTarget implements EntityTarget
}
@Override
public boolean receiveEntity(Entity entity, float relativeYaw, float relativePitch) {
public boolean receiveEntity(Entity entity, float yawOffset) {
entity.sendMessage(new TranslatableText("The entrance of this dungeon has not been converted. If this is a normally generated pocket, please report this bug."));
return false;
}

View file

@ -19,7 +19,7 @@ public class PocketExitMarker extends VirtualTarget implements EntityTarget {
}
@Override
public boolean receiveEntity(Entity entity, float relativeYaw, float relativePitch) {
public boolean receiveEntity(Entity entity, float yawOffset) {
entity.sendMessage(new TranslatableText("The exit of this dungeon has not been linked. If this is a normally generated pocket, please report this bug."));
return false;
}

View file

@ -1,18 +1,18 @@
package org.dimdev.dimdoors.rift.targets;
import net.fabricmc.fabric.api.dimension.v1.FabricDimensions;
import net.minecraft.entity.Entity;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.text.TranslatableText;
import org.dimdev.dimdoors.block.entity.RiftBlockEntity;
import org.dimdev.dimdoors.rift.registry.RiftRegistry;
import org.dimdev.dimdoors.world.limbo.LimboDimension;
import org.dimdev.dimdoors.world.ModDimensions;
import org.dimdev.dimdoors.world.pocketdimension.PersonalPocketDimension;
import org.dimdev.pocketlib.Pocket;
import org.dimdev.pocketlib.PocketRegistry;
import org.dimdev.pocketlib.PrivatePocketData;
import org.dimdev.util.EntityUtils;
import org.dimdev.util.Location;
import org.dimdev.util.TeleportUtil;
import java.util.UUID;
@ -31,15 +31,15 @@ public class PrivatePocketExitTarget extends VirtualTarget implements EntityTarg
}
@Override
public boolean receiveEntity(Entity entity, float relativeYaw, float relativePitch) {
public boolean receiveEntity(Entity entity, float yawOffset) {
Location destLoc;
// TODO: make this recursive
UUID uuid = EntityUtils.getOwner(entity).getUuid();
if (uuid != null) {
destLoc = RiftRegistry.instance().getPrivatePocketExit(uuid);
Pocket pocket = PrivatePocketData.instance().getPrivatePocket(uuid);
destLoc = RiftRegistry.instance(entity.world).getPrivatePocketExit(uuid);
Pocket pocket = PrivatePocketData.instance(entity.world).getPrivatePocket(uuid);
if (location.world.dimension instanceof PersonalPocketDimension && pocket != null && PocketRegistry.instance(pocket.world).getPocketAt(location.pos).equals(pocket)) {
RiftRegistry.instance().setLastPrivatePocketEntrance(uuid, location); // Remember which exit was used for next time the pocket is entered
RiftRegistry.instance(entity.world).setLastPrivatePocketEntrance(uuid, location); // Remember which exit was used for next time the pocket is entered
}
if (destLoc == null || !(destLoc.getBlockEntity() instanceof RiftBlockEntity)) {
if (destLoc == null) {
@ -47,10 +47,10 @@ public class PrivatePocketExitTarget extends VirtualTarget implements EntityTarg
} else {
entity.sendMessage(new TranslatableText("rifts.destinations.private_pocket_exit.rift_has_closed"));
}
TeleportUtil.teleport(entity, LimboDimension.getLimboSkySpawn(entity));
FabricDimensions.teleport(entity, ModDimensions.LIMBO);
return false;
} else {
((EntityTarget) destLoc.getBlockEntity()).receiveEntity(entity, relativeYaw, relativePitch);
((EntityTarget) destLoc.getBlockEntity()).receiveEntity(entity, yawOffset);
return true;
}
} else {
@ -63,7 +63,7 @@ public class PrivatePocketExitTarget extends VirtualTarget implements EntityTarg
super.register();
PocketRegistry privatePocketRegistry = PocketRegistry.instance(location.world);
Pocket pocket = privatePocketRegistry.getPocketAt(location.pos);
RiftRegistry.instance().addPocketEntrance(pocket, location);
RiftRegistry.instance(location.world).addPocketEntrance(pocket, location);
}
@Override

View file

@ -33,12 +33,12 @@ public class PrivatePocketTarget extends VirtualTarget implements EntityTarget {
}
@Override
public boolean receiveEntity(Entity entity, float relativeYaw, float relativePitch) {
public boolean receiveEntity(Entity entity, float yawOffset) {
// TODO: make this recursive
UUID uuid = EntityUtils.getOwner(entity).getUuid();
VirtualLocation virtualLocation = VirtualLocation.fromLocation(location);
if (uuid != null) {
Pocket pocket = PrivatePocketData.instance().getPrivatePocket(uuid);
Pocket pocket = PrivatePocketData.instance(entity.world).getPrivatePocket(uuid);
if (pocket == null) { // generate the private pocket and get its entrances
// set to where the pocket was first created
pocket = PocketGenerator.generatePrivatePocket(virtualLocation != null ?
@ -46,12 +46,12 @@ public class PrivatePocketTarget extends VirtualTarget implements EntityTarget {
null
);
PrivatePocketData.instance().setPrivatePocketID(uuid, pocket);
processEntity(pocket, RiftRegistry.instance().getPocketEntrance(pocket).getBlockEntity(), entity, uuid, relativeYaw, relativePitch);
PrivatePocketData.instance(entity.world).setPrivatePocketID(uuid, pocket);
processEntity(pocket, RiftRegistry.instance(entity.world).getPocketEntrance(pocket).getBlockEntity(), entity, uuid, yawOffset);
return true;
} else {
Location destLoc = RiftRegistry.instance().getPrivatePocketEntrance(uuid); // get the last used entrances
if (destLoc == null) destLoc = RiftRegistry.instance().getPocketEntrance(pocket); // if there's none, then set the target to the main entrances
Location destLoc = RiftRegistry.instance(entity.world).getPrivatePocketEntrance(uuid); // get the last used entrances
if (destLoc == null) destLoc = RiftRegistry.instance(entity.world).getPocketEntrance(pocket); // if there's none, then set the target to the main entrances
if (destLoc == null) { // if the pocket entrances is gone, then create a new private pocket
LOGGER.info("All entrances are gone, creating a new private pocket!");
pocket = PocketGenerator.generatePrivatePocket(virtualLocation != null ?
@ -59,11 +59,11 @@ public class PrivatePocketTarget extends VirtualTarget implements EntityTarget {
null
);
PrivatePocketData.instance().setPrivatePocketID(uuid, pocket);
destLoc = RiftRegistry.instance().getPocketEntrance(pocket);
PrivatePocketData.instance(entity.world).setPrivatePocketID(uuid, pocket);
destLoc = RiftRegistry.instance(entity.world).getPocketEntrance(pocket);
}
processEntity(pocket, destLoc.getBlockEntity(), entity, uuid, relativePitch, relativePitch);
processEntity(pocket, destLoc.getBlockEntity(), entity, uuid, yawOffset);
return true;
}
} else {
@ -71,7 +71,7 @@ public class PrivatePocketTarget extends VirtualTarget implements EntityTarget {
}
}
private void processEntity(Pocket pocket, BlockEntity BlockEntity, Entity entity, UUID uuid, float relativeYaw, float relativePitch) {
private void processEntity(Pocket pocket, BlockEntity BlockEntity, Entity entity, UUID uuid, float relativeYaw) {
if (entity instanceof ItemEntity) {
Item item = ((ItemEntity) entity).getStack().getItem();
@ -79,11 +79,11 @@ public class PrivatePocketTarget extends VirtualTarget implements EntityTarget {
pocket.addDye(EntityUtils.getOwner(entity), ((DyeItem) item).getColor());
entity.remove();
} else {
((EntityTarget) BlockEntity).receiveEntity(entity, relativeYaw, relativePitch);
((EntityTarget) BlockEntity).receiveEntity(entity, relativeYaw);
}
} else {
((EntityTarget) BlockEntity).receiveEntity(entity, relativeYaw, relativePitch);
RiftRegistry.instance().setLastPrivatePocketExit(uuid, location);
((EntityTarget) BlockEntity).receiveEntity(entity, relativeYaw);
RiftRegistry.instance(entity.world).setLastPrivatePocketExit(uuid, location);
}
}

View file

@ -29,6 +29,6 @@ public class PublicPocketTarget extends RestoringTarget {
}
Pocket pocket = PocketGenerator.generatePublicPocket(newVirtualLocation, new GlobalReference(location), null);
return RiftRegistry.instance().getPocketEntrance(pocket);
return RiftRegistry.instance(location.world).getPocketEntrance(pocket);
}
}

View file

@ -18,7 +18,6 @@ import org.dimdev.dimdoors.rift.registry.RiftRegistry;
import org.dimdev.pocketlib.Pocket;
import org.dimdev.pocketlib.VirtualLocation;
import org.dimdev.util.Location;
import org.dimdev.util.WorldUtils;
import org.dimdev.util.math.MathUtil;
import java.util.HashMap;
@ -70,7 +69,7 @@ public class RandomTarget extends VirtualTarget { // TODO: Split into DungeonTar
Map<Location, Float> riftWeights = new HashMap<>();
if (newRiftWeight > 0) riftWeights.put(null, newRiftWeight);
for (Rift otherRift : RiftRegistry.instance().getRifts()) {
for (Rift otherRift : RiftRegistry.instance(location.world).getRifts()) {
VirtualLocation otherVirtualLocation = VirtualLocation.fromLocation(otherRift.location);
if (otherRift.properties == null) continue;
double otherWeight = otherRift.isDetached ? otherRift.properties.floatingWeight : otherRift.properties.entranceWeight;
@ -168,8 +167,8 @@ public class RandomTarget extends VirtualTarget { // TODO: Split into DungeonTar
Pocket pocket = PocketGenerator.generateDungeonPocket(virtualLocation, new GlobalReference(!noLinkBack ? location : null), newLink); // TODO make the generated dungeon of the same type, but in the overworld
// Link the rift if necessary and teleport the entity
if (!noLink) linkRifts(location, RiftRegistry.instance().getPocketEntrance(pocket));
return (Target) RiftRegistry.instance().getPocketEntrance(pocket).getBlockEntity();
if (!noLink) linkRifts(location, RiftRegistry.instance(location.world).getPocketEntrance(pocket));
return (Target) RiftRegistry.instance(location.world).getPocketEntrance(pocket).getBlockEntity();
}
} else {
// An existing rift was selected

View file

@ -44,12 +44,12 @@ public abstract class RiftReference extends VirtualTarget {
@Override
public void register() {
RiftRegistry.instance().addLink(location, getReferencedLocation());
RiftRegistry.instance(location.world).addLink(location, getReferencedLocation());
}
@Override
public void unregister() {
RiftRegistry.instance().removeLink(location, getReferencedLocation());
RiftRegistry.instance(location.world).removeLink(location, getReferencedLocation());
}
@Override
@ -66,8 +66,8 @@ public abstract class RiftReference extends VirtualTarget {
@Override
public float[] getColor() {
Location target = getReferencedLocation();
if (target != null && RiftRegistry.instance().isRiftAt(target)) {
Set<Location> otherRiftTargets = RiftRegistry.instance().getTargets(target);
if (target != null && RiftRegistry.instance(target.world).isRiftAt(target)) {
Set<Location> otherRiftTargets = RiftRegistry.instance(target.world).getTargets(target);
if (otherRiftTargets.size() == 1 && otherRiftTargets.contains(location)) {
return new float[]{0, 1, 0, 1};
}

View file

@ -12,7 +12,7 @@ public final class Targets {
public static final Class<RedstoneTarget> REDSTONE = RedstoneTarget.class;
public static void registerDefaultTargets() {
DefaultTargets.registerDefaultTarget(ENTITY, (entity, relativeYaw, relativePitch) -> {
DefaultTargets.registerDefaultTarget(ENTITY, (entity, relativeYaw) -> {
entity.sendMessage(new TranslatableText("rifts.unlinked"));
return false;
});

View file

@ -0,0 +1,14 @@
package org.dimdev.dimdoors.world;
import net.fabricmc.fabric.api.dimension.v1.EntityPlacer;
import net.minecraft.block.pattern.BlockPattern;
import net.minecraft.entity.Entity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.Direction;
public class LimboEntityPlacer implements EntityPlacer {
@Override
public BlockPattern.TeleportTarget placeEntity(Entity entity, ServerWorld serverWorld, Direction direction, double v, double v1) {
return null;
}
}

View file

@ -16,4 +16,8 @@ public final class ModBiomes {
Registry.register(Registry.BIOME, id, biome);
return biome;
}
public static void init() {
// just loads the class
}
}

View file

@ -10,10 +10,10 @@ import org.dimdev.dimdoors.world.pocketdimension.PersonalPocketDimension;
import org.dimdev.dimdoors.world.pocketdimension.PublicPocketDimension;
public final class ModDimensions {
public static final DimensionType LIMBO = FabricDimensionType.builder().factory(LimboDimension::new).buildAndRegister(new Identifier("dimdoors:limbo"));
public static final DimensionType PERSONAL = FabricDimensionType.builder().factory(PersonalPocketDimension::new).buildAndRegister(new Identifier("dimdoors:personal_pockets"));
public static final DimensionType PUBLIC = FabricDimensionType.builder().factory(PublicPocketDimension::new).buildAndRegister(new Identifier("dimdoors:public_pockets"));
public static final DimensionType DUNGEON = FabricDimensionType.builder().factory(DungeonPocketDimension::new).buildAndRegister(new Identifier("dimdoors:dungeon_pockets"));
public static final DimensionType LIMBO = FabricDimensionType.builder().factory(LimboDimension::new).defaultPlacer(new LimboEntityPlacer()).buildAndRegister(new Identifier("dimdoors:limbo"));
public static final DimensionType PERSONAL = FabricDimensionType.builder().factory(PersonalPocketDimension::new).defaultPlacer(new PocketDimensionPlacer()).buildAndRegister(new Identifier("dimdoors:personal_pockets"));
public static final DimensionType PUBLIC = FabricDimensionType.builder().factory(PublicPocketDimension::new).defaultPlacer(new PocketDimensionPlacer()).buildAndRegister(new Identifier("dimdoors:public_pockets"));
public static final DimensionType DUNGEON = FabricDimensionType.builder().factory(DungeonPocketDimension::new).defaultPlacer(new PocketDimensionPlacer()).buildAndRegister(new Identifier("dimdoors:dungeon_pockets"));
public static boolean isDimDoorsPocketDimension(World world) {
return world.dimension instanceof PublicPocketDimension

View file

@ -0,0 +1,14 @@
package org.dimdev.dimdoors.world;
import net.fabricmc.fabric.api.dimension.v1.EntityPlacer;
import net.minecraft.block.pattern.BlockPattern;
import net.minecraft.entity.Entity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.Direction;
public class PocketDimensionPlacer implements EntityPlacer {
@Override
public BlockPattern.TeleportTarget placeEntity(Entity entity, ServerWorld serverWorld, Direction direction, double v, double v1) {
return null;
}
}

View file

@ -5,7 +5,7 @@ import net.minecraft.nbt.NbtIo;
import net.minecraft.world.World;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.dimdev.dimdoors.DimDoors;
import org.dimdev.dimdoors.DimensionalDoorsInitializer;
import org.dimdev.dimdoors.pockets.PocketTemplate;
import org.dimdev.util.schem.Schematic;
@ -21,7 +21,7 @@ public abstract class BaseSchematicGateway extends BaseGateway {
String schematicJarDirectory = "/assets/dimdoors/gateways/";
//Initialising the possible locations/formats for the schematic file
InputStream schematicStream = DimDoors.class.getResourceAsStream(schematicJarDirectory + id + ".schem");
InputStream schematicStream = DimensionalDoorsInitializer.class.getResourceAsStream(schematicJarDirectory + id + ".schem");
//determine which location to load the schematic file from (and what format)
DataInputStream schematicDataStream = null;

View file

@ -1,9 +1,44 @@
package org.dimdev.dimdoors.world.limbo;
import com.google.common.collect.ImmutableList;
import net.minecraft.entity.EntityCategory;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.BiomeEffects;
import net.minecraft.world.gen.surfacebuilder.SurfaceBuilder;
import net.minecraft.world.gen.surfacebuilder.TernarySurfaceConfig;
import org.dimdev.dimdoors.block.ModBlocks;
import org.dimdev.dimdoors.entity.ModEntityTypes;
import org.dimdev.dimdoors.sound.ModSoundEvents;
public class LimboBiome extends Biome {
public LimboBiome() {
super(new Settings());
super(new Biome.Settings()
.configureSurfaceBuilder(
SurfaceBuilder.DEFAULT,
new TernarySurfaceConfig(
ModBlocks.BLACK_FABRIC.getDefaultState(),
ModBlocks.BLACK_FABRIC.getDefaultState(),
ModBlocks.BLACK_FABRIC.getDefaultState()
)
)
.precipitation(Biome.Precipitation.NONE).category(Biome.Category.NETHER)
.depth(0.1F)
.scale(0.2F)
.temperature(2.0F)
.downfall(0.0F)
.effects(
new BiomeEffects.Builder()
.waterColor(0x000000)
.waterFogColor(0x000000)
.fogColor(0x000000)
.loopSound(ModSoundEvents.CREEPY)
// TODO: moodSound, additionsSound?
.build()
)
.parent(null)
.noises(ImmutableList.of(new Biome.MixedNoisePoint(0.0F, 0.0F, 0.0F, -0.5F, 1.0F))));
addSpawn(EntityCategory.MONSTER, new Biome.SpawnEntry(ModEntityTypes.MONOLITH, 100, 1, 1));
}
}

View file

@ -1,287 +1,84 @@
package org.dimdev.dimdoors.world.limbo;
import net.minecraft.block.Blocks;
import net.minecraft.entity.EntityCategory;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IWorld;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.source.BiomeSource;
import net.minecraft.world.gen.chunk.SurfaceChunkGenerator;
import net.minecraft.world.gen.feature.Feature;
import java.util.List;
public class LimboChunkGenerator extends SurfaceChunkGenerator<LimboChunkGeneratorConfig> {
public LimboChunkGenerator(IWorld iWorld, BiomeSource biomeSource, int i, int j, int k, LimboChunkGeneratorConfig chunkGeneratorConfig, boolean bl) {
super(iWorld, biomeSource, i, j, k, chunkGeneratorConfig, bl);
}
private final double[] noiseFalloff = buildNoiseFalloff();
@Override
protected double[] computeNoiseRange(int i, int j) {
return new double[0];
}
@Override
protected double computeNoiseFalloff(double d, double e, int i) {
return 0;
public LimboChunkGenerator(IWorld world, BiomeSource biomeSource, LimboChunkGeneratorConfig config) {
super(world, biomeSource, 4, 8, 128, config, false);
}
@Override
protected void sampleNoiseColumn(double[] ds, int i, int j) {
sampleNoiseColumn(ds, i, j, 684.412D, 2053.236D, 8.555150000000001D, 34.2206D, 3, -10);
}
@Override
protected double[] computeNoiseRange(int i, int j) {
return new double[]{0.0D, 0.0D};
}
@Override
protected double computeNoiseFalloff(double d, double e, int i) {
return noiseFalloff[i];
}
private double[] buildNoiseFalloff() {
double[] ds = new double[getNoiseSizeY()];
for (int i = 0; i < getNoiseSizeY(); ++i) {
ds[i] = Math.cos((double) i * 3.141592653589793D * 6.0D / (double) getNoiseSizeY()) * 2.0D;
double d = i;
if (i > getNoiseSizeY() / 2) {
d = getNoiseSizeY() - 1 - i;
}
if (d < 4.0D) {
d = 4.0D - d;
ds[i] -= d * d * d * 10.0D;
}
}
return ds;
}
@Override
public List<Biome.SpawnEntry> getEntitySpawnList(EntityCategory entityCategory, BlockPos blockPos) {
if (entityCategory == EntityCategory.MONSTER) {
if (Feature.NETHER_BRIDGE.isInsideStructure(world, blockPos)) {
return Feature.NETHER_BRIDGE.getMonsterSpawns();
}
if (Feature.NETHER_BRIDGE.isApproximatelyInsideStructure(world, blockPos) && world.getBlockState(blockPos.down()).getBlock() == Blocks.NETHER_BRICKS) {
return Feature.NETHER_BRIDGE.getMonsterSpawns();
}
}
return super.getEntitySpawnList(entityCategory, blockPos);
}
@Override
public int getSpawnHeight() {
return 0;
return world.getSeaLevel() + 1;
}
// private final double[] noiseFalloff = this.buildNoiseFalloff();
//
// @Override
// public int getHeightOnGround(int x, int z, Heightmap.Type type) {
// double xzScale = 884.412D; //large values here create spiky land. add a 0, good -default 884, these are configurable in vanilla
// double yScale = 9840.412D; //large values here make sheets- default - 684
//
// depthRegion = depthNoise.generateNoiseOctaves(depthRegion, xOffset, zOffset, xSize, zSize, 200.0D, 200.0D, 0.5D);
// mainNoiseRegion = mainPerlinNoise.generateNoiseOctaves(mainNoiseRegion, xOffset, yOffset, zOffset, xSize, ySize, zSize, xzScale / 80.0D, yScale / 160.0D, xzScale / 80.0D);
// minLimitRegion = minLimitPerlinNoise.generateNoiseOctaves(minLimitRegion, xOffset, yOffset, zOffset, xSize, ySize, zSize, xzScale, yScale, xzScale);
// maxLimitRegion = maxLimitPerlinNoise.generateNoiseOctaves(maxLimitRegion, xOffset, yOffset, zOffset, xSize, ySize, zSize, xzScale, yScale, xzScale);
//
// int heightMapIndex = 0;
// int depthRegionIndex = 0;
// for (int x = 0; x < xSize; x++) {
// for (int z = 0; z < zSize; z++) {
// // These were were static but calculated by some wrongly-converted biome blend code (which is unnecessary
// // since there is only one biome in limbo)
// float heightVariation = 5.959498f;
// float baseHeight = -1.3523747f;
//
// heightVariation = heightVariation * 0.9F + 0.1F;
// baseHeight = (baseHeight * 4.0F - 1.0F) / 8.0F;
//
// double depthOffset = depthRegion[depthRegionIndex] / 8000.0D; // TODO: is depthOffset a right name?
// // Transform depthOffset based on this function (https://goo.gl/ZDXra8)
// // Values of d outside the interval (-10/3, 1) are clamped to 1/8
// // The range is [-5/14, 1/8], with the minimum being at 0
// if (depthOffset < 0.0D) depthOffset = -depthOffset * 0.3D;
// depthOffset = depthOffset * 3.0D - 2.0D;
// if (depthOffset < 0.0D) {
// depthOffset /= 2.0D;
// if (depthOffset < -1.0D) depthOffset = -1.0D; // Not possible
// depthOffset /= 1.4D;
// depthOffset /= 2.0D;
// } else {
// if (depthOffset > 1.0D) depthOffset = 1.0D;
// depthOffset /= 8.0D;
// }
// depthRegionIndex++;
//
// for (int y = 0; y < ySize; y++) {
// double depth = baseHeight;
// depth += depthOffset * 0.2D;
// depth = depth * ySize / 16.0D;
// depth = ySize / 2.0D + depth * 4.0D; // This was a separate double var28 in vanilla
//
// // TODO: is heightOffset named right?
// double heightOffset = (y - depth) * 12.0D * 128.0D / 128.0D / (double) heightVariation; // Vanilla was * 128D / 256D, configurable
//
// if (heightOffset < 0.0D) {
// heightOffset *= 4.0D;
// }
//
// double minLimit = minLimitRegion[heightMapIndex] / 512.0D;
// double maxLimit = maxLimitRegion[heightMapIndex] / 512.0D;
// double mainNoise = (mainNoiseRegion[heightMapIndex] / 10.0D + 1.0D) / 2.0D;
//
// double height;
// if (mainNoise < 0.0D) {
// height = minLimit;
// } else if (mainNoise > 1.0D) {
// height = maxLimit;
// } else {
// height = minLimit + (maxLimit - minLimit) * mainNoise;
// }
//
// height -= heightOffset;
//
// if (y > ySize - 4) {
// double var40 = (y - (ySize - 4)) / 3.0F; // TODO: what does this do?
// height = height * (1.0D - var40) + -10.0D * var40;
// }
//
// heightMap[heightMapIndex] = height;
// heightMapIndex++;
// }
// }
// }
//
// return heightMap;
// }
@Override
public int getMaxY() {
return 256;
}
//
// private Random rand;
//
// // Noise generators
// private OctavePerlinNoiseSampler minLimitPerlinNoise;
// private OctavePerlinNoiseSampler maxLimitPerlinNoise;
// private OctavePerlinNoiseSampler mainPerlinNoise;
// public OctavePerlinNoiseSampler depthNoise;
// double[] mainNoiseRegion;
// double[] minLimitRegion;
// double[] maxLimitRegion;
//
// private World world;
// private double[] heightMap;
//
// double[] depthRegion;
//
// @Override
// protected double[] computeNoiseRange(int i, int j) {
// return new double[]{0, 0};
// }
//
// @Override
// protected double computeNoiseFalloff(double d, double e, int i) {
// return 0;
// }
//
// @Override
// protected void sampleNoiseColumn(double[] ds, int i, int j) {
//
// }
//
// @Override
// public int getSpawnHeight() {
// return 0;
// }
//
// public LimboChunkGenerator(World world, long seed) {
// this.world = world;
// rand = new Random(seed);
// minLimitPerlinNoise = new NoiseGeneratorOctaves(rand, 16); //base terrain
// maxLimitPerlinNoise = new NoiseGeneratorOctaves(rand, 16); //hillyness
// mainPerlinNoise = new NoiseGeneratorOctaves(rand, 80); //seems to adjust the size of features, how stretched things are -default 8
// depthNoise = new NoiseGeneratorOctaves(rand, 16);
//
// this.world = world;
// }
//
// @Override
// public Chunk generateChunk(int x, int z) {
// rand.setSeed(x * 341873128712L + z * 132897987541L);
// ChunkPrimer primer = new ChunkPrimer();
// setBlocksInChunk(x, z, primer);
// Chunk chunk = new Chunk(world, primer, x, z);
// chunk.generateSkylightMap();
//
// if (!chunk.isTerrainPopulated()) {
// chunk.setTerrainPopulated(true);
// }
//
// return chunk;
// }
//
// @Override
// public void populate(int x, int z) {
// Biome biome = world.getBiome(new BlockPos(x * 16 + 16, 0, z * 16 + 16));
// WorldEntitySpawner.performWorldGenSpawning(world, biome, x * 16 + 8, z * 16 + 8, 16, 16, rand);
// }
//
// @Override
// public boolean generateStructures(Chunk chunk, int x, int z) {
// return false;
// }
//
// private double[] generateHeightmap(double[] heightMap, int xOffset, int yOffset, int zOffset, int xSize, int ySize, int zSize) {
// }
//
// @SuppressWarnings("LocalVariableNamingConvention")
// public void setBlocksInChunk(int x, int z, ChunkPrimer primer) {
// biomesForGeneration = world.getBiomeProvider().getBiomesForGeneration(biomesForGeneration, x * 4 - 2, z * 4 - 2, 10, 10);
// heightMap = generateHeightmap(heightMap, x * 4, 0, z * 4, 5, 17, 5); // vanilla ySize is 33
//
// int xzSectionCount = 4;
// int xzSectionSize = 4;
// int ySectionCount = 16;
// int ySectionSize = 8;
//
// double xzScale = 1.0 / xzSectionSize;
// double yScale = 1.0 / ySectionSize;
// for (int sectionX = 0; sectionX < xzSectionCount; sectionX++) {
// int xSectionPart = sectionX * xzSectionSize;
// int i0__ = sectionX * (xzSectionCount + 1);
// int i1__ = (sectionX + 1) * (xzSectionCount + 1);
//
// for (int sectionZ = 0; sectionZ < xzSectionCount; sectionZ++) {
// int zSectionPart = sectionZ * xzSectionSize;
// int i0_0 = (i0__ + sectionZ) * (ySectionCount + 1);
// int i0_1 = (i0__ + sectionZ + 1) * (ySectionCount + 1);
// int i1_0 = (i1__ + sectionZ) * (ySectionCount + 1);
// int i1_1 = (i1__ + sectionZ + 1) * (ySectionCount + 1);
//
// for (int sectionY = 0; sectionY < ySectionCount; sectionY++) {
// int ySectionPart = sectionY * ySectionSize;
// double v0y0 = heightMap[i0_0 + sectionY];
// double v0y1 = heightMap[i0_1 + sectionY];
// double v1y0 = heightMap[i1_0 + sectionY];
// double v1y1 = heightMap[i1_1 + sectionY];
// double d0y0 = (heightMap[i0_0 + sectionY + 1] - v0y0) * yScale;
// double d0y1 = (heightMap[i0_1 + sectionY + 1] - v0y1) * yScale;
// double d1y0 = (heightMap[i1_0 + sectionY + 1] - v1y0) * yScale;
// double d1y1 = (heightMap[i1_1 + sectionY + 1] - v1y1) * yScale;
//
// for (int yRel = 0; yRel < ySectionSize; ++yRel) {
// int yCoord = ySectionPart + yRel;
// double vxy0 = v0y0;
// double vxy1 = v0y1;
// double dxy0 = (v1y0 - v0y0) * xzScale;
// double dxy1 = (v1y1 - v0y1) * xzScale;
//
// for (int xRel = 0; xRel < xzSectionSize; ++xRel) {
// int xCoord = xSectionPart + xRel;
// double dxyz = (vxy1 - vxy0) * xzScale;
// double vxyz = vxy0 - dxyz;
//
// for (int zRel = 0; zRel < xzSectionSize; ++zRel) {
// int zCoord = zSectionPart + zRel;
// if (vxyz > 0) {
// primer.setBlockState(xCoord, yCoord, zCoord, ModBlocks.UNRAVELLED_FABRIC.getDefaultState());
// } else if (yCoord < 6) {
// primer.setBlockState(xCoord, yCoord, zCoord, ModBlocks.ETERNAL_FABRIC.getDefaultState());
// }
// }
//
// vxy0 += dxy0;
// vxy1 += dxy1;
// }
//
// v0y0 += d0y0;
// v0y1 += d0y1;
// v1y0 += d1y0;
// v1y1 += d1y1;
// }
// }
// }
// }
// }
//
// @Override
// public List<Biome.SpawnListEntry> getPossibleCreatures(EnumCreatureType creatureType, BlockPos pos) {
// Biome biome = world.getBiome(pos);
// return biome.getSpawnableList(creatureType);
// }
//
//
// @Override
// public BlockPos getNearestStructurePos(World world, String structureName, BlockPos position, boolean findUnexplored) {
// return null;
// }
//
// @Override
// public void recreateStructures(Chunk chunk, int x, int z) {
//
// }
//
// @Override
// public boolean isInsideStructure(World world, String structureName, BlockPos pos) {
// return false;
// }
@Override
public int getSeaLevel() {
return 32;
}
}

View file

@ -54,10 +54,10 @@ public final class LimboDecay {
if (blocksImmuneToDecay == null) {
blocksImmuneToDecay = new Block[]{
UNRAVELLED_FABRIC,
ETERNAL_FABRIC,
ETERNAL_FLUID,
DIMENSIONAL_PORTAL,
IRON_DIMENSIONAL_DOOR,
WOOD_DIMENSIONAL_DOOR,
OAK_DIMENSIONAL_DOOR,
DETACHED_RIFT,
GOLD_DOOR,
QUARTZ_DOOR,

View file

@ -1,14 +1,17 @@
package org.dimdev.dimdoors.world.limbo;
import net.minecraft.entity.Entity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import net.minecraft.world.biome.source.BiomeSourceType;
import net.minecraft.world.biome.source.FixedBiomeSource;
import net.minecraft.world.biome.source.FixedBiomeSourceConfig;
import net.minecraft.world.dimension.Dimension;
import net.minecraft.world.dimension.DimensionType;
import net.minecraft.world.gen.chunk.ChunkGenerator;
import org.dimdev.util.Location;
import org.dimdev.dimdoors.world.ModBiomes;
import org.dimdev.dimdoors.world.ModDimensions;
public class LimboDimension extends Dimension {
@ -16,17 +19,16 @@ public class LimboDimension extends Dimension {
super(world, dimensionType, 0);
}
public static Location getLimboSkySpawn(Entity entity) {
return null; // TODO
}
@Override
public ChunkGenerator<?> createChunkGenerator() {
return null;
FixedBiomeSourceConfig biomeConfig = BiomeSourceType.FIXED.getConfig(world.getSeed()).setBiome(ModBiomes.LIMBO);
FixedBiomeSource biomeSource = BiomeSourceType.FIXED.applyConfig(biomeConfig);
LimboChunkGeneratorConfig chunkGeneratorConfig = new LimboChunkGeneratorConfig();
return new LimboChunkGenerator(world, biomeSource, chunkGeneratorConfig);
}
@Override
public BlockPos getSpawningBlockInChunk(ChunkPos chunkPos, boolean bl) {
public BlockPos getSpawningBlockInChunk(ChunkPos chunk, boolean bl) {
return null;
}
@ -37,7 +39,7 @@ public class LimboDimension extends Dimension {
@Override
public float getSkyAngle(long l, float f) {
return 0;
return 0.5f;
}
@Override
@ -57,11 +59,11 @@ public class LimboDimension extends Dimension {
@Override
public boolean isFogThick(int i, int j) {
return false;
return true;
}
@Override
public DimensionType getType() {
return null;
return ModDimensions.LIMBO;
}
}

View file

@ -1,9 +1,37 @@
package org.dimdev.dimdoors.world.pocketdimension;
import com.google.common.collect.ImmutableList;
import net.minecraft.block.Blocks;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.BiomeEffects;
import net.minecraft.world.gen.surfacebuilder.SurfaceBuilder;
import net.minecraft.world.gen.surfacebuilder.TernarySurfaceConfig;
public class BlankBiome extends Biome {
public BlankBiome(boolean white, boolean dangerous) {
super(new Biome.Settings());
super(new Biome.Settings()
.configureSurfaceBuilder(
SurfaceBuilder.DEFAULT,
new TernarySurfaceConfig(
Blocks.AIR.getDefaultState(),
Blocks.AIR.getDefaultState(),
Blocks.AIR.getDefaultState()
)
)
.precipitation(Biome.Precipitation.NONE).category(Biome.Category.NETHER)
.depth(0)
.scale(0)
.temperature(0.8f)
.downfall(0)
.effects(
new BiomeEffects.Builder()
.waterColor(white ? 0xFFFFFF : 0x000000)
.waterFogColor(white ? 0xFFFFFF : 0x000000)
.fogColor(white ? 0xFFFFFF : 0x000000)
.build()
)
.parent(null)
.noises(ImmutableList.of())
);
}
}

View file

@ -1,11 +1,10 @@
package org.dimdev.dimdoors.world.pocketdimension;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.dimension.DimensionType;
import net.minecraft.world.gen.chunk.ChunkGenerator;
import org.dimdev.dimdoors.world.ModBiomes;
import org.dimdev.dimdoors.world.ModDimensions;
import org.dimdev.pocketlib.PocketWorldDimension;
public class DungeonPocketDimension extends PocketWorldDimension {
@ -14,47 +13,12 @@ public class DungeonPocketDimension extends PocketWorldDimension {
}
@Override
public ChunkGenerator<?> createChunkGenerator() {
return null;
}
@Override
public BlockPos getSpawningBlockInChunk(ChunkPos chunkPos, boolean bl) {
return null;
}
@Override
public BlockPos getTopSpawningBlockPosition(int i, int j, boolean bl) {
return null;
}
@Override
public float getSkyAngle(long l, float f) {
return 0;
}
@Override
public boolean hasVisibleSky() {
return false;
}
@Override
public Vec3d modifyFogColor(Vec3d vec3d, float f) {
return null;
}
@Override
public boolean canPlayersSleep() {
return false;
}
@Override
public boolean isFogThick(int i, int j) {
return false;
protected Biome getBiome() {
return ModBiomes.DANGEROUS_BLACK_VOID;
}
@Override
public DimensionType getType() {
return null;
return ModDimensions.DUNGEON;
}
}

View file

@ -1,11 +1,10 @@
package org.dimdev.dimdoors.world.pocketdimension;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.dimension.DimensionType;
import net.minecraft.world.gen.chunk.ChunkGenerator;
import org.dimdev.dimdoors.world.ModBiomes;
import org.dimdev.dimdoors.world.ModDimensions;
import org.dimdev.pocketlib.PocketWorldDimension;
public class PersonalPocketDimension extends PocketWorldDimension {
@ -14,47 +13,12 @@ public class PersonalPocketDimension extends PocketWorldDimension {
}
@Override
public ChunkGenerator<?> createChunkGenerator() {
return null;
}
@Override
public BlockPos getSpawningBlockInChunk(ChunkPos chunkPos, boolean bl) {
return null;
}
@Override
public BlockPos getTopSpawningBlockPosition(int i, int j, boolean bl) {
return null;
}
@Override
public float getSkyAngle(long l, float f) {
return 0;
}
@Override
public boolean hasVisibleSky() {
return false;
}
@Override
public Vec3d modifyFogColor(Vec3d vec3d, float f) {
return null;
}
@Override
public boolean canPlayersSleep() {
return false;
}
@Override
public boolean isFogThick(int i, int j) {
return false;
protected Biome getBiome() {
return ModBiomes.WHITE_VOID;
}
@Override
public DimensionType getType() {
return null;
return ModDimensions.PERSONAL;
}
}

View file

@ -1,11 +1,10 @@
package org.dimdev.dimdoors.world.pocketdimension;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.dimension.DimensionType;
import net.minecraft.world.gen.chunk.ChunkGenerator;
import org.dimdev.dimdoors.world.ModBiomes;
import org.dimdev.dimdoors.world.ModDimensions;
import org.dimdev.pocketlib.PocketWorldDimension;
public class PublicPocketDimension extends PocketWorldDimension {
@ -14,47 +13,12 @@ public class PublicPocketDimension extends PocketWorldDimension {
}
@Override
public ChunkGenerator<?> createChunkGenerator() {
return null;
}
@Override
public BlockPos getSpawningBlockInChunk(ChunkPos chunkPos, boolean bl) {
return null;
}
@Override
public BlockPos getTopSpawningBlockPosition(int i, int j, boolean bl) {
return null;
}
@Override
public float getSkyAngle(long l, float f) {
return 0;
}
@Override
public boolean hasVisibleSky() {
return false;
}
@Override
public Vec3d modifyFogColor(Vec3d vec3d, float f) {
return null;
}
@Override
public boolean canPlayersSleep() {
return false;
}
@Override
public boolean isFogThick(int i, int j) {
return false;
protected Biome getBiome() {
return ModBiomes.BLACK_VOID;
}
@Override
public DimensionType getType() {
return null;
return ModDimensions.PUBLIC;
}
}

View file

@ -1,19 +1,12 @@
package org.dimdev.pocketlib;
import net.minecraft.block.BlockState;
import net.minecraft.entity.Entity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.DyeColor;
import net.minecraft.util.math.BlockBox;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import org.dimdev.annotatednbt.Saved;
import org.dimdev.dimdoors.block.ModBlocks;
import org.dimdev.util.WorldUtils;
import java.util.Arrays;
import java.util.Collections;
public final class Pocket {
private static final int BLOCKS_PAINTED_PER_DYE = 1106;

View file

@ -53,7 +53,7 @@ public class PocketRegistry extends PersistentState {
throw new UnsupportedOperationException("PocketRegistry is only available for pocket dimensions!");
}
PocketRegistry instance = world.getPersistentStateManager().get(PocketRegistry::new, DATA_NAME);
PocketRegistry instance = world.getPersistentStateManager().getOrCreate(PocketRegistry::new, DATA_NAME);
instance.world = world;
for (Pocket pocket : instance.pockets.values()) {

View file

@ -1,11 +1,66 @@
package org.dimdev.pocketlib;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.source.BiomeSourceType;
import net.minecraft.world.biome.source.FixedBiomeSource;
import net.minecraft.world.biome.source.FixedBiomeSourceConfig;
import net.minecraft.world.dimension.Dimension;
import net.minecraft.world.dimension.DimensionType;
import net.minecraft.world.gen.chunk.ChunkGenerator;
import org.dimdev.dimdoors.world.limbo.LimboChunkGeneratorConfig;
public abstract class PocketWorldDimension extends Dimension {
public PocketWorldDimension(World world, DimensionType dimensionType, float f) {
super(world, dimensionType, f);
}
@Override
public ChunkGenerator<?> createChunkGenerator() {
FixedBiomeSourceConfig biomeConfig = BiomeSourceType.FIXED.getConfig(this.world.getSeed()).setBiome(getBiome());
FixedBiomeSource biomeSource = BiomeSourceType.FIXED.applyConfig(biomeConfig);
LimboChunkGeneratorConfig chunkGeneratorConfig = new LimboChunkGeneratorConfig();
return new BlankChunkGenerator(world, biomeSource, new BlankChunkGeneratorConfig());
}
@Override
public BlockPos getSpawningBlockInChunk(ChunkPos chunkPos, boolean bl) {
return null;
}
@Override
public BlockPos getTopSpawningBlockPosition(int i, int j, boolean bl) {
return null;
}
@Override
public float getSkyAngle(long l, float f) {
return 0;
}
@Override
public boolean hasVisibleSky() {
return false;
}
@Override
public Vec3d modifyFogColor(Vec3d vec3d, float f) {
return null;
}
@Override
public boolean canPlayersSleep() {
return false;
}
@Override
public boolean isFogThick(int i, int j) {
return true;
}
protected abstract Biome getBiome();
}

View file

@ -3,14 +3,13 @@ package org.dimdev.pocketlib;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.Identifier;
import net.minecraft.world.PersistentState;
import net.minecraft.world.World;
import net.minecraft.world.dimension.DimensionType;
import org.dimdev.annotatednbt.AnnotatedNbt;
import org.dimdev.annotatednbt.Saved;
import org.dimdev.util.WorldUtils;
import java.util.UUID;
@ -36,8 +35,12 @@ public class PrivatePocketData extends PersistentState {
super(DATA_NAME);
}
public static PrivatePocketData instance() {
return WorldUtils.getWorld(DimensionType.OVERWORLD).getPersistentStateManager().get(PrivatePocketData::new, DATA_NAME);
public static PrivatePocketData instance(World world) {
return instance(world.getServer());
}
private static PrivatePocketData instance(MinecraftServer server) {
return server.getWorld(DimensionType.OVERWORLD).getPersistentStateManager().getOrCreate(PrivatePocketData::new, DATA_NAME);
}
@Override

View file

@ -1,32 +1,34 @@
package org.dimdev.util;
import net.fabricmc.fabric.api.dimension.v1.FabricDimensions;
import net.minecraft.block.pattern.BlockPattern;
import net.minecraft.entity.Entity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.WorldView;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import net.minecraft.world.dimension.DimensionType;
public final class TeleportUtil {
public static void teleport(Entity entity, Location location) {
teleport(entity, location, entity.yaw, entity.pitch);
public static void teleport(Entity entity, World world, BlockPos pos, int yawOffset) {
teleport(entity, world, Vec3d.method_24955(pos), yawOffset);
}
public static void teleport(Entity entity, Location location, float yaw, float pitch) {
teleport(entity, location.world, location.pos.getX() + .5, location.pos.getY(), location.pos.getZ() + .5, yaw, pitch);
public static void teleport(Entity entity, World world, Vec3d pos, float yawOffset) {
teleport(entity, world.dimension.getType(), pos, yawOffset);
}
public static void teleport(Entity entity, BlockPos pos, float yaw, float pitch) {
teleport(entity, entity.getEntityWorld(), pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, yaw, pitch);
}
public static void teleport(Entity entity, DimensionType dimension, Vec3d pos, float yawOffset) {
if (entity.dimension == dimension) {
entity.setPos(pos.x, pos.y, pos.z);
entity.setYaw(entity.yaw + yawOffset);
} else {
FabricDimensions.teleport(
entity,
dimension,
(e, serverWorld, direction, v, v1) -> new BlockPattern.TeleportTarget(pos, e.getVelocity(), (int) (e.yaw + yawOffset))
);
public static void teleport(Entity entity, double x, double y, double z, float yaw, float pitch) {
teleport(entity, entity.getEntityWorld(), x, y, z, yaw, pitch);
}
public static void teleport(Entity entity, WorldView world, double x, double y, double z, float yaw, float pitch) {
FabricDimensions.teleport(entity, world.getDimension().getType());
entity.setPos(x, y, z);
entity.yaw = yaw;
entity.pitch = pitch;
entity.setOnFireFor(0); // Workaround for https://bugs.mojang.com/browse/MC-100097
entity.setOnFireFor(0); // Workaround for https://bugs.mojang.com/browse/MC-100097
}
}
}

View file

@ -1,10 +0,0 @@
package org.dimdev.util;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.world.dimension.DimensionType;
public final class WorldUtils {
public static ServerWorld getWorld(DimensionType personal) {
return null;
}
}

View file

@ -5,7 +5,7 @@
"mixins": [
],
"client": [
"ExampleMixin"
],
"injectors": {
"defaultRequire": 1

View file

@ -22,7 +22,7 @@
"environment": "*",
"entrypoints": {
"main": [
"org.dimdev.dimdoors.DimDoors"
"org.dimdev.dimdoors.DimensionalDoorsInitializer"
]
},
"mixins": [