Updated to 1.16.1 fabric. Still got alot of work ahead of us on this tou.

This commit is contained in:
Waterpicker 2020-07-05 06:30:31 -05:00
parent 5846493b55
commit da04b38fea
66 changed files with 2161 additions and 2769 deletions

1
.gitignore vendored
View file

@ -26,3 +26,4 @@ build
run
.DS_Store
Thumbs.db
remappedSrc

View file

@ -5,12 +5,15 @@ buildscript {
}
dependencies {
classpath 'net.fabricmc:fabric-loom:0.2.7-SNAPSHOT'
classpath 'net.fabricmc:fabric-loom:0.4-SNAPSHOT'
}
}
plugins {
id 'fabric-loom' version '0.4-SNAPSHOT'
}
apply plugin: "java"
apply plugin: "fabric-loom"
sourceCompatibility = 1.8
targetCompatibility = 1.8
@ -22,12 +25,12 @@ repositories {
dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_version}"
modCompile "net.fabricmc:fabric-loader:${project.loader_version}"
modCompile "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
modCompile 'com.flowpowered:flow-math:1.0.3'
modCompile 'org.jgrapht:jgrapht-core:1.1.0'
modCompile 'com.github.DimensionalDevelopment:poly2tri.java:master-SNAPSHOT'
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
modApi "net.fabricmc.fabric-api:fabric-api:0.14.1+build.372-1.16"
modImplementation 'com.flowpowered:flow-math:1.0.3'
modImplementation 'org.jgrapht:jgrapht-core:1.1.0'
modImplementation 'com.github.DimensionalDevelopment:poly2tri.java:0.1.1'
}
version "4.0"

View file

@ -1,4 +1,5 @@
minecraft_version=20w11a
yarn_version=20w11a+build.6
loader_version=0.7.8+build.187
fabric_version=0.5.3+build.308-1.16
minecraft_version=1.16.1
yarn_mappings=1.16.1+build.19
loader_version=0.8.9+build.203
fabric_version=0.14.1+build.372-1.16

10
settings.gradle Normal file
View file

@ -0,0 +1,10 @@
pluginManagement {
repositories {
jcenter()
maven {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
}
gradlePluginPortal()
}
}

View file

@ -1,8 +1,8 @@
package org.dimdev.annotatednbt;
import com.google.gson.Gson;
import com.mojang.datafixers.Dynamic;
import com.mojang.datafixers.types.JsonOps;
import com.mojang.serialization.Dynamic;
import com.mojang.serialization.JsonOps;
import net.minecraft.datafixer.NbtOps;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.Tag;

View file

