Merge pull request #364 from StevenRS11/1.20.1-multiplatform

Various Fixes
This commit is contained in:
Waterpicker 2023-11-05 00:32:50 -05:00 committed by GitHub
commit fe451f8532
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 135 additions and 46 deletions

View file

@ -93,7 +93,7 @@ public final class ModConfig implements ConfigData {
public static class General {
@Tooltip public double teleportOffset = 0;
@Tooltip public boolean riftBoundingBoxInCreative;
@Tooltip public double riftCloseSpeed = 0.01;
@Tooltip public double riftCloseSpeed = 0.1;
@Tooltip public double riftGrowthSpeed = 1;
@Tooltip public int depthSpreadFactor = 20;
@Tooltip public double endermanSpawnChance = 0.00005;

View file

@ -3,7 +3,8 @@ package org.dimdev.dimdoors.api.rift.target;
import net.minecraft.core.Rotations;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.phys.Vec3;
import org.dimdev.dimdoors.api.util.Location;
public interface EntityTarget extends Target {
boolean receiveEntity(Entity entity, Vec3 relativePos, Rotations relativeAngle, Vec3 relativeVelocity);
boolean receiveEntity(Entity entity, Vec3 relativePos, Rotations relativeAngle, Vec3 relativeVelocity, Location location);
}

View file

@ -27,7 +27,7 @@ public class EternalFluidBlock extends ArchitecturyLiquidBlock {
}
try {
if (TARGET.receiveEntity(entity, Vec3.ZERO, MathUtil.entityEulerAngle(entity), entity.getDeltaMovement())) {
if (TARGET.receiveEntity(entity, Vec3.ZERO, MathUtil.entityEulerAngle(entity), entity.getDeltaMovement(), null)) {
if (entity instanceof Player) {
LimboExitReason.ETERNAL_FLUID.broadcast((Player) entity);
}

View file

@ -15,8 +15,10 @@ import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.Vec3;
import org.dimdev.dimdoors.DimensionalDoors;
import org.dimdev.dimdoors.api.util.Location;
import org.dimdev.dimdoors.api.util.TeleportUtil;
import org.dimdev.dimdoors.block.ModBlocks;
import org.dimdev.dimdoors.client.RiftCurves;
public class DetachedRiftBlockEntity extends RiftBlockEntity {
private static final RandomSource random = RandomSource.create();
@ -25,6 +27,7 @@ public class DetachedRiftBlockEntity extends RiftBlockEntity {
public boolean stabilized = false;
public int spawnedEndermanId = 0;
public float size = 0;
public int curveID = 0;
private boolean unregisterDisabled = false;
@ -33,6 +36,7 @@ public class DetachedRiftBlockEntity extends RiftBlockEntity {
public DetachedRiftBlockEntity(BlockPos pos, BlockState state) {
super(ModBlockEntityTypes.DETACHED_RIFT.get(), pos, state);
this.curveID = (int) (Math.random()* RiftCurves.CURVES.size());
}
public static void tick(Level world, BlockPos pos, BlockState state, DetachedRiftBlockEntity blockEntity) {
@ -80,6 +84,10 @@ public class DetachedRiftBlockEntity extends RiftBlockEntity {
this.setChanged();
}
public int getCurveID() {
return this.curveID;
}
@Override
public CompoundTag serialize(CompoundTag nbt) {
super.serialize(nbt);
@ -87,6 +95,7 @@ public class DetachedRiftBlockEntity extends RiftBlockEntity {
nbt.putBoolean("stablized", this.stabilized);
nbt.putInt("spawnedEnderManId", this.spawnedEndermanId);
nbt.putFloat("size", this.size);
nbt.putInt("curveID", this.curveID);
return nbt;
}
@ -97,6 +106,7 @@ public class DetachedRiftBlockEntity extends RiftBlockEntity {
this.stabilized = nbt.getBoolean("stablized");
this.spawnedEndermanId = nbt.getInt("spawnedEnderManId");
this.size = nbt.getFloat("size");
this.curveID = nbt.getInt("curveID");
}
@Override
@ -112,7 +122,7 @@ public class DetachedRiftBlockEntity extends RiftBlockEntity {
}
@Override
public boolean receiveEntity(Entity entity, Vec3 relativePos, Rotations relativeAngle, Vec3 velocity) {
public boolean receiveEntity(Entity entity, Vec3 relativePos, Rotations relativeAngle, Vec3 velocity, Location location) {
if (this.level instanceof ServerLevel)
TeleportUtil.teleport(entity, this.level, this.worldPosition, relativeAngle, velocity);
return true;
@ -131,4 +141,13 @@ public class DetachedRiftBlockEntity extends RiftBlockEntity {
public void setLocked(boolean locked) {
// NO-OP
}
@Override
public CompoundTag getUpdateTag() {
CompoundTag tag = super.getUpdateTag();
tag.putFloat("size", this.size);
tag.putInt("curveID", this.curveID);
return tag;
}
}

View file

@ -21,6 +21,7 @@ import org.dimdev.dimdoors.DimensionalDoors;
import org.dimdev.dimdoors.api.client.DefaultTransformation;
import org.dimdev.dimdoors.api.client.Transformer;
import org.dimdev.dimdoors.api.util.EntityUtils;
import org.dimdev.dimdoors.api.util.Location;
import org.dimdev.dimdoors.api.util.TeleportUtil;
import org.dimdev.dimdoors.api.util.math.TransformationMatrix3d;
import org.dimdev.dimdoors.block.CoordinateTransformerBlock;
@ -86,7 +87,7 @@ public class EntranceRiftBlockEntity extends RiftBlockEntity {
}
@Override
public boolean receiveEntity(Entity entity, Vec3 relativePos, Rotations relativeAngle, Vec3 relativeVelocity) {
public boolean receiveEntity(Entity entity, Vec3 relativePos, Rotations relativeAngle, Vec3 relativeVelocity, Location location) {
BlockState state = this.getLevel().getBlockState(this.getBlockPos());
Block block = state.getBlock();
Vec3 targetPos = Vec3.atCenterOf(this.getBlockPos()).add(Vec3.atLowerCornerOf(this.getOrientation().getOpposite().getNormal()).scale(DimensionalDoors.getConfig().getGeneralConfig().teleportOffset + 0.01/* slight offset to prevent issues due to mathematical inaccuracies*/));
@ -111,11 +112,19 @@ public class EntranceRiftBlockEntity extends RiftBlockEntity {
TransformationMatrix3d.TransformationMatrix3dBuilder transformationBuilder = transformer.transformationBuilder(state, this.getBlockPos());
TransformationMatrix3d.TransformationMatrix3dBuilder rotatorBuilder = transformer.rotatorBuilder(state, this.getBlockPos());
targetPos = transformer.transformOut(transformationBuilder, relativePos);
//TODO:offset entity one block infront of door
relativeAngle = transformer.rotateOut(rotatorBuilder, relativeAngle);
relativeVelocity = transformer.rotateOut(rotatorBuilder, relativeVelocity);
}
// TODO: open door
Direction direction = getOrientation().getOpposite();
targetPos= targetPos.add((double) direction.getNormal().getX() /2, (double) direction.getNormal().getY() /2, (double) direction.getNormal().getZ() /2);
TeleportUtil.teleport(entity, this.level, targetPos, relativeAngle, relativeVelocity);

View file

@ -26,6 +26,7 @@ import org.dimdev.dimdoors.api.util.math.TransformationMatrix3d;
import org.dimdev.dimdoors.block.CoordinateTransformerBlock;
import org.dimdev.dimdoors.rift.registry.LinkProperties;
import org.dimdev.dimdoors.rift.registry.Rift;
import org.dimdev.dimdoors.rift.targets.LocationProvider;
import org.dimdev.dimdoors.rift.targets.MessageTarget;
import org.dimdev.dimdoors.rift.targets.Targets;
import org.dimdev.dimdoors.rift.targets.VirtualTarget;
@ -184,6 +185,9 @@ public abstract class RiftBlockEntity extends BlockEntity implements Target, Ent
Vec3 relativePos = new Vec3(0, 0, 0);
Rotations relativeAngle = new Rotations(entity.getXRot(), entity.getYRot(), 0);
Vec3 relativeVelocity = entity.getDeltaMovement();
var location = this.getTarget() instanceof LocationProvider provider ? provider.getLocation() : null;
EntityTarget target = this.getTarget().as(Targets.ENTITY);
BlockState state = this.getLevel().getBlockState(this.getBlockPos());
@ -197,7 +201,7 @@ public abstract class RiftBlockEntity extends BlockEntity implements Target, Ent
relativeVelocity = transformer.rotateTo(rotatorBuilder, relativeVelocity);
}
if (target.receiveEntity(entity, relativePos, relativeAngle, relativeVelocity)) {
if (target.receiveEntity(entity, relativePos, relativeAngle, relativeVelocity, location)) {
VirtualLocation vLoc = VirtualLocation.fromLocation(new Location((ServerLevel) entity.level(), entity.blockPosition()));
EntityUtils.chat(entity, Component.literal("You are at x = " + vLoc.getX() + ", y = ?, z = " + vLoc.getZ() + ", w = " + vLoc.getDepth()));
return true;

View file

@ -29,7 +29,7 @@ public class DetachedRiftBlockEntityRenderer implements BlockEntityRenderer<Deta
private static final RGBA DEFAULT_COLOR = new RGBA(1, 0.5f, 1, 1);
private static final Tesseract TESSERACT = new Tesseract();
private static final RiftCurves.PolygonInfo CURVE = RiftCurves.CURVES.get(0);
private static final RiftCurves.PolygonInfo CURVE = RiftCurves.CURVES.get(1);
@Override
public void render(DetachedRiftBlockEntity rift, float tickDelta, PoseStack matrices, MultiBufferSource vcs, int breakProgress, int alpha) {
@ -56,8 +56,8 @@ public class DetachedRiftBlockEntityRenderer implements BlockEntityRenderer<Deta
private void renderCrack(VertexConsumer vc, PoseStack matrices, DetachedRiftBlockEntity rift) {
matrices.pushPose();
matrices.translate(0.5, 0.5, 0.5);
RiftCrackRenderer.drawCrack(matrices.last().pose(), vc, 0, CURVE, DimensionalDoors.getConfig().getGraphicsConfig().riftSize * rift.size / 150, 0);//0xF1234568L * rift.hashCode());
matrices.translate(0.5, 1.5, 0.5);
RiftCrackRenderer.drawCrack(matrices.last().pose(), vc, 0, RiftCurves.CURVES.get(rift.getCurveID()), DimensionalDoors.getConfig().getGraphicsConfig().riftSize * rift.size / 150, 0);//0xF1234568L * rift.hashCode());
matrices.popPose();
}

View file

@ -17,11 +17,16 @@ import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.item.context.UseOnContext;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
import org.apache.commons.compress.compressors.lz77support.LZ77Compressor;
import org.dimdev.dimdoors.DimensionalDoors;
import org.dimdev.dimdoors.api.util.Location;
import org.dimdev.dimdoors.api.util.RotatedLocation;
import org.dimdev.dimdoors.block.DimensionalPortalBlock;
import org.dimdev.dimdoors.block.ModBlocks;
import org.dimdev.dimdoors.block.RiftProvider;
import org.dimdev.dimdoors.block.door.DimensionalDoorBlock;
import org.dimdev.dimdoors.block.entity.DetachedRiftBlockEntity;
import org.dimdev.dimdoors.block.entity.RiftBlockEntity;
import org.dimdev.dimdoors.client.ToolTipHelper;
import org.dimdev.dimdoors.rift.targets.RiftReference;
import org.dimdev.dimdoors.sound.ModSoundEvents;
@ -45,6 +50,7 @@ public class RiftSignatureItem extends Item {
public InteractionResult useOn(UseOnContext itemUsageContext) {
Player player = itemUsageContext.getPlayer();
Level world = itemUsageContext.getLevel();
// get block one block above the clicked block
BlockPos pos = itemUsageContext.getClickedPos();
InteractionHand hand = itemUsageContext.getHand();
BlockState state = world.getBlockState(pos);
@ -77,8 +83,14 @@ public class RiftSignatureItem extends Item {
player.displayClientMessage(Component.translatable(this.getDescriptionId() + ".stored"), true);
world.playSound(null, player.blockPosition(), ModSoundEvents.RIFT_START.get(), SoundSource.BLOCKS, 0.6f, 1);
} else {
RiftBlockEntity rift1;
RiftBlockEntity rift2;
// Place a rift at the saved point
if (target.getBlockState().getBlock() != ModBlocks.DETACHED_RIFT.get()) {
if (target.getBlockState().getBlock() instanceof RiftProvider<?> provider) {
rift1 = provider.getRift(target.getWorld(),target.pos,target.getBlockState());
} else {
if (!target.getBlockState().getBlock().isPossibleToRespawnInThis(state)) {
player.displayClientMessage(Component.translatable("tools.target_became_block"), true);
clearSource(stack); // TODO: But is this fair? It's a rather hidden way of unbinding your signature!
@ -86,16 +98,25 @@ public class RiftSignatureItem extends Item {
}
Level sourceWorld = DimensionalDoors.getWorld(target.world);
sourceWorld.setBlockAndUpdate(target.getBlockPos(), ModBlocks.DETACHED_RIFT.get().defaultBlockState());
DetachedRiftBlockEntity rift1 = (DetachedRiftBlockEntity) target.getBlockEntity();
rift1.setDestination(RiftReference.tryMakeRelative(target, new Location((ServerLevel) world, pos)));
rift1 = (DetachedRiftBlockEntity) target.getBlockEntity();
rift1.register();
}
rift1.setDestination(RiftReference.tryMakeRelative(target, new Location((ServerLevel) world, pos)));
if (world.getBlockState(pos).getBlock() instanceof RiftProvider<?> provider) {
rift2 = provider.getRift(world, pos, world.getBlockState(pos));
}
else{
pos = pos.above();
world.setBlockAndUpdate(pos, ModBlocks.DETACHED_RIFT.get().defaultBlockState());
rift2 = (DetachedRiftBlockEntity) world.getBlockEntity(pos);
rift2.register();
}
rift2.setDestination(RiftReference.tryMakeRelative(new Location((ServerLevel) world, pos), target));
// Place a rift at the target point
world.setBlockAndUpdate(pos, ModBlocks.DETACHED_RIFT.get().defaultBlockState());
DetachedRiftBlockEntity rift2 = (DetachedRiftBlockEntity) world.getBlockEntity(pos);
rift2.setDestination(RiftReference.tryMakeRelative(new Location((ServerLevel) world, pos), target));
rift2.register();
stack.hurtAndBreak(1, player, a -> {}); // TODO: calculate damage based on position?

View file

@ -40,7 +40,7 @@ public class EscapeTarget extends VirtualTarget implements EntityTarget { // TOD
}
@Override
public boolean receiveEntity(Entity entity, Vec3 relativePos, Rotations relativeAngle, Vec3 relativeVelocity) {
public boolean receiveEntity(Entity entity, Vec3 relativePos, Rotations relativeAngle, Vec3 relativeVelocity, Location location2) {
if (!ModDimensions.isPocketDimension(entity.level()) && !(ModDimensions.isLimboDimension(entity.level()))) {
chat(entity, Component.translatable("rifts.destinations.escape.not_in_pocket_dim"));
return false;

View file

@ -7,6 +7,7 @@ import net.minecraft.world.entity.Entity;
import net.minecraft.world.phys.Vec3;
import org.dimdev.dimdoors.api.rift.target.EntityTarget;
import org.dimdev.dimdoors.api.util.EntityUtils;
import org.dimdev.dimdoors.api.util.Location;
public class IdMarker extends VirtualTarget implements EntityTarget {
private final int id;
@ -40,7 +41,7 @@ public class IdMarker extends VirtualTarget implements EntityTarget {
}
@Override
public boolean receiveEntity(Entity entity, Vec3 relativePos, Rotations relativeAngle, Vec3 relativeVelocity) {
public boolean receiveEntity(Entity entity, Vec3 relativePos, Rotations relativeAngle, Vec3 relativeVelocity, Location location) {
EntityUtils.chat(entity, Component.literal("This rift is configured for pocket dungeons. Its id is " + this.id));
return false;
}

View file

@ -6,6 +6,7 @@ import net.minecraft.core.Rotations;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.phys.Vec3;
import org.dimdev.dimdoors.api.rift.target.EntityTarget;
import org.dimdev.dimdoors.api.util.Location;
import org.dimdev.dimdoors.api.util.TeleportUtil;
import org.dimdev.dimdoors.block.ModBlocks;
import org.dimdev.dimdoors.world.ModDimensions;
@ -19,7 +20,7 @@ public class LimboTarget extends VirtualTarget implements EntityTarget {
}
@Override
public boolean receiveEntity(Entity entity, Vec3 relativePos, Rotations relativeAngle, Vec3 relativeVelocity) {
public boolean receiveEntity(Entity entity, Vec3 relativePos, Rotations relativeAngle, Vec3 relativeVelocity, Location location) {
BlockPos teleportPos = entity.blockPosition();
while(ModDimensions.LIMBO_DIMENSION.getBlockState(VirtualLocation.getTopPos(ModDimensions.LIMBO_DIMENSION, teleportPos.getX(), teleportPos.getZ())).getBlock() == ModBlocks.ETERNAL_FLUID.get()) {
teleportPos = teleportPos.offset(1, 0, 1);

View file

@ -0,0 +1,8 @@
package org.dimdev.dimdoors.rift.targets;
import org.dimdev.dimdoors.api.util.Location;
public interface LocationProvider {
Location getLocation();
}

View file

@ -7,6 +7,7 @@ import net.minecraft.world.phys.Vec3;
import org.dimdev.dimdoors.api.rift.target.EntityTarget;
import org.dimdev.dimdoors.api.rift.target.Target;
import org.dimdev.dimdoors.api.util.EntityUtils;
import org.dimdev.dimdoors.api.util.Location;
public class MessageTarget implements EntityTarget {
private final Target forwardTo;
@ -24,11 +25,11 @@ public class MessageTarget implements EntityTarget {
}
@Override
public boolean receiveEntity(Entity entity, Vec3 relativePos, Rotations relativeAngle, Vec3 relativeVelocity) {
public boolean receiveEntity(Entity entity, Vec3 relativePos, Rotations relativeAngle, Vec3 relativeVelocity, Location location) {
EntityUtils.chat(entity, Component.translatable(this.message, this.messageParams));
if (this.forwardTo != null) {
this.forwardTo.as(Targets.ENTITY).receiveEntity(entity, relativePos, relativeAngle, relativeVelocity);
this.forwardTo.as(Targets.ENTITY).receiveEntity(entity, relativePos, relativeAngle, relativeVelocity, location);
return true;
} else {
return false;

View file

@ -8,6 +8,7 @@ import net.minecraft.world.phys.Vec3;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.dimdev.dimdoors.api.rift.target.EntityTarget;
import org.dimdev.dimdoors.api.util.EntityUtils;
import org.dimdev.dimdoors.api.util.Location;
public class PocketEntranceMarker extends VirtualTarget implements EntityTarget {
private final float weight;
@ -29,7 +30,7 @@ public class PocketEntranceMarker extends VirtualTarget implements EntityTarget
}
@Override
public boolean receiveEntity(Entity entity, Vec3 relativePos, Rotations relativeAngle, Vec3 relativeVelocity) {
public boolean receiveEntity(Entity entity, Vec3 relativePos, Rotations relativeAngle, Vec3 relativeVelocity, Location location) {
EntityUtils.chat(entity, Component.translatable("The entrance of this dungeon has not been converted. If this is a normally generated pocket, please report this bug."));
return false;
}

View file

@ -7,6 +7,7 @@ import net.minecraft.world.entity.Entity;
import net.minecraft.world.phys.Vec3;
import org.dimdev.dimdoors.api.rift.target.EntityTarget;
import org.dimdev.dimdoors.api.util.EntityUtils;
import org.dimdev.dimdoors.api.util.Location;
public class PocketExitMarker extends VirtualTarget implements EntityTarget {
public static final Codec<PocketExitMarker> CODEC = Codec.unit(PocketExitMarker::new);
@ -15,7 +16,7 @@ public class PocketExitMarker extends VirtualTarget implements EntityTarget {
}
@Override
public boolean receiveEntity(Entity entity, Vec3 relativePos, Rotations relativeAngle, Vec3 relativeVelocity) {
public boolean receiveEntity(Entity entity, Vec3 relativePos, Rotations relativeAngle, Vec3 relativeVelocity, Location location) {
EntityUtils.chat(entity, Component.literal("The exit of this dungeon has not been linked. If this is a normally generated pocket, please report this bug."));
return false;
}

View file

@ -23,7 +23,7 @@ public class PrivatePocketExitTarget extends VirtualTarget implements EntityTarg
}
@Override
public boolean receiveEntity(Entity entity, Vec3 relativePos, Rotations relativeAngle, Vec3 relativeVelocity) {
public boolean receiveEntity(Entity entity, Vec3 relativePos, Rotations relativeAngle, Vec3 relativeVelocity, Location location) {
Location destLoc;
// TODO: make this recursive
UUID uuid = EntityUtils.getOwner(entity).getUUID();
@ -40,11 +40,11 @@ public class PrivatePocketExitTarget extends VirtualTarget implements EntityTarg
EntityUtils.chat(entity, Component.translatable("rifts.destinations.private_pocket_exit.rift_has_closed"));
}
LimboTarget.INSTANCE.receiveEntity(entity, relativePos, relativeAngle, relativeVelocity);
LimboTarget.INSTANCE.receiveEntity(entity, relativePos, relativeAngle, relativeVelocity, location);
return false;
} else {
((EntityTarget) destLoc.getBlockEntity()).receiveEntity(entity, relativePos, relativeAngle, relativeVelocity);
((EntityTarget) destLoc.getBlockEntity()).receiveEntity(entity, relativePos, relativeAngle, relativeVelocity, location);
return true;
}
} else {

View file

@ -30,7 +30,7 @@ public class PrivatePocketTarget extends VirtualTarget implements EntityTarget {
}
@Override
public boolean receiveEntity(Entity entity, Vec3 relativePos, Rotations relativeAngle, Vec3 relativeVelocity) {
public boolean receiveEntity(Entity entity, Vec3 relativePos, Rotations relativeAngle, Vec3 relativeVelocity, Location location) {
UUID uuid = EntityUtils.getOwner(entity).getUUID();
VirtualLocation virtualLocation = VirtualLocation.fromLocation(this.location);
if (uuid != null) {
@ -75,13 +75,13 @@ public class PrivatePocketTarget extends VirtualTarget implements EntityTarget {
if (pocket.addDye(EntityUtils.getOwner(entity), ((DyeItem) item).getDyeColor())) {
entity.remove(Entity.RemovalReason.DISCARDED);
} else {
((EntityTarget) blockEntity).receiveEntity(entity, relativePos, relativeAngle, relativeVelocity);
((EntityTarget) blockEntity).receiveEntity(entity, relativePos, relativeAngle, relativeVelocity, null);
}
} else {
((EntityTarget) blockEntity).receiveEntity(entity, relativePos, relativeAngle, relativeVelocity);
((EntityTarget) blockEntity).receiveEntity(entity, relativePos, relativeAngle, relativeVelocity, null);
}
} else {
((EntityTarget) blockEntity).receiveEntity(entity, relativePos, relativeAngle, relativeVelocity);
((EntityTarget) blockEntity).receiveEntity(entity, relativePos, relativeAngle, relativeVelocity, null);
DimensionalRegistry.getRiftRegistry().setLastPrivatePocketExit(uuid, this.location);
}
}

View file

@ -17,7 +17,7 @@ import java.util.Set;
* such that when the target rift is gone, the destination is notified and invalidated
* (see shouldInvalidate)
*/
public abstract class RiftReference extends VirtualTarget {
public abstract class RiftReference extends VirtualTarget implements LocationProvider {
public RiftReference() {
}
@ -31,6 +31,11 @@ public abstract class RiftReference extends VirtualTarget {
}
}
@Override
public Location getLocation() {
return getReferencedLocation();
}
public static RiftReference tryMakeRelative(Location from, Location to) {
if (from.world != to.world) {
return new GlobalReference(to);

View file

@ -1,10 +1,16 @@
package org.dimdev.dimdoors.rift.targets;
import net.minecraft.core.Direction;
import net.minecraft.core.Rotations;
import net.minecraft.network.chat.Component;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.material.Fluid;
import net.minecraft.world.phys.Vec3;
import org.dimdev.dimdoors.api.rift.target.*;
import org.dimdev.dimdoors.api.util.EntityUtils;
import org.dimdev.dimdoors.api.util.Location;
import org.dimdev.dimdoors.api.util.TeleportUtil;
import org.dimdev.dimdoors.world.ModDimensions;
// A list of the default targets provided by dimcore. Add your own in ModTargets
public final class Targets {
@ -14,9 +20,19 @@ public final class Targets {
public static final Class<RedstoneTarget> REDSTONE = RedstoneTarget.class;
public static void registerDefaultTargets() {
DefaultTargets.registerDefaultTarget(ENTITY, (entity, relativePos, relativeRotation, relativeVelocity) -> {
DefaultTargets.registerDefaultTarget(ENTITY, new EntityTarget() {
@Override
public boolean receiveEntity(Entity entity, Vec3 relativePos, Rotations relativeRotation, Vec3 relativeVelocity, Location location) {
if(location != null){
TeleportUtil.teleport(entity, location.getWorld(), Vec3.upFromBottomCenterOf(location.pos,0.0), relativeRotation, relativeVelocity);
return true;
}
EntityUtils.chat(entity, Component.translatable("rifts.unlinked2"));
return false;
}
});
DefaultTargets.registerDefaultTarget(ITEM, stack -> false);

View file

@ -5,6 +5,7 @@ import net.minecraft.util.RandomSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.phys.Vec3;
import org.dimdev.dimdoors.api.rift.target.EntityTarget;
import org.dimdev.dimdoors.api.util.Location;
import java.util.Collections;
@ -22,7 +23,7 @@ public class UnstableTarget extends VirtualTarget implements EntityTarget {
}
@Override
public boolean receiveEntity(Entity entity, Vec3 relativePos, Rotations relativeAngle, Vec3 relativeVelocity) {
public boolean receiveEntity(Entity entity, Vec3 relativePos, Rotations relativeAngle, Vec3 relativeVelocity, Location location) {
if (RANDOM.nextBoolean()) {
return RandomTarget.builder()
.acceptedGroups(Collections.singleton(0))
@ -35,9 +36,9 @@ public class UnstableTarget extends VirtualTarget implements EntityTarget {
.newRiftWeight(1)
.build()
.as(Targets.ENTITY)
.receiveEntity(entity, relativePos, relativeAngle, relativeVelocity);
.receiveEntity(entity, relativePos, relativeAngle, relativeVelocity, location);
}
return LimboTarget.INSTANCE.receiveEntity(entity, relativePos, relativeAngle, relativeVelocity);
return LimboTarget.INSTANCE.receiveEntity(entity, relativePos, relativeAngle, relativeVelocity, location);
}
}