Remove some deprecation warnings

This commit is contained in:
Sollace 2023-08-04 18:29:06 +01:00
parent 7868db90b5
commit f16632e5fe
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB
3 changed files with 35 additions and 22 deletions

View file

@ -6,16 +6,14 @@ import com.minelittlepony.unicopia.ability.data.Hit;
import com.minelittlepony.unicopia.ability.data.Pos; import com.minelittlepony.unicopia.ability.data.Pos;
import com.minelittlepony.unicopia.ability.magic.Caster; import com.minelittlepony.unicopia.ability.magic.Caster;
import com.minelittlepony.unicopia.ability.magic.spell.effect.SpellType; import com.minelittlepony.unicopia.ability.magic.spell.effect.SpellType;
import com.minelittlepony.unicopia.block.state.StatePredicate;
import com.minelittlepony.unicopia.entity.Living; import com.minelittlepony.unicopia.entity.Living;
import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.particle.MagicParticleEffect; import com.minelittlepony.unicopia.particle.MagicParticleEffect;
import com.minelittlepony.unicopia.util.Trace; import com.minelittlepony.unicopia.util.Trace;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.FenceBlock; import net.minecraft.block.ShapeContext;
import net.minecraft.block.LeavesBlock;
import net.minecraft.block.WallBlock;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.predicate.entity.EntityPredicates; import net.minecraft.predicate.entity.EntityPredicates;
@ -24,6 +22,7 @@ import net.minecraft.text.Text;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.World; import net.minecraft.world.World;
/** /**
@ -158,12 +157,21 @@ public class UnicornTeleportAbility implements Ability<Pos> {
Living.transmitPassengers(mount); Living.transmitPassengers(mount);
} }
Vec3d offset = teleportee.getOriginVector().subtract(teleporter.getOriginVector()); Vec3d offset = teleportee.getOriginVector()
.subtract(teleporter.getOriginVector())
.add(
participant.getX() - Math.floor(participant.getX()),
0,
participant.getZ() - Math.floor(participant.getZ())
);
Vec3d dest = destination.vec().add(offset);
participant.teleport( participant.teleport(
destination.x + offset.x + (participant.getX() - Math.floor(participant.getX())), dest.x,
destination.y + offset.y, getTargetYPosition(participant.getEntityWorld(), BlockPos.ofFloored(dest), ShapeContext.of(participant)),
destination.z + offset.z + (participant.getZ() - Math.floor(participant.getZ()))); dest.z
);
teleporter.subtractEnergyCost(distance); teleporter.subtractEnergyCost(distance);
participant.fallDistance /= distance; participant.fallDistance /= distance;
@ -173,23 +181,22 @@ public class UnicornTeleportAbility implements Ability<Pos> {
private boolean enterable(World w, BlockPos pos) { private boolean enterable(World w, BlockPos pos) {
BlockState state = w.getBlockState(pos); BlockState state = w.getBlockState(pos);
return w.isAir(pos) || !state.isOpaque();
Block block = state.getBlock();
return w.isAir(pos)
|| !state.isOpaque()
|| (block instanceof LeavesBlock);
} }
private boolean exception(World w, BlockPos pos, PlayerEntity player) { private boolean exception(World w, BlockPos pos, PlayerEntity player) {
BlockState state = w.getBlockState(pos); BlockState state = w.getBlockState(pos);
VoxelShape shape;
Block c = state.getBlock();
return state.hasSolidTopSurface(w, pos, player) return state.hasSolidTopSurface(w, pos, player)
|| state.isLiquid() || StatePredicate.isFluid(state)
|| (c instanceof WallBlock) || (shape = state.getCollisionShape(w, pos, ShapeContext.of(player))).isEmpty()
|| (c instanceof FenceBlock) || shape.getBoundingBox().getYLength() > 1;
|| (c instanceof LeavesBlock); }
private double getTargetYPosition(World world, BlockPos pos, ShapeContext context) {
VoxelShape shape = world.getBlockState(pos).getCollisionShape(world, pos, context);
return pos.getY() + (shape.isEmpty() ? 0 : shape.getBoundingBox().getYLength());
} }
@Override @Override

View file

@ -124,11 +124,16 @@ public abstract class StatePredicate implements Predicate<BlockState> {
} }
static boolean isWater(BlockState s) { static boolean isWater(BlockState s) {
return s.isLiquid() && s.getFluidState().isIn(FluidTags.WATER); return isFluid(s) && s.getFluidState().isIn(FluidTags.WATER);
} }
static boolean isLava(BlockState s) { static boolean isLava(BlockState s) {
return s.isLiquid() && s.getFluidState().isIn(FluidTags.LAVA); return isFluid(s) && s.getFluidState().isIn(FluidTags.LAVA);
}
@SuppressWarnings("deprecation")
public static boolean isFluid(BlockState s) {
return s.isLiquid();
} }
public static Predicate<BlockState> ofState(String state) { public static Predicate<BlockState> ofState(String state) {

View file

@ -15,6 +15,7 @@ import com.minelittlepony.unicopia.ability.magic.SpellContainer;
import com.minelittlepony.unicopia.ability.magic.SpellContainer.Operation; import com.minelittlepony.unicopia.ability.magic.SpellContainer.Operation;
import com.minelittlepony.unicopia.ability.magic.spell.Situation; import com.minelittlepony.unicopia.ability.magic.spell.Situation;
import com.minelittlepony.unicopia.ability.magic.spell.Spell; import com.minelittlepony.unicopia.ability.magic.spell.Spell;
import com.minelittlepony.unicopia.block.state.StatePredicate;
import com.minelittlepony.unicopia.entity.EntityPhysics; import com.minelittlepony.unicopia.entity.EntityPhysics;
import com.minelittlepony.unicopia.entity.EntityReference; import com.minelittlepony.unicopia.entity.EntityReference;
import com.minelittlepony.unicopia.entity.Physics; import com.minelittlepony.unicopia.entity.Physics;
@ -183,7 +184,7 @@ public class MagicProjectileEntity extends ThrownItemEntity implements Caster<Ma
getSpellSlot().get(true).filter(spell -> spell.tick(this, Situation.PROJECTILE)); getSpellSlot().get(true).filter(spell -> spell.tick(this, Situation.PROJECTILE));
if (getHydrophobic()) { if (getHydrophobic()) {
if (getWorld().getBlockState(getBlockPos()).isLiquid()) { if (StatePredicate.isFluid(getWorld().getBlockState(getBlockPos()))) {
Vec3d vel = getVelocity(); Vec3d vel = getVelocity();
double velY = vel.y; double velY = vel.y;