@ -5,15 +5,16 @@ import net.fabricmc.api.Environment;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.MaterialColor;
import net.minecraft.block.ShapeContext;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.client.MinecraftClient;
import net.minecraft.entity.EntityContext;
import net.minecraft.client.world.ClientWorld;
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;
import net.minecraft.world.WorldAccess;
import org.dimdev.dimdoors.block.entity.DetachedRiftBlockEntity;
import org.dimdev.dimdoors.client.RiftParticle;
import org.dimdev.dimdoors.world.ModDimensions;
@ -33,19 +34,18 @@ public class DetachedRiftBlock extends Block implements RiftProvider<DetachedRif
}
@Override
@SuppressWarnings("deprecation")
public MaterialColor getMapColor(BlockState state, BlockView world, BlockPos pos) {
public MaterialColor getDefaultMaterialColor() {
return MaterialColor.BLACK;
}
@Override
public void onBroken(IWorld world, BlockPos pos, BlockState state) {
public void onBroken(WorldAccess world, BlockPos pos, BlockState state) {
((DetachedRiftBlockEntity) world.getBlockEntity(pos)).unregister();
super.onBroken(world, pos, state);
}
@Override
public VoxelShape getOutlineShape(BlockState blockState, BlockView blockView, BlockPos blockPos, EntityContext entityContext) {
public VoxelShape getOutlineShape(BlockState blockState, BlockView blockView, BlockPos blockPos, ShapeContext entityContext) {
return VoxelShapes.empty();
}
@ -68,7 +68,7 @@ public class DetachedRiftBlock extends Block implements RiftProvider<DetachedRif
if (rift.closing) {
MinecraftClient.getInstance().particleManager.addParticle(
new RiftParticle(
world,
(ClientWorld) world,
pos.getX() + .5, pos.getY() + 1.5, pos.getZ() + .5,
rand.nextGaussian() * speed, rand.nextGaussian() * speed, rand.nextGaussian() * speed,
outsidePocket ? 0.8f : 0.4f, 0.55f, 2000, 2000
@ -77,7 +77,7 @@ public class DetachedRiftBlock extends Block implements RiftProvider<DetachedRif
}
MinecraftClient.getInstance().particleManager.addParticle(new RiftParticle(
world,
(ClientWorld) world,
pos.getX() + .5, pos.getY() + 1.5, pos.getZ() + .5,
rand.nextGaussian() * speed, rand.nextGaussian() * speed, rand.nextGaussian() * speed,
outsidePocket ? 0.0f : 0.7f, 0.55f, rift.stabilized ? 750 : 2000, rift.stabilized ? 750 : 2000)

View file

@ -41,7 +41,7 @@ public class DimensionalDoorBlock extends DoorBlock implements RiftProvider<Entr
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hitResult) {
state = state.cycle(OPEN);
world.setBlockState(pos, state, 10);
world.playLevelEvent(player, state.get(OPEN) ? material == Material.METAL ? 1005 : 1006 : material == Material.METAL ? 1011 : 1012, pos, 0);
world.syncWorldEvent(player, state.get(OPEN) ? material == Material.METAL ? 1005 : 1006 : material == Material.METAL ? 1011 : 1012, pos, 0);
return ActionResult.SUCCESS;
}

View file

@ -4,8 +4,8 @@ import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos;
import org.dimdev.dimdoors.world.ModDimensions;
import org.dimdev.dimdoors.world.limbo.LimboDecay;
import org.dimdev.dimdoors.world.limbo.LimboDimension;
import java.util.Random;
@ -19,7 +19,7 @@ public class UnravelledFabricBlock extends Block {
@Override
@SuppressWarnings("deprecation")
public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {
if (world.dimension instanceof LimboDimension) {
if (ModDimensions.isLimboDimension(world)) {
LimboDecay.applySpreadDecay(world, pos);
}
}

View file

@ -2,9 +2,10 @@ package org.dimdev.dimdoors.block.entity;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.block.BlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.SpawnType;
import net.minecraft.entity.SpawnReason;
import net.minecraft.entity.mob.EndermanEntity;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.util.Tickable;
@ -42,7 +43,7 @@ public class DetachedRiftBlockEntity extends RiftBlockEntity implements Tickable
}
if (!world.isClient && random.nextDouble() < ModConfig.GENERAL.endermanSpawnChance) {
EndermanEntity enderman = EntityType.ENDERMAN.spawn(world, null, null, null, pos, SpawnType.STRUCTURE, false, false);
EndermanEntity enderman = EntityType.ENDERMAN.spawn(world, null, null, null, pos, SpawnReason.STRUCTURE, false, false);
if (random.nextDouble() < ModConfig.GENERAL.endermanAggressiveChance) {
enderman.setTarget(world.getClosestPlayer(enderman, 50));
@ -71,8 +72,8 @@ public class DetachedRiftBlockEntity extends RiftBlockEntity implements Tickable
}
@Override
public void fromTag(CompoundTag tag) {
super.fromTag(tag);
public void fromTag(BlockState state, CompoundTag tag) {
super.fromTag(state, tag);
AnnotatedNbt.load(this, tag);
}

View file

@ -2,10 +2,12 @@ package org.dimdev.dimdoors.block.entity;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.block.BlockState;
import net.minecraft.entity.Entity;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import org.dimdev.annotatednbt.AnnotatedNbt;
import org.dimdev.dimdoors.ModConfig;
import org.dimdev.util.TeleportUtil;
@ -18,8 +20,8 @@ public class EntranceRiftBlockEntity extends RiftBlockEntity {
}
@Override
public void fromTag(CompoundTag nbt) {
super.fromTag(nbt);
public void fromTag(BlockState state, CompoundTag nbt) {
super.fromTag(state, nbt);
AnnotatedNbt.load(this, nbt);
}
@ -43,7 +45,7 @@ public class EntranceRiftBlockEntity extends RiftBlockEntity {
@Override
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));
Vec3d targetPos = Vec3d.ofCenter(pos).add(Vec3d.of(getOrientation().getVector()).multiply(ModConfig.GENERAL.teleportOffset + 0.5));
TeleportUtil.teleport(entity, world, targetPos, yawOffset);
return true;
@ -69,7 +71,7 @@ public class EntranceRiftBlockEntity extends RiftBlockEntity {
protected float[] getEntranceRenderColor(Random rand) {
float red, green, blue;
if (world.dimension.isNether()) {
if (world.getRegistryKey() == World.NETHER) {
red = rand.nextFloat() * 0.5F + 0.4F;
green = rand.nextFloat() * 0.05F;
blue = rand.nextFloat() * 0.05F;

View file

@ -1,12 +1,13 @@
package org.dimdev.dimdoors.block.entity;
import net.fabricmc.fabric.api.block.entity.BlockEntityClientSerializable;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.entity.Entity;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.text.TranslatableText;
import net.minecraft.text.LiteralText;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.dimdev.annotatednbt.AnnotatedNbt;
@ -18,6 +19,7 @@ import org.dimdev.dimdoors.rift.registry.Rift;
import org.dimdev.dimdoors.rift.registry.RiftRegistry;
import org.dimdev.dimdoors.rift.targets.*;
import org.dimdev.pocketlib.VirtualLocation;
import org.dimdev.util.EntityUtils;
import org.dimdev.util.Location;
import java.util.Arrays;
@ -37,17 +39,19 @@ public abstract class RiftBlockEntity extends BlockEntity implements BlockEntity
alwaysDelete = false;
}
// NBT
@Override
public void fromTag(CompoundTag nbt) {
super.fromTag(nbt);
public void fromTag(BlockState state, CompoundTag nbt) {
super.fromTag(state, nbt);
AnnotatedNbt.load(this, nbt);
destination = nbt.contains("destination") ? VirtualTarget.readVirtualTargetNBT(nbt.getCompound("destination")) : null;
}
@Override
public void fromClientTag(CompoundTag tag) {
fromTag(tag);
fromTag(world.getBlockState(pos), tag);
}
@Override
@ -154,12 +158,12 @@ public abstract class RiftBlockEntity extends BlockEntity implements BlockEntity
EntityTarget target = getTarget().as(Targets.ENTITY);
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));
VirtualLocation vloc = VirtualLocation.fromLocation(new Location((ServerWorld) entity.world, entity.getBlockPos()));
EntityUtils.chat(entity, new LiteralText("You are at x = " + vloc.x + ", y = ?, z = " + vloc.z + ", w = " + vloc.depth));
return true;
}
} catch (Exception e) {
entity.sendMessage(new TranslatableText("Something went wrong while trying to teleport you, please report this bug."));
EntityUtils.chat(entity, new LiteralText("Something went wrong while trying to teleport you, please report this bug."));
LOGGER.error("Teleporting failed with the following exception: ", e);
}

View file

@ -1,123 +0,0 @@
//package org.dimdev.dimdoors.client;
//
//import com.mojang.blaze3d.systems.RenderSystem;
//import net.fabricmc.api.EnvType;
//import net.fabricmc.api.Environment;
//import net.minecraft.client.Minecraft;
//import net.minecraft.client.render.entity.LivingEntityRenderer;
//import net.minecraft.client.renderer.RenderSystem;
//import net.minecraft.client.renderer.OpenGlHelper;
//import net.minecraft.client.renderer.entity.RenderLiving;
//import net.minecraft.client.renderer.entity.RenderManager;
//import net.minecraft.util.Identifier;
//import net.minecraftforge.client.event.RenderLivingEvent;
//import net.minecraftforge.common.MinecraftForge;
//import org.dimdev.dimdoors.DimDoors;
//import org.dimdev.dimdoors.entity.MonolithEntity;
//import org.lwjgl.opengl.GL11;
//
//import java.util.Arrays;
//import java.util.List;
//
//@Environment(EnvType.CLIENT)
//public class MonolithRenderer extends LivingEntityRenderer<MonolithEntity, MonolithModel> {
// protected static final List<Identifier> MONOLITH_TEXTURES = Arrays.asList(
// new Identifier("dimdoors:textures/mobs/monolith/monolith0.png"),
// new Identifier("dimdoors:textures/mobs/monolith/monolith1.png"),
// new Identifier("dimdoors:textures/mobs/monolith/monolith2.png"),
// new Identifier("dimdoors:textures/mobs/monolith/monolith3.png"),
// new Identifier("dimdoors:textures/mobs/monolith/monolith4.png"),
// new Identifier("dimdoors:textures/mobs/monolith/monolith5.png"),
// new Identifier("dimdoors:textures/mobs/monolith/monolith6.png"),
// new Identifier("dimdoors:textures/mobs/monolith/monolith7.png"),
// new Identifier("dimdoors:textures/mobs/monolith/monolith8.png"),
// new Identifier("dimdoors:textures/mobs/monolith/monolith9.png"),
// new Identifier("dimdoors:textures/mobs/monolith/monolith10.png"),
// new Identifier("dimdoors:textures/mobs/monolith/monolith11.png"),
// new Identifier("dimdoors:textures/mobs/monolith/monolith12.png"),
// new Identifier("dimdoors:textures/mobs/monolith/monolith13.png"),
// new Identifier("dimdoors:textures/mobs/monolith/monolith14.png"),
// new Identifier("dimdoors:textures/mobs/monolith/monolith15.png"),
// new Identifier("dimdoors:textures/mobs/monolith/monolith16.png"),
// new Identifier("dimdoors:textures/mobs/monolith/monolith17.png"),
// new Identifier("dimdoors:textures/mobs/monolith/monolith18.png"));
//
// public MonolithRenderer(RenderManager manager, float f) {
// super(manager, new MonolithModel(), f);
// }
//
// @Override
// public void doRender(MonolithEntity monolith, double x, double y, double z, float entityYaw, float partialTicks) {
// final float minScaling = 0;
// final float maxScaling = 0.1f;
//
// float jitterScale = 0;
// if (monolith.isDangerous()) {
// // Use linear interpolation to scale how much jitter we want for our given aggro level
// jitterScale = minScaling + (0.1f) * monolith.getAggroProgress();
// }
//
// // Calculate jitter - include entity ID to give Monoliths individual jitters
// float time = ((Minecraft.getSystemTime() + 0xF1234568 * monolith.getEntityId()) % 200000) / 50.0F;
//
// // We use random constants here on purpose just to get different wave forms
// double xJitter = jitterScale * Math.sin(1.1f * time) * Math.sin(0.8f * time);
// double yJitter = jitterScale * Math.sin(1.2f * time) * Math.sin(0.9f * time);
// double zJitter = jitterScale * Math.sin(1.3f * time) * Math.sin(0.7f * time);
//
// // Render with jitter
// render(monolith, x + xJitter, y + yJitter, z + zJitter, entityYaw, partialTicks);
// }
//
// public void render(MonolithEntity monolith, double x, double y, double z, float entityYaw, float partialTicks) {
// if (MinecraftForge.EVENT_BUS.post(new RenderLivingEvent.Pre<>(monolith, this, 1, x, y, z))) return;
// RenderSystem.pushMatrix();
// RenderSystem.disableCull();
// RenderSystem.disableLighting();
// RenderSystem.enableBlend();
// RenderSystem.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
// mainModel.swingProgress = getSwingProgress(monolith, partialTicks);
//
// try {
// float interpolatedYaw = interpolateRotation(monolith.prevRenderYawOffset, monolith.renderYawOffset, partialTicks);
// float rotation;
// float pitch = monolith.prevRotationPitch + (monolith.rotationPitch - monolith.prevRotationPitch) * partialTicks;
// renderLivingAt(monolith, x, y, z);
//
// rotation = handleRotationFloat(monolith, partialTicks);
// applyRotations(monolith, rotation, interpolatedYaw, partialTicks);
//
// float scaleFactor = 0.0625F;
// RenderSystem.enableRescaleNormal();
//
// RenderSystem.scale(-1.0f, -1.0f, 1.0F);
// preRenderCallback(monolith, partialTicks);
// RenderSystem.rotate(monolith.pitchLevel, 1.0F, 0.0F, 0.0F);
// RenderSystem.translate(0.0F, 24.0F * scaleFactor - 0.0078125F, 0.0F);
//
// renderModel(monolith, 0, 0, rotation, interpolatedYaw, pitch, scaleFactor);
//
// OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit);
// RenderSystem.disableTexture2D();
// OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit);
//
// RenderSystem.disableRescaleNormal();
// } catch (Exception e) {
// LOGGER.error("Couldn't render entity", e);
// }
//
// OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit);
// RenderSystem.enableTexture2D();
// OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit);
// RenderSystem.enableCull();
// RenderSystem.enableLighting();
// RenderSystem.disableBlend();
// RenderSystem.popMatrix();
// MinecraftForge.EVENT_BUS.post(new RenderLivingEvent.Post<>(monolith, this, 1, x, y, z));
// }
//
// @Override
// protected Identifier getEntityTexture(MonolithEntity monolith) {
// return MONOLITH_TEXTURES.get(monolith.getTextureState());
// }
//}

View file

@ -3,12 +3,12 @@ package org.dimdev.dimdoors.client;
import net.minecraft.client.particle.AnimatedParticle;
import net.minecraft.client.particle.SpriteProvider;
import net.minecraft.client.texture.Sprite;
import net.minecraft.world.World;
import net.minecraft.client.world.ClientWorld;
import java.util.Random;
public class RiftParticle extends AnimatedParticle {
public RiftParticle(World world, double x, double y, double z, double velocityX, double velocityY, double velocityZ, float color, float scale, int averageAge, int ageSpread) {
public RiftParticle(ClientWorld world, double x, double y, double z, double velocityX, double velocityY, double velocityZ, float color, float scale, int averageAge, int ageSpread) {
super(world, x, y, z, new SpriteProvider() { // TODO: 160, 8
@Override
public Sprite getSprite(int i, int j) {

View file

@ -1,25 +1,15 @@
package org.dimdev.dimdoors.commands;
import com.google.gson.Gson;
import com.mojang.brigadier.Command;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.FloatArgumentType;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.builder.RequiredArgumentBuilder;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.mojang.datafixers.types.JsonOps;
import net.minecraft.command.arguments.*;
import net.minecraft.command.suggestion.SuggestionProviders;
import net.minecraft.datafixer.NbtOps;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.command.arguments.DimensionArgumentType;
import net.minecraft.command.arguments.Vec3ArgumentType;
import net.minecraft.server.command.CommandManager;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.sound.SoundCategory;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.dimension.DimensionType;
import org.dimdev.util.TeleportUtil;
public class DimTeleportCommand {
@ -44,9 +34,9 @@ public class DimTeleportCommand {
);
}
private static int teleport(ServerPlayerEntity player, DimensionType dimension, Vec3d coordinates, float yaw) {
private static int teleport(ServerPlayerEntity player, ServerWorld world, Vec3d coordinates, float yaw) {
try {
TeleportUtil.teleport(player, dimension, coordinates, yaw);
TeleportUtil.teleport(player, world, coordinates, yaw);
} catch (Exception e) {
e.printStackTrace();
}

View file

@ -2,9 +2,9 @@ package org.dimdev.dimdoors.entity;
import net.fabricmc.fabric.api.client.rendereregistry.v1.EntityRendererRegistry;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityCategory;
import net.minecraft.entity.EntityDimensions;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.SpawnGroup;
import net.minecraft.util.registry.Registry;
public class ModEntityTypes {
@ -26,6 +26,6 @@ public class ModEntityTypes {
}
private static <E extends Entity> EntityType<E> register(String id, EntityType.EntityFactory<E> factory, int a, int b) {
return Registry.register(Registry.ENTITY_TYPE, id, EntityType.Builder.create(factory, EntityCategory.MONSTER).setDimensions(a, b).makeFireImmune().spawnableFarFromPlayer().build(id));
return Registry.register(Registry.ENTITY_TYPE, id, EntityType.Builder.create(factory, SpawnGroup.MONSTER).setDimensions(a, b).makeFireImmune().spawnableFarFromPlayer().build(id));
}
}

View file

@ -18,10 +18,7 @@ import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import org.dimdev.dimdoors.entity.ai.MonolithTask;
import org.dimdev.dimdoors.sound.ModSoundEvents;
import org.dimdev.dimdoors.world.limbo.LimboDimension;
import org.dimdev.dimdoors.world.pocketdimension.DungeonPocketDimension;
import static net.minecraft.entity.attribute.EntityAttributes.MAX_HEALTH;
import org.dimdev.dimdoors.world.ModDimensions;
public class MonolithEntity extends MobEntity {
public final EntityDimensions DIMENSIONS = EntityDimensions.fixed(3f, 3f);
@ -107,12 +104,6 @@ public class MonolithEntity extends MobEntity {
return true;
}
@Override
protected void initAttributes() {
super.initAttributes();
getAttributes().get(MAX_HEALTH).setBaseValue(57005);
}
@Override
public boolean isPushable() {
return false;
@ -142,7 +133,7 @@ public class MonolithEntity extends MobEntity {
@Override
protected void mobTick() {
// Remove this Monolith if it's not in Limbo or in a pocket dungeon
if (!(world.dimension instanceof LimboDimension || world.dimension instanceof DungeonPocketDimension)) {
if (!(ModDimensions.isLimboDimension(world) || ModDimensions.isDimDoorsPocketDimension(world))) {
remove();
super.mobTick();
return;
@ -163,7 +154,7 @@ public class MonolithEntity extends MobEntity {
// Server side...
// Rapidly increase the aggro level if this Monolith can see the player
if (visibility) {
if (world.dimension instanceof LimboDimension) {
if (ModDimensions.isLimboDimension(world)) {
if (isDangerous()) {
aggro++;
} else {

View file

@ -4,23 +4,24 @@ 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.fluid.FlowableFluid;
import net.minecraft.fluid.Fluid;
import net.minecraft.fluid.FluidState;
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.WorldAccess;
import net.minecraft.world.WorldView;
import org.dimdev.dimdoors.block.ModBlocks;
import org.dimdev.dimdoors.item.ModItems;
import java.util.Random;
public abstract class EternalFluid extends BaseFluid {
public abstract class EternalFluid extends FlowableFluid {
@Override
public Fluid getFlowing() {
return ModFluids.FLOWING_ETERNAL_FLUID;
@ -48,13 +49,13 @@ public abstract class EternalFluid extends BaseFluid {
}
@Override
protected void beforeBreakingBlock(IWorld iWorld, BlockPos blockPos, BlockState blockState) {
protected void beforeBreakingBlock(WorldAccess iWorld, BlockPos blockPos, BlockState blockState) {
}
@Override
public int method_15733(WorldView worldView) {
return worldView.getDimension().doesWaterVaporize() ? 4 : 2;
public int getFlowSpeed(WorldView worldView) {
return worldView.getDimension().isUltrawarm() ? 4 : 2;
}
@Override
@ -69,7 +70,7 @@ public abstract class EternalFluid extends BaseFluid {
@Override
public int getLevelDecreasePerBlock(WorldView worldView) {
return worldView.getDimension().doesWaterVaporize() ? 1 : 2;
return worldView.getDimension().isUltrawarm() ? 1 : 2;
}
@Override
@ -79,7 +80,7 @@ public abstract class EternalFluid extends BaseFluid {
@Override
public int getTickRate(WorldView worldView) {
return worldView.getDimension().isNether() ? 10 : 30;
return worldView.getDimension().isUltrawarm() ? 10 : 30;
}
@Override
@ -99,9 +100,9 @@ public abstract class EternalFluid extends BaseFluid {
}
@Override
protected void flow(IWorld world, BlockPos pos, BlockState blockState, Direction direction, FluidState fluidState) {
protected void flow(WorldAccess world, BlockPos pos, BlockState blockState, Direction direction, FluidState fluidState) {
if (direction == Direction.DOWN) {
if (world.getFluidState(pos).matches(FluidTags.WATER)) {
if (world.getFluidState(pos).isIn(FluidTags.WATER)) {
if (blockState.getBlock() instanceof FluidBlock) {
world.setBlockState(pos, ModBlocks.BLACK_ANCIENT_FABRIC.getDefaultState(), 3);
}

View file

@ -1,12 +1,12 @@
package org.dimdev.dimdoors.fluid;
import net.minecraft.fluid.BaseFluid;
import net.minecraft.fluid.FlowableFluid;
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 EternalFluid.Still());
public static final BaseFluid FLOWING_ETERNAL_FLUID = register("dimdoors:flowing_eternal_fluid", new EternalFluid.Flowing());
public static final FlowableFluid ETERNAL_FLUID = register("dimdoors:eternal_fluid", new EternalFluid.Still());
public static final FlowableFluid 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

@ -43,7 +43,7 @@ public class DimensionalDoorItem extends TallBlockItem {
if (context.getWorld().isClient) {
Object[] translationArgs = new Object[0];
context.getPlayer().sendMessage(new TranslatableText("rifts.entrances.rift_too_close", translationArgs));
context.getPlayer().sendMessage(new TranslatableText("rifts.entrances.rift_too_close", translationArgs), true);
DetachedRiftBlockEntityRenderer.showRiftCoreUntil = System.currentTimeMillis() + ModConfig.GRAPHICS.highlightRiftCoreFor;
}

View file

@ -11,7 +11,7 @@ import org.dimdev.dimdoors.fluid.ModFluids;
import org.dimdev.dimdoors.rift.registry.LinkProperties;
import org.dimdev.dimdoors.rift.targets.*;
import org.dimdev.dimdoors.sound.ModSoundEvents;
import org.dimdev.dimdoors.world.pocketdimension.PersonalPocketDimension;
import org.dimdev.dimdoors.world.ModDimensions;
import java.util.Arrays;
import java.util.Collections;
@ -56,7 +56,7 @@ public final class ModItems {
ModBlocks.QUARTZ_DIMENSIONAL_DOOR,
new Item.Settings().group(DIMENSIONAL_DOORS).maxCount(1),
rift -> {
if (rift.getWorld().dimension instanceof PersonalPocketDimension) {
if (ModDimensions.isDimDoorsPocketDimension(rift.getWorld())) {
rift.setDestination(new PrivatePocketExitTarget()); // exit
} else {
rift.setDestination(new PrivatePocketTarget()); // entrances

View file

@ -4,7 +4,6 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.SwordItem;
import net.minecraft.item.ToolMaterials;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
@ -16,8 +15,6 @@ import net.minecraft.world.World;
import org.dimdev.dimdoors.ModConfig;
import org.dimdev.dimdoors.block.entity.RiftBlockEntity;
import org.dimdev.dimdoors.client.DetachedRiftBlockEntityRenderer;
import org.dimdev.util.Location;
import org.dimdev.util.TeleportUtil;
public class RiftBladeItem extends SwordItem {
public static final String ID = "rift_blade";
@ -27,7 +24,7 @@ public class RiftBladeItem extends SwordItem {
}
@Override
public boolean hasEnchantmentGlint(ItemStack itemStack) {
public boolean hasGlint(ItemStack itemStack) {
return true;
}
@ -48,7 +45,7 @@ public class RiftBladeItem extends SwordItem {
if (RayTraceHelper.hitsLivingEntity(hit) || RayTraceHelper.hitsRift(hit, world)) {
return new TypedActionResult<>(ActionResult.SUCCESS, stack);
} else {
player.sendMessage(new TranslatableText(getTranslationKey() + ".rift_miss"));
player.sendMessage(new TranslatableText(getTranslationKey() + ".rift_miss"), true);
DetachedRiftBlockEntityRenderer.showRiftCoreUntil = System.currentTimeMillis() + ModConfig.GRAPHICS.highlightRiftCoreFor;
return new TypedActionResult<>(ActionResult.FAIL, stack);
}

View file

@ -37,7 +37,7 @@ public class RiftConfigurationToolItem extends Item {
if (world.isClient) {
if (!RayTraceHelper.hitsRift(hit, world)) {
player.sendMessage(new TranslatableText("tools.rift_miss"));
player.sendMessage(new TranslatableText("tools.rift_miss"), true);
DetachedRiftBlockEntityRenderer.showRiftCoreUntil = System.currentTimeMillis() + ModConfig.GRAPHICS.highlightRiftCoreFor;
}
return new TypedActionResult<>(ActionResult.FAIL, stack);

View file

@ -43,7 +43,7 @@ public class RiftRemoverItem extends Item {
if (world.isClient) {
if (!RayTraceHelper.hitsDetachedRift(hit, world)) {
player.sendMessage(new TranslatableText("tools.rift_miss"));
player.sendMessage(new TranslatableText("tools.rift_miss"), true);
DetachedRiftBlockEntityRenderer.showRiftCoreUntil = System.currentTimeMillis() + ModConfig.GRAPHICS.highlightRiftCoreFor;
}
return new TypedActionResult<>(ActionResult.FAIL, stack);
@ -53,12 +53,12 @@ public class RiftRemoverItem extends Item {
DetachedRiftBlockEntity rift = (DetachedRiftBlockEntity) world.getBlockEntity(new BlockPos(hit.getPos()));
if (!rift.closing) {
rift.setClosing(true);
world.playSound(null, player.getSenseCenterPos(), ModSoundEvents.RIFT_CLOSE, SoundCategory.BLOCKS, 0.6f, 1);
world.playSound(null, player.getBlockPos(), ModSoundEvents.RIFT_CLOSE, SoundCategory.BLOCKS, 0.6f, 1);
stack.damage(10, player, a -> {});
player.sendMessage(new TranslatableText(getTranslationKey() + ".closing"));
player.sendMessage(new TranslatableText(getTranslationKey() + ".closing"), true);
return new TypedActionResult<>(ActionResult.SUCCESS, stack);
} else {
player.sendMessage(new TranslatableText(getTranslationKey() + ".already_closing"));
player.sendMessage(new TranslatableText(getTranslationKey() + ".already_closing"), true);
}
}
return new TypedActionResult<>(ActionResult.FAIL, stack);

View file

@ -35,7 +35,7 @@ public class RiftSignatureItem extends Item {
}
@Override
public boolean hasEnchantmentGlint(ItemStack stack) {
public boolean hasGlint(ItemStack stack) {
return stack.getTag() != null && stack.getTag().contains("destination");
}
@ -66,13 +66,13 @@ public class RiftSignatureItem extends Item {
if (target == null) {
// The link signature has not been used. Store its current target as the first location.
setSource(stack, new RotatedLocation((ServerWorld) world, pos, player.yaw, 0));
player.sendMessage(new TranslatableText(getTranslationKey() + ".stored"));
world.playSound(null, player.getSenseCenterPos(), ModSoundEvents.RIFT_START, SoundCategory.BLOCKS, 0.6f, 1);
player.sendMessage(new TranslatableText(getTranslationKey() + ".stored"), true);
world.playSound(null, player.getBlockPos(), ModSoundEvents.RIFT_START, SoundCategory.BLOCKS, 0.6f, 1);
} else {
// Place a rift at the saved point
if (target.getBlockState().getBlock() != ModBlocks.DETACHED_RIFT) {
if (!target.getBlockState().getBlock().canMobSpawnInside()) {
player.sendMessage(new TranslatableText("tools.target_became_block"));
player.sendMessage(new TranslatableText("tools.target_became_block"), true);
clearSource(stack); // TODO: But is this fair? It's a rather hidden way of unbinding your signature!
return ActionResult.FAIL;
}
@ -92,9 +92,9 @@ public class RiftSignatureItem extends Item {
stack.damage(1, player, a -> {}); // TODO: calculate damage based on position?
clearSource(stack);
player.sendMessage(new TranslatableText(getTranslationKey() + ".created"));
player.sendMessage(new TranslatableText(getTranslationKey() + ".created"), true);
// null = send sound to the player too, we have to do this because this code is not run client-side
world.playSound(null, player.getSenseCenterPos(), ModSoundEvents.RIFT_END, SoundCategory.BLOCKS, 0.6f, 1);
world.playSound(null, player.getBlockPos(), ModSoundEvents.RIFT_END, SoundCategory.BLOCKS, 0.6f, 1);
}
return ActionResult.SUCCESS;

View file

@ -40,7 +40,7 @@ public class RiftStabilizerItem extends Item {
// TODO: not necessarily success, fix this and all other similar cases to make arm swing correct
return new TypedActionResult<>(ActionResult.SUCCESS, stack);
} else {
player.sendMessage(new TranslatableText("tools.rift_miss"));
player.sendMessage(new TranslatableText("tools.rift_miss"), true);
DetachedRiftBlockEntityRenderer.showRiftCoreUntil = System.currentTimeMillis() + ModConfig.GRAPHICS.highlightRiftCoreFor;
return new TypedActionResult<>(ActionResult.FAIL, stack);
}
@ -50,12 +50,12 @@ public class RiftStabilizerItem extends Item {
DetachedRiftBlockEntity rift = (DetachedRiftBlockEntity) world.getBlockEntity(new BlockPos(hit.getPos()));
if (!rift.stabilized && !rift.closing) {
rift.setStabilized(true);
world.playSound(null, player.getSenseCenterPos(), ModSoundEvents.RIFT_CLOSE, SoundCategory.BLOCKS, 0.6f, 1); // TODO: different sound
world.playSound(null, player.getBlockPos(), ModSoundEvents.RIFT_CLOSE, SoundCategory.BLOCKS, 0.6f, 1); // TODO: different sound
stack.damage(1, player, a -> {});
player.sendMessage(new TranslatableText(getTranslationKey() + ".stabilized"));
player.sendMessage(new TranslatableText(getTranslationKey() + ".stabilized"), true);
return new TypedActionResult<>(ActionResult.SUCCESS, stack);
} else {
player.sendMessage(new TranslatableText(getTranslationKey() + ".already_stabilized"));
player.sendMessage(new TranslatableText(getTranslationKey() + ".already_stabilized"), true);
}
}
return new TypedActionResult<>(ActionResult.FAIL, stack);

View file

@ -33,7 +33,7 @@ public class StabilizedRiftSignatureItem extends Item { // TODO: common supercla
}
@Override
public boolean hasEnchantmentGlint(ItemStack stack) {
public boolean hasGlint(ItemStack stack) {
return stack.getTag() != null && stack.getTag().contains("destination");
}
@ -63,13 +63,13 @@ public class StabilizedRiftSignatureItem extends Item { // TODO: common supercla
if (target == null) {
// The link signature has not been used. Store its current target as the first location.
setSource(stack, new RotatedLocation((ServerWorld) world, pos, player.yaw, 0));
player.sendMessage(new TranslatableText(getTranslationKey() + ".stored"));
world.playSound(null, player.getSenseCenterPos(), ModSoundEvents.RIFT_START, SoundCategory.BLOCKS, 0.6f, 1);
player.sendMessage(new TranslatableText(getTranslationKey() + ".stored"), true);
world.playSound(null, player.getBlockPos(), ModSoundEvents.RIFT_START, SoundCategory.BLOCKS, 0.6f, 1);
} else {
// Place a rift at the target point
if (target.getBlockState().getBlock() != ModBlocks.DETACHED_RIFT) {
if (!target.getBlockState().getBlock().canReplace(world.getBlockState(target.getBlockPos()), itemPlacementContext)) {
player.sendMessage(new TranslatableText("tools.target_became_block"));
player.sendMessage(new TranslatableText("tools.target_became_block"), true);
// Don't clear source, stabilized signatures always stay bound
return ActionResult.FAIL;
}
@ -87,8 +87,8 @@ public class StabilizedRiftSignatureItem extends Item { // TODO: common supercla
stack.damage(1, player, playerEntity -> {});
player.sendMessage(new TranslatableText(getTranslationKey() + ".created"));
world.playSound(null, player.getSenseCenterPos(), ModSoundEvents.RIFT_END, SoundCategory.BLOCKS, 0.6f, 1);
player.sendMessage(new TranslatableText(getTranslationKey() + ".created"), true);
world.playSound(null, player.getBlockPos(), ModSoundEvents.RIFT_END, SoundCategory.BLOCKS, 0.6f, 1);
}
return ActionResult.SUCCESS;

View file

@ -56,7 +56,7 @@ public final class PocketGenerator {
*/
public static Pocket generateDungeonPocket(VirtualLocation virtualLocation, VirtualTarget linkTo, LinkProperties linkProperties) {
int depth = virtualLocation.depth;
float netherProbability = virtualLocation.world.dimension.isNether() ? 1 : (float) depth / 200; // TODO: improve nether probability
float netherProbability = virtualLocation.world.getDimension().isUltrawarm() ? 1 : (float) depth / 200; // TODO: improve nether probability
Random random = new Random();
String group = random.nextFloat() < netherProbability ? "nether" : "ruins";
PocketTemplate pocketTemplate = SchematicHandler.INSTANCE.getRandomTemplate(group, depth, ModConfig.POCKETS.maxPocketSize, false);

View file

@ -221,7 +221,7 @@ public class PocketTemplate {
rifts.add(rift);
} else if (tile instanceof Inventory) {
Inventory inventory = (Inventory) tile;
if (inventory.isInvEmpty()) {
if (inventory.isEmpty()) {
if (tile instanceof ChestBlockEntity || tile instanceof DispenserBlockEntity) {
LootTable table;
if (tile instanceof ChestBlockEntity) {
@ -231,10 +231,10 @@ public class PocketTemplate {
LOGGER.debug("Now populating dispenser.");
table = world.getServer().getLootManager().getTable(new Identifier("dimdoors:dispenser_projectiles"));
}
LootContext ctx = new LootContext.Builder(world).setRandom(world.random).build(LootContextTypes.CHEST);
LootContext ctx = new LootContext.Builder(world).random(world.random).build(LootContextTypes.CHEST);
table.supplyInventory(inventory, ctx);
LOGGER.debug("Inventory should be populated now. Chest is: " + (inventory.isInvEmpty() ? "empty." : "filled."));
if (inventory.isInvEmpty()) {
LOGGER.debug("Inventory should be populated now. Chest is: " + (inventory.isEmpty() ? "empty." : "filled."));
if (inventory.isEmpty()) {
LOGGER.error(", however Inventory is: empty!");
}
}

View file

@ -6,7 +6,6 @@ import net.minecraft.nbt.Tag;
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;
import org.dimdev.pocketlib.Pocket;
@ -20,6 +19,8 @@ import org.jgrapht.graph.DefaultEdge;
import java.util.*;
import java.util.stream.Collectors;
import static net.minecraft.world.World.OVERWORLD;
public class RiftRegistry extends PersistentState {
private static final Logger LOGGER = LogManager.getLogger();
private static final String DATA_NAME = "rifts";
@ -44,7 +45,7 @@ public class RiftRegistry extends PersistentState {
}
private static RiftRegistry instance(MinecraftServer server) {
return server.getWorld(DimensionType.OVERWORLD).getPersistentStateManager().getOrCreate(() -> new RiftRegistry(server.getWorld(DimensionType.OVERWORLD)), DATA_NAME);
return server.getWorld(OVERWORLD).getPersistentStateManager().getOrCreate(() -> new RiftRegistry(server.getWorld(OVERWORLD)), DATA_NAME);
}
@Override
@ -72,8 +73,8 @@ public class RiftRegistry extends PersistentState {
// Read the connections between links that have a source or destination in this dimension
ListTag linksNBT = (ListTag) nbt.get("links");
for (Tag linkNBT : linksNBT) {
RegistryVertex from = uuidMap.get(((CompoundTag) linkNBT).getUuidNew("from"));
RegistryVertex to = uuidMap.get(((CompoundTag) linkNBT).getUuidNew("to"));
RegistryVertex from = uuidMap.get(((CompoundTag) linkNBT).getUuid("from"));
RegistryVertex to = uuidMap.get(((CompoundTag) linkNBT).getUuid("to"));
if (from != null && to != null) {
graph.addEdge(from, to);
// We need a system for detecting links that are incomplete after processing them in the other subregistry too
@ -110,8 +111,8 @@ public class RiftRegistry extends PersistentState {
RegistryVertex from = graph.getEdgeSource(edge);
RegistryVertex to = graph.getEdgeTarget(edge);
CompoundTag linkNBT = new CompoundTag();
linkNBT.putUuidNew("from", from.id);
linkNBT.putUuidNew("to", to.id);
linkNBT.putUuid("from", from.id);
linkNBT.putUuid("to", to.id);
linksNBT.add(linkNBT);
}
tag.put("links", linksNBT);
@ -126,8 +127,8 @@ public class RiftRegistry extends PersistentState {
private Map<UUID, PlayerRiftPointer> readPlayerRiftPointers(ListTag tag) {
Map<UUID, PlayerRiftPointer> pointerMap = new HashMap<>();
for (Tag entryNBT : tag) {
UUID player = ((CompoundTag) entryNBT).getUuidNew("player");
UUID rift = ((CompoundTag) entryNBT).getUuidNew("rift");
UUID player = ((CompoundTag) entryNBT).getUuid("player");
UUID rift = ((CompoundTag) entryNBT).getUuid("rift");
PlayerRiftPointer pointer = new PlayerRiftPointer(player);
pointerMap.put(player, pointer);
uuidMap.put(pointer.id, pointer);
@ -141,10 +142,10 @@ public class RiftRegistry extends PersistentState {
ListTag pointers = new ListTag();
for (Map.Entry<UUID, PlayerRiftPointer> entry : playerRiftPointerMap.entrySet()) {
CompoundTag entryNBT = new CompoundTag();
entryNBT.putUuidNew("player", entry.getKey());
entryNBT.putUuid("player", entry.getKey());
int count = 0;
for (DefaultEdge edge : graph.outgoingEdgesOf(entry.getValue())) {
entryNBT.putUuidNew("rift", graph.getEdgeTarget(edge).id);
entryNBT.putUuid("rift", graph.getEdgeTarget(edge).id);
count++;
}
if (count != 1) throw new RuntimeException("PlayerRiftPointer points to more than one rift");

View file

@ -8,13 +8,14 @@ import net.minecraft.text.TranslatableText;
import org.dimdev.dimdoors.block.entity.RiftBlockEntity;
import org.dimdev.dimdoors.rift.registry.RiftRegistry;
import org.dimdev.dimdoors.world.ModDimensions;
import org.dimdev.dimdoors.world.limbo.LimboDimension;
import org.dimdev.pocketlib.VirtualLocation;
import org.dimdev.util.Location;
import org.dimdev.util.TeleportUtil;
import java.util.UUID;
import static org.dimdev.util.EntityUtils.chat;
public class EscapeTarget extends VirtualTarget implements EntityTarget { // TODO: createRift option
protected boolean canEscapeLimbo = false;
@ -37,12 +38,12 @@ public class EscapeTarget extends VirtualTarget implements EntityTarget { // TOD
@Override
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"));
if (!ModDimensions.isDimDoorsPocketDimension(entity.world) && !(ModDimensions.isLimboDimension(entity.world))) {
chat(entity, new TranslatableText("rifts.destinations.escape.not_in_pocket_dim"));
return false;
}
if (entity.world.dimension instanceof LimboDimension && !canEscapeLimbo) {
entity.sendMessage(new TranslatableText("rifts.destinations.escape.cannot_escape_limbo"));
if (ModDimensions.isLimboDimension(entity.world) && !canEscapeLimbo) {
chat(entity, new TranslatableText("rifts.destinations.escape.cannot_escape_limbo"));
return false;
}
@ -50,16 +51,16 @@ public class EscapeTarget extends VirtualTarget implements EntityTarget { // TOD
if (uuid != null) {
Location destLoc = RiftRegistry.instance(entity.world).getOverworldRift(uuid);
if (destLoc != null && destLoc.getBlockEntity() instanceof RiftBlockEntity || canEscapeLimbo) {
Location location = VirtualLocation.fromLocation(new Location((ServerWorld) entity.world, entity.getSenseCenterPos())).projectToWorld(false);
Location location = VirtualLocation.fromLocation(new Location((ServerWorld) entity.world, entity.getBlockPos())).projectToWorld(false);
TeleportUtil.teleport(entity, location.world, location.pos, 0);
return true;
} else {
if (destLoc == null) {
entity.sendMessage(new TranslatableText("rifts.destinations.escape.did_not_use_rift"));
chat(entity, new TranslatableText("rifts.destinations.escape.did_not_use_rift"));
} else {
entity.sendMessage(new TranslatableText("rifts.destinations.escape.rift_has_closed"));
chat(entity, new TranslatableText("rifts.destinations.escape.rift_has_closed"));
}
FabricDimensions.teleport(entity, ModDimensions.LIMBO);
FabricDimensions.teleport(entity, entity.getServer().getWorld(ModDimensions.LIMBO));
return true;
}
} else {

View file

@ -3,7 +3,8 @@ 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.ModDimensions;
import static org.dimdev.dimdoors.world.ModDimensions.LIMBO;
public class LimboTarget extends VirtualTarget implements EntityTarget {
public LimboTarget() {}
@ -21,7 +22,7 @@ public class LimboTarget extends VirtualTarget implements EntityTarget {
@Override
public boolean receiveEntity(Entity entity, float yawOffset) {
FabricDimensions.teleport(entity, ModDimensions.LIMBO);
FabricDimensions.teleport(entity, entity.getServer().getWorld(LIMBO));
return true;
}
}

View file

@ -2,6 +2,7 @@ package org.dimdev.dimdoors.rift.targets;
import net.minecraft.entity.Entity;
import net.minecraft.text.TranslatableText;
import org.dimdev.util.EntityUtils;
@SuppressWarnings("OverloadedVarargsMethod")
public class MessageTarget implements EntityTarget {
@ -22,7 +23,7 @@ public class MessageTarget implements EntityTarget {
@Override
public boolean receiveEntity(Entity entity, float yawOffset) {
entity.sendMessage(new TranslatableText(message, messageParams));
EntityUtils.chat(entity, new TranslatableText(message, messageParams));
if (forwardTo != null) {
forwardTo.as(Targets.ENTITY).receiveEntity(entity, yawOffset);

View file

@ -5,6 +5,7 @@ import net.minecraft.nbt.CompoundTag;
import net.minecraft.text.TranslatableText;
import org.dimdev.annotatednbt.Saved;
import org.dimdev.annotatednbt.AnnotatedNbt;
import org.dimdev.util.EntityUtils;
public class PocketEntranceMarker extends VirtualTarget implements EntityTarget {
@ -41,7 +42,7 @@ public class PocketEntranceMarker extends VirtualTarget implements EntityTarget
@Override
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."));
EntityUtils.chat(entity, 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

@ -3,6 +3,7 @@ package org.dimdev.dimdoors.rift.targets;
import net.minecraft.entity.Entity;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.text.TranslatableText;
import org.dimdev.util.EntityUtils;
public class PocketExitMarker extends VirtualTarget implements EntityTarget {
public PocketExitMarker() {}
@ -20,7 +21,7 @@ public class PocketExitMarker extends VirtualTarget implements EntityTarget {
@Override
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."));
EntityUtils.chat(entity, 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

@ -7,7 +7,6 @@ import net.minecraft.text.TranslatableText;
import org.dimdev.dimdoors.block.entity.RiftBlockEntity;
import org.dimdev.dimdoors.rift.registry.RiftRegistry;
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;
@ -38,16 +37,16 @@ public class PrivatePocketExitTarget extends VirtualTarget implements EntityTarg
if (uuid != null) {
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)) {
if (ModDimensions.isDimDoorsPocketDimension(location.world) && pocket != null && PocketRegistry.instance(pocket.world).getPocketAt(location.pos).equals(pocket)) {
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) {
entity.sendMessage(new TranslatableText("rifts.destinations.private_pocket_exit.did_not_use_rift"));
EntityUtils.chat(entity, new TranslatableText("rifts.destinations.private_pocket_exit.did_not_use_rift"));
} else {
entity.sendMessage(new TranslatableText("rifts.destinations.private_pocket_exit.rift_has_closed"));
EntityUtils.chat(entity, new TranslatableText("rifts.destinations.private_pocket_exit.rift_has_closed"));
}
FabricDimensions.teleport(entity, ModDimensions.LIMBO);
FabricDimensions.teleport(entity, entity.getServer().getWorld(ModDimensions.LIMBO));
return false;
} else {
((EntityTarget) destLoc.getBlockEntity()).receiveEntity(entity, yawOffset);

View file

@ -3,6 +3,7 @@ package org.dimdev.dimdoors.rift.targets;
import net.minecraft.fluid.Fluid;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.math.Direction;
import org.dimdev.util.EntityUtils;
// A list of the default targets provided by dimcore. Add your own in ModTargets
public final class Targets {
@ -13,7 +14,7 @@ public final class Targets {
public static void registerDefaultTargets() {
DefaultTargets.registerDefaultTarget(ENTITY, (entity, relativeYaw) -> {
entity.sendMessage(new TranslatableText("rifts.unlinked"));
EntityUtils.chat(entity, new TranslatableText("rifts.unlinked"));
return false;
});
DefaultTargets.registerDefaultTarget(ITEM, stack -> false);

View file

@ -1,224 +0,0 @@
//package org.dimdev.dimdoors.tools;
//
//import net.minecraft.block.DoorBlock;
//import net.minecraft.block.state.BlockState;
//import net.minecraft.item.DyeColor;
//import net.minecraft.nbt.CompressedStreamTools;
//import net.minecraft.nbt.CompoundTag;
//import org.dimdev.util.schem.Schematic;
//import org.dimdev.dimdoors.block.DimensionalDoorBlock;
//import org.dimdev.dimdoors.block.FabricBlock;
//import org.dimdev.dimdoors.block.AncientFabricBlock;
//import org.dimdev.dimdoors.block.ModBlocks;
//import org.dimdev.dimdoors.rift.targets.VirtualTarget;
//import org.dimdev.dimdoors.rift.targets.PocketEntranceMarker;
//import org.dimdev.dimdoors.rift.targets.PocketExitMarker;
//import org.dimdev.dimdoors.rift.targets.PrivatePocketExitTarget;
//import org.dimdev.dimdoors.rift.registry.LinkProperties;
//import org.dimdev.dimdoors.block.entity.EntranceRiftBlockEntity;
//
//import java.io.DataOutputStream;
//import java.io.File;
//import java.io.FileOutputStream;
//import java.io.IOException;
//import java.util.ArrayList;
//import java.util.Arrays;
//import java.util.Collections;
//import java.util.List;
//
//public final class SchematicGenerator {
//
// // Run "gradlew generatePocketSchematics" to generate the pocket schematics
// @SuppressWarnings("UseOfSystemOutOrSystemErr")
// public static void main(String... args) throws IOException {
//
// // Parse arguments
// File schematicDir;
// if (args.length > 1) {
// System.err.println("Too many arguments!");
// return;
// } else if (args.length == 1) {
// schematicDir = new File(args[0]);
// if (!schematicDir.isDirectory()) {
// System.err.print("The directory " + args[0] + " couldn't be found!");
// return;
// }
// } else {
// schematicDir = new File("schematics/");
// }
//
// // Register blocks and tile entities to be able to run this without starting Minecraft
// Initializer.initialize();
//
// // Generate the schematics
// List<Schematic> schematics = generatePocketSchematics();
//
// // Save the schematics
// String[] saveFolders = {"public/", "private/", "blank/", "blank/", "blank/"};
// int i = 0;
// for (Schematic schematic : schematics) {
// CompoundTag schematicNBT = schematic.saveToNBT();
// File saveFile = new File(schematicDir, saveFolders[i++ % saveFolders.length] + schematic.name + ".schem");
// saveFile.getParentFile().mkdirs();
// DataOutputStream schematicDataStream = new DataOutputStream(new FileOutputStream(saveFile));
// CompressedStreamTools.writeCompressed(schematicNBT, schematicDataStream);
// schematicDataStream.flush();
// schematicDataStream.close();
// }
// // TODO: also generate JSON files
// }
//
// public static List<Schematic> generatePocketSchematics() {
// List<Schematic> schematics = new ArrayList<>();
// for (int pocketSize = 0; pocketSize < 8; pocketSize++) { // Changing to 8 to 16 would cause out of memory (256^3*4 bytes = 64MB/schematic)
// schematics.add(generateBlankWithDoor(
// "public_pocket", // base name
// pocketSize, // size
// ModBlocks.ANCIENT_FABRIC.getDefaultState(), // outer wall
// ModBlocks.BLACK_FABRIC.getDefaultState(), // inner wall
// ModBlocks.IRON_DIMENSIONAL_DOOR, // door
// PocketExitMarker.builder().build(),// exit rift destination
// LinkProperties.builder()
// .groups(Collections.singleton(1))
// .linksRemaining(1)
// .entranceWeight(1)
// .floatingWeight(1)
// .build()));
//
// schematics.add(generateBlankWithDoor(
// "private_pocket", // base name
// pocketSize, // size
// ModBlocks.ANCIENT_FABRIC.getDefaultState().withProperty(AncientFabricBlock.COLOR, DyeColor.WHITE), // outer wall
// ModBlocks.BLACK_FABRIC.getDefaultState().withProperty(AncientFabricBlock.COLOR, DyeColor.WHITE), // inner wall
// ModBlocks.QUARTZ_DIMENSIONAL_DOOR, // door
// PrivatePocketExitTarget.builder().build(),// exit rift destination
// null));
//
// schematics.add(generateBlank(
// "blank_pocket",
// pocketSize,
// ModBlocks.ANCIENT_FABRIC.getDefaultState(),
// ModBlocks.BLACK_FABRIC.getDefaultState()));
//
// schematics.add(generateFrame(
// "void_pocket",
// pocketSize,
// ModBlocks.BLACK_FABRIC.getDefaultState().withProperty(FabricBlock.COLOR, DyeColor.LIGHT_BLUE)));
//
// schematics.add(generateResizableFrame(
// "resizable_pocket",
// pocketSize,
// ModBlocks.BLACK_FABRIC.getDefaultState().withProperty(FabricBlock.COLOR, DyeColor.ORANGE)));
// }
// return schematics;
// }
//
// private static Schematic generateBlank(String baseName, int pocketSize, BlockState outerWall, BlockState innerWall) {
// short size = (short) ((pocketSize + 1) * 16 - 1); // -1 so that the door can be centered
//
// // Set schematic info
// Schematic schematic = new Schematic(baseName + "_" + pocketSize, "DimDoors", size, size, size);
// schematic.requiredMods = new String[]{"dimdoors"};
//
// // Set block data
// for (int x = 0; x < size; x++) {
// for (int y = 0; y < size; y++) {
// for (int z = 0; z < size; z++) {
// int layer = Collections.min(Arrays.asList(x, y, z, size - 1 - x, size - 1 - y, size - 1 - z));
// if (layer == 0) {
// schematic.setBlockState(x, y, z, outerWall);
// } else if (layer < 5) {
// schematic.setBlockState(x, y, z, innerWall);
// }
// }
// }
// }
//
// return schematic;
// }
//
// private static Schematic generateBlankWithDoor(String baseName, int pocketSize, BlockState outerWall, BlockState innerWall, DimensionalDoorBlock doorBlock, VirtualTarget exitDest, LinkProperties link) {
// short size = (short) ((pocketSize + 1) * 16 - 1); // -1 so that the door can be centered
//
// // Make the schematic
// Schematic schematic = generateBlank(baseName, pocketSize, outerWall, innerWall);
//
// // Add the door
// schematic.setBlockState((size - 1) / 2, 5, 4, doorBlock.getDefaultState().withProperty(DoorBlock.HALF, DoorBlock.EnumDoorHalf.LOWER));
// schematic.setBlockState((size - 1) / 2, 6, 4, doorBlock.getDefaultState().withProperty(DoorBlock.HALF, DoorBlock.EnumDoorHalf.UPPER));
//
// // Set the rift entities
// schematic.tileEntities = new ArrayList<>();
// EntranceRiftBlockEntity rift = (EntranceRiftBlockEntity) doorBlock.createTileEntity(null, doorBlock.getDefaultState());
// rift.setDestination(PocketEntranceMarker.builder()
// .ifDestination(exitDest)
// .build());
// rift.setProperties(link);
//
// rift.setLeaveRiftOnBreak(true);
// CompoundTag tileNBT = rift.serializeNBT();
// tileNBT.setInteger("x", (size - 1) / 2);
// tileNBT.setInteger("y", 5);
// tileNBT.setInteger("z", 4);
// schematic.tileEntities.add(tileNBT);
//
// return schematic;
// }
//
// private static Schematic generateFrame(String baseName, int chunkSize, BlockState frame) {
// short size = (short) ((chunkSize + 1) * 16 - 1); // -1 so that the door can be centered
//
// // Set schematic info
// Schematic schematic = new Schematic(baseName + "_" + chunkSize, "DimDoors", size, size, size);
// schematic.requiredMods = new String[]{"dimdoors"};
//
// // Set block data
// for (int x = 0; x < size; x++) {
// for (int y = 0; y < size; y++) {
// for (int z = 0; z < size; z++) {
// int sides = 0;
// if (x == 0 || x == size - 1) sides++;
// if (y == 0 || y == size - 1) sides++;
// if (z == 0 || z == size - 1) sides++;
//
// if (sides >= 2) {
// schematic.setBlockState(x, y, z, frame);
// }
// }
// }
// }
//
// return schematic;
// }
//
// private static Schematic generateResizableFrame(String baseName, int chunkSize, BlockState frame) {
// short size = (short) ((chunkSize + 1) * 16);
//
// // Set schematic info
// Schematic schematic = new Schematic(baseName + "_" + chunkSize, "DimDoors", size, size, size);
// schematic.requiredMods = new String[]{"dimdoors"};
//
// // Set block data
// for (int x = 0; x < size; x++) {
// for (int y = 0; y < size; y++) {
// for (int z = 0; z < size; z++) {
// int sides = 0;
// if (x % 16 == 0) sides++;
// if (y % 16 == 0) sides++;
// if (z % 16 == 0) sides++;
// int cubeSides = 3;
// int cubeSize = Math.max(x, Math.max(y, z));
// if (cubeSize - x != 0) cubeSides--;
// if (cubeSize - y != 0) cubeSides--;
// if (cubeSize - z != 0) cubeSides--;
//
// if (sides >= 2 && cubeSides >= 2) {
// schematic.setBlockState(x, y, z, frame);
// }
// }
// }
// }
//
// return schematic;
// }
//}

View file

@ -10,7 +10,7 @@ public final class ModBiomes {
public static final Biome LIMBO = register(new Identifier("dimdoors:limbo"), new LimboBiome());
public static final Biome WHITE_VOID = register(new Identifier("dimdoors:white_void"), new BlankBiome(true, false));
public static final Biome BLACK_VOID = register(new Identifier("dimdoors:black_void"), new BlankBiome(false, false));
public static final Biome DANGEROUS_BLACK_VOID = register(new Identifier("dimdoors:dangeroud_black_void"), new BlankBiome(false, true));
public static final Biome DANGEROUS_BLACK_VOID = register(new Identifier("dimdoors:dangerous_black_void"), new BlankBiome(false, true));
private static Biome register(Identifier id, Biome biome) {
Registry.register(Registry.BIOME, id, biome);

View file

@ -1,24 +1,23 @@
package org.dimdev.dimdoors.world;
import net.fabricmc.fabric.api.dimension.v1.FabricDimensionType;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
import net.minecraft.util.registry.RegistryKey;
import net.minecraft.world.World;
import net.minecraft.world.dimension.DimensionType;
import org.dimdev.dimdoors.world.limbo.LimboDimension;
import org.dimdev.dimdoors.world.pocketdimension.DungeonPocketDimension;
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).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 final RegistryKey<World> LIMBO = RegistryKey.of(Registry.DIMENSION, new Identifier("dimdoors:limbo"));
public static final RegistryKey<World> PERSONAL = RegistryKey.of(Registry.DIMENSION, new Identifier("dimdoors:personal_pockets"));
public static final RegistryKey<World> PUBLIC = RegistryKey.of(Registry.DIMENSION, new Identifier("dimdoors:public_pockets"));
public static final RegistryKey<World> DUNGEON = RegistryKey.of(Registry.DIMENSION, new Identifier("dimdoors:dungeon_pockets"));
public static boolean isDimDoorsPocketDimension(World world) {
return world.dimension instanceof PublicPocketDimension
|| world.dimension instanceof PersonalPocketDimension
|| world.dimension instanceof DungeonPocketDimension;
RegistryKey<World> type = world.getRegistryKey();
return type == PERSONAL || type == PUBLIC || type == DUNGEON;
}
public static boolean isLimboDimension(World world) {
return world.getRegistryKey() == LIMBO;
}
public static void init() {

View file

@ -1,142 +0,0 @@
//package org.dimdev.dimdoors.world.gateways;
//
//import net.minecraft.block.Blocks;
//import net.minecraft.block.Material;
//import net.minecraft.util.math.BlockPos;
//import net.minecraft.world.Heightmap;
//import net.minecraft.world.World;
//import net.minecraft.world.WorldProviderEnd;
//import net.minecraft.world.chunk.ChunkProvider;
//import net.minecraft.world.dimension.TheNetherDimension;
//import net.minecraft.world.gen.chunk.ChunkGenerator;
//import net.minecraftforge.fml.common.IWorldGenerator;
//import org.dimdev.dimdoors.ModConfig;
//import org.dimdev.dimdoors.block.ModBlocks;
//import org.dimdev.pocketlib.PocketWorldDimension;
//
//import java.util.ArrayList;
//import java.util.Arrays;
//import java.util.Random;
//
//public class GatewayGenerator implements IWorldGenerator {
// private static final int CLUSTER_GROWTH_CHANCE = 80;
// private static final int MAX_CLUSTER_GROWTH_CHANCE = 100;
// private static final int MIN_RIFT_Y = 4;
// private static final int MAX_RIFT_Y = 240;
// private static final int CHUNK_LENGTH = 16;
// private static final int MAX_GATEWAY_GENERATION_ATTEMPTS = 10;
//
// private ArrayList<BaseGateway> gateways;
// private BaseGateway defaultGateway;
//
// public GatewayGenerator() {
// gateways = new ArrayList<>();
// defaultGateway = new GatewayTwoPillars();
//
// // Add gateways here
// gateways.add(new GatewaySandstonePillars());
// gateways.add(new LimboGateway());
// }
//
// @Override
// public void generate(Random random, int chunkX, int chunkZ, World world, ChunkGenerator chunkGenerator, ChunkProvider chunkProvider) {
// // Don't generate rifts or gateways if the current world is a pocket dimension or the world is remote.
// // Also don't generate anything in the Nether or The End.
// if (world.isClient || world.dimension instanceof PocketWorldDimension || world.dimension instanceof TheNetherDimension || world.dimension instanceof WorldProviderEnd) {
// return;
// }
//
// int x, y, z;
// int attempts;
// boolean valid;
//
// // Check if we're allowed to generate rift clusters in this dimension.
// // If so, randomly decide whether to one.
// boolean clusterGenerated = false;
// if (!ModConfig.WORLD.clusterDimBlacklist.contains(world.dimension.getType().getSuffix())) {
// double clusterGenChance = ModConfig.WORLD.clusterGenChance;
// while (clusterGenChance > 0.0) {
// if (random.nextDouble() < clusterGenChance) {
// do {
// //Pick a random point on the surface of the chunk
// x = chunkX * CHUNK_LENGTH + random.nextInt(CHUNK_LENGTH);
// z = chunkZ * CHUNK_LENGTH + random.nextInt(CHUNK_LENGTH);
// y = world.getHeight(x, z);
//
// //If the point is within the acceptable altitude range, the block above is empty, and we're
// //not building on bedrock, then generate a rift there
// if (y >= MIN_RIFT_Y && y <= MAX_RIFT_Y && world.isAirBlock(new BlockPos(x, y + 1, z))
// && world.getBlockState(new BlockPos(x, y, z)).getBlock() != Blocks.BEDROCK
// && //<-- Stops Nether roof spawning. DO NOT REMOVE!
// world.getBlockState(new BlockPos(x, y - 1, z)).getBlock() != Blocks.BEDROCK
// && world.getBlockState(new BlockPos(x, y - 2, z)).getBlock() != Blocks.BEDROCK) {
// //Create a link. If this is not the first time, create a child link and connect it to the first link.
// world.setBlockState(new BlockPos(x, y, z), ModBlocks.DETACHED_RIFT.getDefaultState());
// }
// } //Randomly decide whether to repeat the process and add another rift to the cluster
// while (random.nextInt(MAX_CLUSTER_GROWTH_CHANCE) < CLUSTER_GROWTH_CHANCE);
// clusterGenerated = true;
// }
// clusterGenChance -= 1.0;
// }
// }
//
// // Check if we can place a Rift Gateway in this dimension, then randomly decide whether to place one.
// // This only happens if a rift cluster was NOT generated.
// if (!clusterGenerated && Arrays.binarySearch(ModConfig.WORLD.gatewayDimBlacklist, world.dimension.getDimensionType().getId()) == -1) {
// double gatewayGenChance = ModConfig.WORLD.gatewayGenChance;
// while (gatewayGenChance > 0.0) {
// if (random.nextDouble() < gatewayGenChance) {
// valid = false;
// x = y = z = 0; //Stop the compiler from freaking out
//
// //Check locations for the gateway until we are satisfied or run out of attempts.
// for (attempts = 0; attempts < MAX_GATEWAY_GENERATION_ATTEMPTS && !valid; attempts++) {
// //Pick a random point on the surface of the chunk and check its materials
// x = chunkX * CHUNK_LENGTH + random.nextInt(CHUNK_LENGTH);
// z = chunkZ * CHUNK_LENGTH + random.nextInt(CHUNK_LENGTH);
// y = world.getTopY(Heightmap.Type.WORLD_SURFACE, x, z);
// valid = checkGatewayLocation(world, new BlockPos(x, y, z));
// }
//
// // Build the gateway if we found a valid location
// if (valid) {
// ArrayList<BaseGateway> validGateways = new ArrayList<>();
// for (BaseGateway gateway : gateways) {
// if (gateway.isLocationValid(world, x, y, z)) {
// validGateways.add(gateway);
// }
// }
// // Add the default gateway if the rest were rejected
// if (validGateways.isEmpty()) {
// validGateways.add(defaultGateway);
// }
// // Randomly select a gateway from the pool of viable gateways
// validGateways.get(random.nextInt(validGateways.size())).generate(world, x, y - 1, z);
// }
// }
// gatewayGenChance -= 1.0;
// }
// }
// }
//
// private static boolean checkGatewayLocation(World world, BlockPos pos) {
// //Check if the point is within the acceptable altitude range, the block above that point is empty,
// //and the block two levels down is opaque and has a reasonable material. Plus that we're not building
// //on top of bedrock.
// return pos.getY() >= MIN_RIFT_Y && pos.getY() <= MAX_RIFT_Y
// && world.isAir(pos.up())
// && world.getBlockState(pos).getBlock() != Blocks.BEDROCK
// && world.getBlockState(pos.down()).getBlock() != Blocks.BEDROCK //<-- Stops Nether roof spawning. DO NOT REMOVE!
// && checkFoundationMaterial(world, pos.down());
// }
//
// private static boolean checkFoundationMaterial(World world, BlockPos pos) {
// //We check the material and opacity to prevent generating gateways on top of trees or houses,
// //or on top of strange things like tall grass, water, slabs, or torches.
// //We also want to avoid generating things on top of the Nether's bedrock!
// Material material = world.getBlockState(pos).getMaterial();
// return material != Material.LEAVES && material != Material.WOOD && material != Material.PUMPKIN
// && world.getBlockState(pos).isFullCube(world, pos) && world.getBlockState(pos).getBlock() != Blocks.BEDROCK;
// }
//}

View file

@ -5,8 +5,7 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.World;
import org.dimdev.dimdoors.block.ModBlocks;
import org.dimdev.dimdoors.item.DimensionalDoorItem;
import org.dimdev.dimdoors.world.limbo.LimboDimension;
import org.dimdev.dimdoors.world.ModDimensions;
public class LimboGateway extends BaseGateway {
@Override
@ -32,6 +31,6 @@ public class LimboGateway extends BaseGateway {
@Override
public boolean isLocationValid(World world, int x, int y, int z) {
return world.dimension instanceof LimboDimension;
return ModDimensions.isLimboDimension(world);
}
}

View file

@ -1,7 +1,7 @@
package org.dimdev.dimdoors.world.limbo;
import com.google.common.collect.ImmutableList;
import net.minecraft.entity.EntityCategory;
import net.minecraft.entity.SpawnGroup;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.BiomeEffects;
import net.minecraft.world.gen.surfacebuilder.SurfaceBuilder;
@ -37,8 +37,6 @@ public class LimboBiome extends Biome {
)
.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));
addSpawn(SpawnGroup.MONSTER, new Biome.SpawnEntry(ModEntityTypes.MONOLITH, 100, 1, 1));
}
}

View file

@ -1,91 +1,93 @@
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.chunk.Chunk;
import net.minecraft.world.gen.chunk.SurfaceChunkGenerator;
import net.minecraft.world.gen.feature.Feature;
import java.util.List;
import java.util.Random;
public class LimboChunkGenerator extends SurfaceChunkGenerator<LimboChunkGeneratorConfig> {
private final double[] noiseFalloff = buildNoiseFalloff();
public LimboChunkGenerator(IWorld world, BiomeSource biomeSource, LimboChunkGeneratorConfig config) {
super(world, biomeSource, 4, 8, 256, config, false);
}
@Override
protected void sampleNoiseColumn(double[] buffer, int x, int z) {
sampleNoiseColumn(buffer, x, z, 884.412D, 9740.421D, 8.555150000000001D, 20.2206D, 3, -10);
}
@Override
protected double[] computeNoiseRange(int i, int j) {
return new double[] {-0.80118735, 5.4635482};
}
@Override
protected double computeNoiseFalloff(double d, double e, int i) {
return noiseFalloff[i]/8000d;
}
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 world.getSeaLevel() + 1;
}
@Override
public int getMaxY() {
return 256;
}
@Override
public int getSeaLevel() {
return 32;
}
@Override
protected void buildBedrock(Chunk chunk, Random random) {
}
}
//package org.dimdev.dimdoors.world.limbo;
//
//import net.minecraft.block.Blocks;
//import net.minecraft.entity.SpawnGroup;
//import net.minecraft.util.math.BlockPos;
//import net.minecraft.world.WorldAccess;
//import net.minecraft.world.biome.Biome;
//import net.minecraft.world.biome.source.BiomeSource;
//import net.minecraft.world.chunk.Chunk;
//import net.minecraft.world.gen.StructureAccessor;
//import net.minecraft.world.gen.chunk.ChunkGenerator;
//import net.minecraft.world.gen.chunk.SurfaceChunkGenerator;
//import net.minecraft.world.gen.feature.Feature;
//
//import java.util.List;
//import java.util.Random;
//
//public class LimboChunkGenerator extends ChunkGenerator {
// private final double[] noiseFalloff = buildNoiseFalloff();
//
// public LimboChunkGenerator(WorldAccess world, BiomeSource biomeSource, LimboChunkGeneratorConfig config) {
// super(world, biomeSource, 4, 8, 256, config, false);
// }
//
// @Override
// protected void sampleNoiseColumn(double[] buffer, int x, int z) {
// sampleNoiseColumn(buffer, x, z, 884.412D, 9740.421D, 8.555150000000001D, 20.2206D, 3, -10);
// }
//
// @Override
// protected double[] computeNoiseRange(int i, int j) {
// return new double[] {-0.80118735, 5.4635482};
// }
//
// @Override
// protected double computeNoiseFalloff(double d, double e, int i) {
// return noiseFalloff[i]/8000d;
// }
//
// 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(Biome biome, StructureAccessor accessor, SpawnGroup group, BlockPos pos) {
// if (group == SpawnGroup.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 world.getSeaLevel() + 1;
// }
//
// @Override
// public int getMaxY() {
// return 256;
// }
//
// @Override
// public int getSeaLevel() {
// return 32;
// }
//
// @Override
// protected void buildBedrock(Chunk chunk, Random random) {
//
// }
//}

View file

@ -1,7 +0,0 @@
package org.dimdev.dimdoors.world.limbo;
import net.minecraft.world.gen.chunk.CavesChunkGeneratorConfig;
import net.minecraft.world.gen.chunk.ChunkGeneratorConfig;
public class LimboChunkGeneratorConfig extends CavesChunkGeneratorConfig {
}

View file

@ -1,72 +0,0 @@
package org.dimdev.dimdoors.world.limbo;
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.dimdoors.block.ModBlocks;
import org.dimdev.dimdoors.world.ModBiomes;
import org.dimdev.dimdoors.world.ModDimensions;
public class LimboDimension extends Dimension {
public LimboDimension(World world, DimensionType dimensionType) {
super(world, dimensionType, 0);
}
@Override
public ChunkGenerator<?> createChunkGenerator() {
FixedBiomeSourceConfig biomeConfig = BiomeSourceType.FIXED.getConfig(world.getSeed()).setBiome(ModBiomes.LIMBO);
FixedBiomeSource biomeSource = BiomeSourceType.FIXED.applyConfig(biomeConfig);
LimboChunkGeneratorConfig chunkGeneratorConfig = new LimboChunkGeneratorConfig();
chunkGeneratorConfig.setDefaultBlock(ModBlocks.UNRAVELLED_FABRIC.getDefaultState());
chunkGeneratorConfig.setDefaultFluid(ModBlocks.ETERNAL_FLUID.getDefaultState());
return new LimboChunkGenerator(world, biomeSource, chunkGeneratorConfig);
}
@Override
public BlockPos getSpawningBlockInChunk(ChunkPos chunk, 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.5f;
}
@Override
public boolean hasVisibleSky() {
return false;
}
@Override
public Vec3d modifyFogColor(Vec3d vec3d, float f) {
return new Vec3d(0.2,0.2,0.2);
}
@Override
public boolean canPlayersSleep() {
return false;
}
@Override
public boolean isFogThick(int i, int j) {
return false;
}
@Override
public DimensionType getType() {
return ModDimensions.LIMBO;
}
}

View file

@ -6,6 +6,7 @@ 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.sound.ModSoundEvents;
public class BlankBiome extends Biome {
public BlankBiome(boolean white, boolean dangerous) {
@ -23,15 +24,18 @@ public class BlankBiome extends Biome {
.scale(0)
.temperature(0.8f)
.downfall(0)
.effects(
new BiomeEffects.Builder()
.waterColor(white ? 0xFFFFFF : 0x000000)
.waterFogColor(white ? 0xFFFFFF : 0x000000)
.fogColor(white ? 0xFFFFFF : 0x000000)
.build()
)
.effects(createEffect(white))
.parent(null)
.noises(ImmutableList.of())
);
}
private static BiomeEffects createEffect(boolean white) {
BiomeEffects.Builder builder = new BiomeEffects.Builder()
.waterColor(white ? 0xFFFFFF : 0x000000)
.waterFogColor(white ? 0xFFFFFF : 0x000000)
.fogColor(white ? 0xFFFFFF : 0x000000);
if(white) builder.loopSound(ModSoundEvents.WHITE_VOID);
return builder.build();
}
}

View file

@ -1,24 +0,0 @@
package org.dimdev.dimdoors.world.pocketdimension;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.dimension.DimensionType;
import org.dimdev.dimdoors.world.ModBiomes;
import org.dimdev.dimdoors.world.ModDimensions;
import org.dimdev.pocketlib.PocketWorldDimension;
public class DungeonPocketDimension extends PocketWorldDimension {
public DungeonPocketDimension(World world, DimensionType dimensionType) {
super(world, dimensionType, 0);
}
@Override
protected Biome getBiome() {
return ModBiomes.DANGEROUS_BLACK_VOID;
}
@Override
public DimensionType getType() {
return ModDimensions.DUNGEON;
}
}

View file

@ -1,24 +0,0 @@
package org.dimdev.dimdoors.world.pocketdimension;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.dimension.DimensionType;
import org.dimdev.dimdoors.world.ModBiomes;
import org.dimdev.dimdoors.world.ModDimensions;
import org.dimdev.pocketlib.PocketWorldDimension;
public class PersonalPocketDimension extends PocketWorldDimension {
public PersonalPocketDimension(World world, DimensionType dimensionType) {
super(world, dimensionType, 0);
}
@Override
protected Biome getBiome() {
return ModBiomes.WHITE_VOID;
}
@Override
public DimensionType getType() {
return ModDimensions.PERSONAL;
}
}

View file

@ -1,24 +0,0 @@
package org.dimdev.dimdoors.world.pocketdimension;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.dimension.DimensionType;
import org.dimdev.dimdoors.world.ModBiomes;
import org.dimdev.dimdoors.world.ModDimensions;
import org.dimdev.pocketlib.PocketWorldDimension;
public class PublicPocketDimension extends PocketWorldDimension {
public PublicPocketDimension(World world, DimensionType dimensionType) {
super(world, dimensionType, 0);
}
@Override
protected Biome getBiome() {
return ModBiomes.BLACK_VOID;
}
@Override
public DimensionType getType() {
return ModDimensions.PUBLIC;
}
}

View file

@ -1,30 +1,70 @@
package org.dimdev.pocketlib;
import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.block.BlockState;
import net.minecraft.structure.StructureManager;
import net.minecraft.world.BlockView;
import net.minecraft.world.ChunkRegion;
import net.minecraft.world.Heightmap;
import net.minecraft.world.IWorld;
import net.minecraft.world.WorldAccess;
import net.minecraft.world.biome.source.BiomeSource;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.gen.StructureAccessor;
import net.minecraft.world.gen.chunk.ChunkGenerator;
import net.minecraft.world.gen.chunk.StructuresConfig;
import net.minecraft.world.gen.chunk.VerticalBlockSample;
public class BlankChunkGenerator extends ChunkGenerator<BlankChunkGeneratorConfig> {
public BlankChunkGenerator(IWorld world, BiomeSource biomeSource, BlankChunkGeneratorConfig config) {
super(world, biomeSource, config);
import java.util.Collections;
import java.util.Optional;
public class BlankChunkGenerator extends ChunkGenerator {
public static final Codec<BlankChunkGenerator> CODEC = RecordCodecBuilder.create((instance) ->
instance.group(
BiomeSource.field_24713.fieldOf("biome_source")
.forGetter((generator) -> generator.biomeSource)
).apply(instance, instance.stable(BlankChunkGenerator::new))
);
public BlankChunkGenerator(BiomeSource biomeSource) {
super(biomeSource, new StructuresConfig(Optional.empty(), Collections.emptyMap()));
}
@Override
public void buildSurface(ChunkRegion chunkRegion, Chunk chunk) {}
protected Codec<? extends ChunkGenerator> method_28506() {
return CODEC;
}
@Override
public int getSpawnHeight() {
public ChunkGenerator withSeed(long seed) {
return this;
}
@Override
public void buildSurface(ChunkRegion region, Chunk chunk) {
}
@Override
public void populateNoise(WorldAccess world, StructureAccessor accessor, Chunk chunk) {
}
@Override
public void setStructureStarts(StructureAccessor structureAccessor, Chunk chunk, StructureManager structureManager, long l) {
}
@Override
public void addStructureReferences(WorldAccess world, StructureAccessor accessor, Chunk chunk) {
}
@Override
public int getHeight(int x, int z, Heightmap.Type heightmapType) {
return 0;
}
@Override
public void populateNoise(IWorld iWorld, Chunk chunk) {}
@Override
public int getHeightOnGround(int i, int j, Heightmap.Type type) {
return 0;
public BlockView getColumnSample(int x, int z) {
return new VerticalBlockSample(new BlockState[0]);
}
}

View file

@ -1,6 +0,0 @@
package org.dimdev.pocketlib;
import net.minecraft.world.gen.chunk.ChunkGeneratorConfig;
public class BlankChunkGeneratorConfig extends ChunkGeneratorConfig {
}

View file

@ -7,6 +7,7 @@ import net.minecraft.util.DyeColor;
import net.minecraft.util.math.BlockBox;
import net.minecraft.util.math.BlockPos;
import org.dimdev.annotatednbt.Saved;
import org.dimdev.util.EntityUtils;
public final class Pocket {
private static final int BLOCKS_PAINTED_PER_DYE = 1106;
@ -36,7 +37,7 @@ public final class Pocket {
int maxDye = amountOfDyeRequiredToColor(this);
if (dyeColor == color) {
entity.sendMessage(new TranslatableText("dimdoors.pockets.dyeAlreadyAbsorbed"));
EntityUtils.chat(entity, new TranslatableText("dimdoors.pockets.dyeAlreadyAbsorbed"));
return false;
}
@ -45,17 +46,17 @@ public final class Pocket {
dyeColor = color;
this.nextDyeColor = null;
count = 0;
entity.sendMessage(new TranslatableText("dimdoors.pocket.pocketHasBeenDyed", dyeColor));
EntityUtils.chat(entity, new TranslatableText("dimdoors.pocket.pocketHasBeenDyed", dyeColor));
return true;
} else {
count++;
entity.sendMessage(new TranslatableText("dimdoors.pocket.remainingNeededDyes", count, maxDye, color));
EntityUtils.chat(entity, new TranslatableText("dimdoors.pocket.remainingNeededDyes", count, maxDye, color));
return true;
}
} else {
this.nextDyeColor = color;
count = 1;
entity.sendMessage(new TranslatableText("dimdoors.pocket.remainingNeededDyes", count, maxDye, color));
EntityUtils.chat(entity, new TranslatableText("dimdoors.pocket.remainingNeededDyes", count, maxDye, color));
return true;
}
}

View file

@ -4,10 +4,10 @@ import net.minecraft.nbt.CompoundTag;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.PersistentState;
import net.minecraft.world.World;
import org.dimdev.annotatednbt.AnnotatedNbt;
import org.dimdev.annotatednbt.Saved;
import org.dimdev.dimdoors.ModConfig;
import org.dimdev.dimdoors.world.ModDimensions;
import org.dimdev.util.math.GridUtil;
import java.util.HashMap;
@ -49,7 +49,7 @@ public class PocketRegistry extends PersistentState {
}
public static PocketRegistry instance(ServerWorld world) {
if (!(world.dimension instanceof PocketWorldDimension)) {
if (!(ModDimensions.isDimDoorsPocketDimension(world))) {
throw new UnsupportedOperationException("PocketRegistry is only available for pocket dimensions!");
}

View file

@ -1,66 +0,0 @@
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

@ -7,12 +7,13 @@ import net.minecraft.server.MinecraftServer;
import net.minecraft.server.world.ServerWorld;
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 java.util.UUID;
import static net.minecraft.world.World.OVERWORLD;
public class PrivatePocketData extends PersistentState {
protected static class PocketInfo {
@Saved public final ServerWorld world;
@ -40,7 +41,7 @@ public class PrivatePocketData extends PersistentState {
}
private static PrivatePocketData instance(MinecraftServer server) {
return server.getWorld(DimensionType.OVERWORLD).getPersistentStateManager().getOrCreate(PrivatePocketData::new, DATA_NAME);
return server.getWorld(OVERWORLD).getPersistentStateManager().getOrCreate(PrivatePocketData::new, DATA_NAME);
}
@Override

View file

@ -4,14 +4,14 @@ import net.minecraft.nbt.CompoundTag;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.Heightmap;
import net.minecraft.world.World;
import net.minecraft.world.dimension.DimensionType;
import org.dimdev.annotatednbt.AnnotatedNbt;
import org.dimdev.annotatednbt.Saved;
import org.dimdev.dimdoors.ModConfig;
import org.dimdev.dimdoors.world.limbo.LimboDimension;
import org.dimdev.dimdoors.world.ModDimensions;
import org.dimdev.util.Location;
import static net.minecraft.world.World.OVERWORLD;
public class VirtualLocation {
@Saved public final ServerWorld world;
@Saved public final int x;
@ -37,19 +37,19 @@ public class VirtualLocation {
public static VirtualLocation fromLocation(Location location) {
VirtualLocation virtualLocation = null;
if (location.world.dimension instanceof PocketWorldDimension) {
if (ModDimensions.isDimDoorsPocketDimension(location.world)) {
Pocket pocket = PocketRegistry.instance(location.world).getPocketAt(location.pos);
if (pocket != null) {
virtualLocation = pocket.virtualLocation; // TODO: pockets-relative coordinates
} else {
virtualLocation = null; // TODO: door was placed in a pockets dim but outside of a pockets...
}
} else if (location.world.dimension instanceof LimboDimension) { // TODO: convert to interface on worldprovider
} else if (ModDimensions.isLimboDimension(location.world)) { // TODO: convert to interface on worldprovider
virtualLocation = new VirtualLocation(location.world, location.getX(), location.getZ(), ModConfig.DUNGEONS.maxDungeonDepth);
} // TODO: nether coordinate transform
if (virtualLocation == null) {
return new VirtualLocation(location.world.getServer().getWorld(DimensionType.OVERWORLD), location.getX(), location.getZ(), 5);
return new VirtualLocation(location.world.getServer().getWorld(OVERWORLD), location.getX(), location.getZ(), 5);
}
return virtualLocation;
@ -58,8 +58,8 @@ public class VirtualLocation {
public Location projectToWorld(boolean acceptLimbo) {
ServerWorld world = this.world;
if (!acceptLimbo && world.dimension instanceof LimboDimension) {
world = world.getServer().getWorld(DimensionType.OVERWORLD);
if (!acceptLimbo && ModDimensions.isLimboDimension(world)) {
world = world.getServer().getWorld(OVERWORLD);
}
float spread = ModConfig.GENERAL.depthSpreadFactor * depth;

View file

@ -5,16 +5,17 @@ import net.minecraft.entity.ItemEntity;
import net.minecraft.entity.mob.MobEntity;
import net.minecraft.entity.passive.TameableEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.projectile.*;
import net.minecraft.entity.thrown.ThrownEntity;
import net.minecraft.entity.projectile.FishingBobberEntity;
import net.minecraft.entity.projectile.ProjectileEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.text.Text;
public final class EntityUtils {
public static Entity getOwner(Entity entity) {
Entity topmostEntity = null;
// Thrower
if (entity instanceof Projectile) topmostEntity = ((Projectile) entity).getOwner();
if (entity instanceof ProjectileEntity) topmostEntity = ((ProjectileEntity) entity).getOwner();
if (entity instanceof FishingBobberEntity) topmostEntity = ((FishingBobberEntity) entity).getOwner();
if (entity instanceof ItemEntity) topmostEntity = ((ServerWorld) entity.getEntityWorld()).getEntity(((ItemEntity) entity).getThrower());
@ -32,4 +33,12 @@ public final class EntityUtils {
return entity;
}
public static void chat(Entity entity, Text text, boolean actionBar) {
if(entity instanceof PlayerEntity) ((PlayerEntity) entity).sendMessage(text, actionBar);
}
public static void chat(Entity entity, Text text) {
chat(entity, text, false);
}
}

View file

@ -4,15 +4,12 @@ import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.fluid.FluidState;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.registry.RegistryKey;
import net.minecraft.world.World;
import net.minecraft.world.dimension.DimensionType;
import org.dimdev.annotatednbt.AutoSerializable;
import org.dimdev.annotatednbt.Saved;
import java.io.Serializable;
public class Location implements AutoSerializable {
@Saved public final ServerWorld world;
@Saved public final BlockPos pos;
@ -66,7 +63,7 @@ public class Location implements AutoSerializable {
return world.hashCode() * 31 + pos.hashCode();
}
public Identifier getWorldId() {
return DimensionType.getId(world.dimension.getType());
public RegistryKey<World> getWorldId() {
return world.getRegistryKey();
}
}

View file

@ -1,34 +1,27 @@
package org.dimdev.util;
import com.mojang.datafixers.DataFixerUpper;
import com.mojang.datafixers.Dynamic;
import net.fabricmc.fabric.api.dimension.v1.FabricDimensions;
import net.minecraft.block.pattern.BlockPattern;
import net.minecraft.datafixer.NbtOps;
import net.minecraft.entity.Entity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos;
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, World world, BlockPos pos, int yawOffset) {
teleport(entity, world, Vec3d.method_24955(pos), yawOffset);
teleport(entity, world, Vec3d.ofBottomCenter(pos), yawOffset);
}
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, DimensionType dimension, Vec3d pos, float yawOffset) {
if (entity.dimension == dimension) {
if (entity.world.getRegistryKey().equals(world.getRegistryKey())) {
entity.setPos(pos.x, pos.y, pos.z);
entity.setYaw(entity.yaw + yawOffset);
} else {
FabricDimensions.teleport(
entity,
dimension,
(ServerWorld) world,
(e, serverWorld, direction, v, v1) -> new BlockPattern.TeleportTarget(pos, e.getVelocity(), (int) (e.yaw + yawOffset))
);

View file

@ -22,7 +22,7 @@ public class SchematicConverter {
public static void reloadConversions() {
CONVERSIONS.clear();
SeparateClassToAvoidIdeaLag.a();
//SeparateClassToAvoidIdeaLag.a();
CONVERSIONS.put("minecraft:double_stone_slab[variant=stone_brick]", "minecraft:brick_slab[type=double]");
CONVERSIONS.put("minecraft:double_stone_slab", "minecraft:stone_slab[type=double]");
CONVERSIONS.put("minecraft:double_stone_slab[seamless=true]", "minecraft:smooth_stone");

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,10 @@
{
"generator": {
"type": "dimdoors:void",
"biome_source": {
"type": "minecraft:fixed",
"biome": "dimdoors:dangerous_black_void"
}
},
"type": "dimdoors:void"
}

View file

@ -0,0 +1,10 @@
{
"generator": {
"type": "dimdoors:blank",
"biome_source": {
"type": "minecraft:fixed",
"biome": "dimdoors:black_void"
}
},
"type": "dimdoors:void"
}

View file

@ -0,0 +1,10 @@
{
"generator": {
"type": "dimdoors:void",
"biome_source": {
"type": "minecraft:fixed",
"biome": "dimdoors:white_void"
}
},
"type": "dimdoors:void"
}

View file

@ -0,0 +1,10 @@
{
"generator": {
"type": "dimdoors:void",
"biome_source": {
"type": "minecraft:fixed",
"biome": "dimdoors:black_void"
}
},
"type": "dimdoors:void"
}

View file

@ -0,0 +1,14 @@
{
"ultrawarm": false,
"natural": false,
"shrunk": false,
"ambient_light": 0.1,
"has_skylight": true,
"has_ceiling": false,
"infiniburn": "minecraft:infiniburn_overworld",
"logical_height" : 256,
"has_raids" : false,
"respawn_anchor_works": false,
"bed_works" : false,
"piglin_safe" : false
}