Add archivist's eyeglass and spectral tether, plus some improvements to teleportation

This commit is contained in:
Electroblob77
2020-06-23 22:09:06 +01:00
parent 0ca86eb01b
commit 33c5f79ed7
16 changed files with 224 additions and 103 deletions
@@ -174,10 +174,11 @@ public class BlockTransportationStone extends Block {
return false;
}
/** Returns whether the specified location is surrounded by a complete cicle of 8 transportation stones. */
/** Returns whether the specified location is surrounded by a complete circle of 8 transportation stones. */
public static boolean testForCircle(World world, BlockPos pos){
if(world.getBlockState(pos).getMaterial().blocksMovement()) return false;
if(world.getBlockState(pos).getMaterial().blocksMovement() || world.getBlockState(pos.up()).getMaterial()
.blocksMovement()) return false;
for(int x = -1; x <= 1; x++){
for(int z = -1; z <= 1; z++){
@@ -549,36 +549,38 @@ public class ClientProxy extends CommonProxy {
public void handleTransportationPacket(PacketTransportation.Message message){
World world = Minecraft.getMinecraft().world;
Entity caster = world.getEntityByID(message.casterID);
BlockPos pos = message.destination;
if(caster == null) return; // Shouldn't happen
Entity entity = world.getEntityByID(message.dismountEntityID);
if(message.dismountEntityID != -1 && entity != null) entity.dismountRidingEntity();
// Moved from when the packet is sent to when it is received; fixes the sound not playing in first person.
caster.playSound(WizardrySounds.SPELL_TRANSPORTATION_TRAVEL, 1, 1);
// Changed to a position to avoid syncing issues
world.playSound(pos.getX(), pos.getY(), pos.getZ(), WizardrySounds.SPELL_TRANSPORTATION_TRAVEL, WizardrySounds.SPELLS, 1, 1, false);
for(int i = 0; i < 20; i++){
double radius = 1;
float angle = world.rand.nextFloat() * (float)Math.PI * 2;
double x = caster.posX + radius * MathHelper.cos(angle);
double y = caster.getEntityBoundingBox().minY + world.rand.nextDouble() * 2;
double z = caster.posZ + radius * MathHelper.sin(angle);
double x = pos.getX() + 0.5 + radius * MathHelper.cos(angle);
double y = pos.getY() + world.rand.nextDouble() * 2;
double z = pos.getZ() + 0.5 + radius * MathHelper.sin(angle);
ParticleBuilder.create(Type.SPARKLE).pos(x, y, z).vel(0, 0.02, 0).clr(0.6f, 1, 0.6f)
.time(80 + world.rand.nextInt(10)).spawn(world);
}
for(int i = 0; i < 20; i++){
double radius = 1;
float angle = world.rand.nextFloat() * (float)Math.PI * 2;
double x = caster.posX + radius * MathHelper.cos(angle);
double y = caster.getEntityBoundingBox().minY + world.rand.nextDouble() * 2;
double z = caster.posZ + radius * MathHelper.sin(angle);
double x = pos.getX() + 0.5 + radius * MathHelper.cos(angle);
double y = pos.getY() + world.rand.nextDouble() * 2;
double z = pos.getZ() + 0.5 + radius * MathHelper.sin(angle);
world.spawnParticle(EnumParticleTypes.VILLAGER_HAPPY, x, y, z, 0, 0.02, 0);
}
for(int i = 0; i < 20; i++){
double radius = 1;
float angle = world.rand.nextFloat() * (float)Math.PI * 2;
double x = caster.posX + radius * MathHelper.cos(angle);
double y = caster.getEntityBoundingBox().minY + world.rand.nextDouble() * 2;
double z = caster.posZ + radius * MathHelper.sin(angle);
double x = pos.getX() + 0.5 + radius * MathHelper.cos(angle);
double y = pos.getY() + world.rand.nextDouble() * 2;
double z = pos.getZ() + 0.5 + radius * MathHelper.sin(angle);
world.spawnParticle(EnumParticleTypes.ENCHANTMENT_TABLE, x, y, z, 0, 0.02, 0);
}
}
@@ -282,6 +282,7 @@ public final class WizardryModels {
registerItemModel(WizardryItems.charm_haggler);
registerItemModel(WizardryItems.charm_experience_tome);
registerItemModel(WizardryItems.charm_move_speed);
registerItemModel(WizardryItems.charm_spell_discovery);
registerItemModel(WizardryItems.charm_auto_smelt);
registerItemModel(WizardryItems.charm_lava_walking);
registerItemModel(WizardryItems.charm_storm);
@@ -295,6 +296,7 @@ public final class WizardryModels {
registerItemModel(WizardryItems.charm_light);
registerItemModel(WizardryItems.charm_transportation);
registerItemModel(WizardryItems.charm_black_hole);
registerItemModel(WizardryItems.charm_mount_teleporting);
registerItemModel(WizardryItems.charm_feeding);
}
@@ -5,9 +5,11 @@ import electroblob.wizardry.Wizardry;
import electroblob.wizardry.constants.Element;
import electroblob.wizardry.constants.Tier;
import electroblob.wizardry.data.WizardData;
import electroblob.wizardry.item.ItemArtefact;
import electroblob.wizardry.item.ItemScroll;
import electroblob.wizardry.item.ItemSpellBook;
import electroblob.wizardry.registry.Spells;
import electroblob.wizardry.registry.WizardryItems;
import electroblob.wizardry.spell.Spell;
import electroblob.wizardry.util.SpellProperties;
import net.minecraft.entity.player.EntityPlayer;
@@ -150,8 +152,12 @@ public class RandomSpell extends LootFunction {
possibleSpells.removeIf(s -> s.getElement() != element);
if(possibleSpells.isEmpty()) return Spells.none; // If it fails anywhere, it'll most likely be here
float bias = undiscoveredBias;
// Archivist's eyeglass increases undiscovered bias by 0.4 up to a maximum of 0.9
if(ItemArtefact.isArtefactActive(player, WizardryItems.charm_spell_discovery)) bias = Math.min(bias + 0.4f, 0.9f);
// Remove either the undiscovered spells or the discovered ones, depending on the bias
if(undiscoveredBias > 0 && player != null){
if(bias > 0 && player != null){
WizardData data = WizardData.get(player);
@@ -159,7 +165,7 @@ public class RandomSpell extends LootFunction {
// If none have been discovered or they've all been discovered, don't bother!
if(discoveredCount > 0 && discoveredCount < possibleSpells.size()){
// Kinda unintuitive but it's very neat!
boolean keepDiscovered = random.nextFloat() < 0.5f + 0.5f * undiscoveredBias;
boolean keepDiscovered = random.nextFloat() < 0.5f + 0.5f * bias;
possibleSpells.removeIf(s -> keepDiscovered != data.hasSpellBeenDiscovered(s));
}
}
@@ -3,10 +3,14 @@ package electroblob.wizardry.packet;
import electroblob.wizardry.Wizardry;
import electroblob.wizardry.packet.PacketTransportation.Message;
import io.netty.buffer.ByteBuf;
import net.minecraft.entity.Entity;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
import javax.annotation.Nullable;
/**
* <b>[Server -> Client]</b> This packet is sent when a player is teleported due to the transportation spell to spawn
* the particles.
@@ -26,26 +30,31 @@ public class PacketTransportation implements IMessageHandler<Message, IMessage>
}
public static class Message implements IMessage {
/** EntityID of the caster */
public int casterID;
/** The destination that was teleported to */
public BlockPos destination;
public int dismountEntityID;
// This constructor is required otherwise you'll get errors (used somewhere in fml through reflection)
public Message(){
}
public Message(int casterID){
this.casterID = casterID;
public Message(BlockPos destination, @Nullable Entity toDismount){
this.destination = destination;
this.dismountEntityID = toDismount == null ? -1 : toDismount.getEntityId();
}
@Override
public void fromBytes(ByteBuf buf){
// The order is important
this.casterID = buf.readInt();
this.destination = BlockPos.fromLong(buf.readLong());
this.dismountEntityID = buf.readInt();
}
@Override
public void toBytes(ByteBuf buf){
buf.writeInt(casterID);
buf.writeLong(destination.toLong());
buf.writeInt(dismountEntityID);
}
}
}
@@ -266,6 +266,7 @@ public final class WizardryItems {
public static final Item charm_haggler = placeholder();
public static final Item charm_experience_tome = placeholder();
public static final Item charm_move_speed = placeholder();
public static final Item charm_spell_discovery = placeholder();
public static final Item charm_auto_smelt = placeholder();
public static final Item charm_lava_walking = placeholder();
public static final Item charm_storm = placeholder();
@@ -279,6 +280,7 @@ public final class WizardryItems {
public static final Item charm_light = placeholder();
public static final Item charm_transportation = placeholder();
public static final Item charm_black_hole = placeholder();
public static final Item charm_mount_teleporting = placeholder();
public static final Item charm_feeding = placeholder();
private static final Map<Pair<Tier, Element>, Item> WAND_MAP = new HashMap<>();
@@ -627,6 +629,7 @@ public final class WizardryItems {
registerItem(registry, "charm_haggler", new ItemArtefact(EnumRarity.RARE, ItemArtefact.Type.CHARM));
registerItem(registry, "charm_experience_tome", new ItemArtefact(EnumRarity.EPIC, ItemArtefact.Type.CHARM));
registerItem(registry, "charm_move_speed", new ItemArtefact(EnumRarity.RARE, ItemArtefact.Type.CHARM));
registerItem(registry, "charm_spell_discovery", new ItemArtefact(EnumRarity.UNCOMMON, ItemArtefact.Type.CHARM));
registerItem(registry, "charm_auto_smelt", new ItemArtefact(EnumRarity.RARE, ItemArtefact.Type.CHARM));
registerItem(registry, "charm_lava_walking", new ItemArtefact(EnumRarity.EPIC, ItemArtefact.Type.CHARM));
registerItem(registry, "charm_storm", new ItemArtefact(EnumRarity.RARE, ItemArtefact.Type.CHARM));
@@ -640,6 +643,7 @@ public final class WizardryItems {
registerItem(registry, "charm_light", new ItemArtefact(EnumRarity.RARE, ItemArtefact.Type.CHARM));
registerItem(registry, "charm_transportation", new ItemArtefact(EnumRarity.RARE, ItemArtefact.Type.CHARM));
registerItem(registry, "charm_black_hole", new ItemArtefact(EnumRarity.EPIC, ItemArtefact.Type.CHARM));
registerItem(registry, "charm_mount_teleporting", new ItemArtefact(EnumRarity.RARE, ItemArtefact.Type.CHARM));
registerItem(registry, "charm_feeding", new ItemArtefact(EnumRarity.UNCOMMON, ItemArtefact.Type.CHARM));
}
@@ -1,13 +1,14 @@
package electroblob.wizardry.spell;
import electroblob.wizardry.Wizardry;
import electroblob.wizardry.item.ItemArtefact;
import electroblob.wizardry.item.SpellActions;
import electroblob.wizardry.registry.WizardryItems;
import electroblob.wizardry.util.BlockUtils;
import electroblob.wizardry.util.RayTracer;
import electroblob.wizardry.util.SpellModifiers;
import electroblob.wizardry.util.*;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityBoat;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
@@ -15,6 +16,7 @@ import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
public class Blink extends Spell {
@@ -27,8 +29,12 @@ public class Blink extends Spell {
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
RayTraceResult rayTrace = RayTracer.standardBlockRayTrace(world, caster,
getProperty(RANGE).doubleValue() * modifiers.get(WizardryItems.range_upgrade), false);
boolean teleportMount = caster.isRiding() && ItemArtefact.isArtefactActive(caster, WizardryItems.charm_mount_teleporting);
boolean hitLiquids = teleportMount && caster.getRidingEntity() instanceof EntityBoat; // Boats teleport to the surface
double range = getProperty(RANGE).floatValue() * modifiers.get(WizardryItems.range_upgrade);
RayTraceResult rayTrace = RayTracer.standardBlockRayTrace(world, caster, range, hitLiquids, !hitLiquids,false);
// It's worth noting that on the client side, the cast() method only gets called if the server side
// cast method succeeded, so you need not check any conditions for spawning particles.
@@ -48,32 +54,21 @@ public class Blink extends Spell {
if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.BLOCK){
BlockPos pos = rayTrace.getBlockPos();
BlockPos pos = rayTrace.getBlockPos().offset(rayTrace.sideHit);
Entity toTeleport = teleportMount ? caster.getRidingEntity() : caster;
// Leave space for the player's head
if(rayTrace.sideHit == EnumFacing.DOWN) pos = pos.down();
Vec3d vec = EntityUtils.findSpaceForTeleport(toTeleport, GeometryUtils.getFaceCentre(pos, EnumFacing.DOWN), teleportMount);
// This means stuff like snow layers is ignored, meaning when on snow-covered ground the player does
// not teleport 1 block above the ground.
if(rayTrace.sideHit == EnumFacing.UP && !world.getBlockState(pos).getMaterial().blocksMovement()){
pos = pos.down();
if(vec != null){
// Plays before and after so it is heard from both positions
this.playSound(world, caster, ticksInUse, -1, modifiers);
if(!teleportMount && caster.isRiding()) caster.dismountRidingEntity();
if(!world.isRemote) toTeleport.setPositionAndUpdate(vec.x, vec.y, vec.z);
this.playSound(world, caster, ticksInUse, -1, modifiers);
return true;
}
pos = pos.offset(rayTrace.sideHit);
// Prevents the player from teleporting into blocks and suffocating.
if(world.getBlockState(pos).getMaterial().blocksMovement()
|| world.getBlockState(pos.up()).getMaterial().blocksMovement()){
return false;
}
// Plays before and after so it is heard from both positions
this.playSound(world, caster, ticksInUse, -1, modifiers);
if(!world.isRemote) caster.setPositionAndUpdate(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5);
this.playSound(world, caster, ticksInUse, -1, modifiers);
return true;
}
return false;
@@ -2,11 +2,12 @@ package electroblob.wizardry.spell;
import electroblob.wizardry.Wizardry;
import electroblob.wizardry.constants.Constants;
import electroblob.wizardry.item.ItemArtefact;
import electroblob.wizardry.item.SpellActions;
import electroblob.wizardry.registry.WizardryItems;
import electroblob.wizardry.util.BlockUtils;
import electroblob.wizardry.util.RayTracer;
import electroblob.wizardry.util.SpellModifiers;
import electroblob.wizardry.util.*;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityBoat;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
@@ -28,8 +29,12 @@ public class PhaseStep extends Spell {
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
boolean teleportMount = caster.isRiding() && ItemArtefact.isArtefactActive(caster, WizardryItems.charm_mount_teleporting);
boolean hitLiquids = teleportMount && caster.getRidingEntity() instanceof EntityBoat; // Boats teleport to the surface
double range = getProperty(RANGE).floatValue() * modifiers.get(WizardryItems.range_upgrade);
RayTraceResult rayTrace = RayTracer.standardBlockRayTrace(world, caster, range, false);
RayTraceResult rayTrace = RayTracer.standardBlockRayTrace(world, caster, range, hitLiquids, !hitLiquids, false);
// This is here because the conditions are false on the client for whatever reason. (see the Javadoc for cast()
// for an explanation)
@@ -46,6 +51,8 @@ public class PhaseStep extends Spell {
Wizardry.proxy.playBlinkEffect(caster);
}
Entity toTeleport = teleportMount ? caster.getRidingEntity() : caster;
if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.BLOCK){
BlockPos pos = rayTrace.getBlockPos();
@@ -68,66 +75,40 @@ public class PhaseStep extends Spell {
&& !Wizardry.settings.teleportThroughUnbreakableBlocks)
break; // Don't return false yet, there are other possible outcomes below now
if(!world.getBlockState(pos1).getMaterial().blocksMovement()
&& !world.getBlockState(pos1.up()).getMaterial().blocksMovement()){
// Plays before and after so it is heard from both positions
this.playSound(world, caster, ticksInUse, -1, modifiers);
if(!world.isRemote){
caster.setPositionAndUpdate(pos1.getX() + 0.5, pos1.getY() + 0.5, pos1.getZ() + 0.5);
}
this.playSound(world, caster, ticksInUse, -1, modifiers);
return true;
}
Vec3d vec = GeometryUtils.getFaceCentre(pos1, EnumFacing.DOWN);
if(attemptTeleport(world, toTeleport, vec, teleportMount, caster, ticksInUse, modifiers)) return true;
}
// If no suitable position was found on the other side of the wall, works like blink instead
// Leave space for the player's head
if(rayTrace.sideHit == EnumFacing.DOWN) pos = pos.down();
// This means stuff like snow layers is ignored, meaning when on snow-covered ground the player does
// not teleport 1 block above the ground.
if(rayTrace.sideHit == EnumFacing.UP && !world.getBlockState(pos).getMaterial().blocksMovement()){
pos = pos.down();
}
pos = pos.offset(rayTrace.sideHit);
// Prevents the player from teleporting into blocks and suffocating
if(world.getBlockState(pos).getMaterial().blocksMovement()
|| world.getBlockState(pos.up()).getMaterial().blocksMovement()){
return false;
}
Vec3d vec = GeometryUtils.getFaceCentre(pos, EnumFacing.DOWN);
if(attemptTeleport(world, toTeleport, vec, teleportMount, caster, ticksInUse, modifiers)) return true;
}else{ // The ray trace missed
Vec3d vec = caster.getPositionVector().add(caster.getLookVec().scale(range));
if(attemptTeleport(world, toTeleport, vec, teleportMount, caster, ticksInUse, modifiers)) return true;
}
return false;
}
protected boolean attemptTeleport(World world, Entity toTeleport, Vec3d destination, boolean teleportMount, EntityPlayer caster, int ticksInUse, SpellModifiers modifiers){
destination = EntityUtils.findSpaceForTeleport(toTeleport, destination, teleportMount);
if(destination != null){
// Plays before and after so it is heard from both positions
this.playSound(world, caster, ticksInUse, -1, modifiers);
if(!world.isRemote) caster.setPositionAndUpdate(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5);
if(!teleportMount && caster.isRiding()) caster.dismountRidingEntity();
if(!world.isRemote) toTeleport.setPositionAndUpdate(destination.x, destination.y, destination.z);
this.playSound(world, caster, ticksInUse, -1, modifiers);
caster.swingArm(hand);
return true;
}else{ // The ray trace missed
Vec3d destination = caster.getPositionVector().add(caster.getLookVec().scale(range));
BlockPos pos = new BlockPos(destination);
// Prevents the player from teleporting into blocks and suffocating.
if(world.getBlockState(pos).getMaterial().blocksMovement()
|| world.getBlockState(pos.up()).getMaterial().blocksMovement()){
return false;
}
if(!world.isRemote) caster.setPositionAndUpdate(destination.x, destination.y, destination.z);
this.playSound(world, caster, ticksInUse, -1, modifiers);
caster.swingArm(hand);
return true;
}
return false;
}
}
@@ -9,7 +9,11 @@ import electroblob.wizardry.item.SpellActions;
import electroblob.wizardry.packet.PacketTransportation;
import electroblob.wizardry.packet.WizardryPacketHandler;
import electroblob.wizardry.registry.WizardryItems;
import electroblob.wizardry.util.*;
import electroblob.wizardry.util.GeometryUtils;
import electroblob.wizardry.util.Location;
import electroblob.wizardry.util.NBTExtras;
import electroblob.wizardry.util.SpellModifiers;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.MobEffects;
import net.minecraft.nbt.NBTTagList;
@@ -177,9 +181,21 @@ public class Transportation extends Spell {
Location destination = locations.get(locations.size() - 1);
if(countdown == 1 && destination.dimension == player.dimension){
Entity mount = player.getRidingEntity();
if(mount != null) player.dismountRidingEntity();
player.setPositionAndUpdate(destination.pos.getX() + 0.5, destination.pos.getY(), destination.pos.getZ() + 0.5);
boolean teleportMount = mount != null && ItemArtefact.isArtefactActive(player, WizardryItems.charm_mount_teleporting);
if(teleportMount){
mount.setPositionAndUpdate(destination.pos.getX() + 0.5, destination.pos.getY(), destination.pos.getZ() + 0.5);
player.startRiding(mount);
}
player.addPotionEffect(new PotionEffect(MobEffects.BLINDNESS, 50, 0));
IMessage msg = new PacketTransportation.Message(player.getEntityId());
IMessage msg = new PacketTransportation.Message(destination.pos, teleportMount ? null : player);
WizardryPacketHandler.net.sendToDimension(msg, player.world.provider.getDimension());
}
@@ -1,5 +1,6 @@
package electroblob.wizardry.util;
import com.google.common.collect.Streams;
import electroblob.wizardry.Wizardry;
import electroblob.wizardry.data.WizardData;
import electroblob.wizardry.entity.living.ISpellCaster;
@@ -17,17 +18,24 @@ import net.minecraft.item.ItemStack;
import net.minecraft.network.datasync.DataParameter;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvent;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.EnumDifficulty;
import net.minecraft.world.World;
import net.minecraftforge.event.ForgeEventFactory;
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
import javax.annotation.Nullable;
import java.util.Comparator;
import java.util.List;
import java.util.UUID;
import java.util.function.Predicate;
import java.util.stream.Collectors;
/**
* Contains useful static methods for retrieving and interacting with players, mobs and other entities. These methods
@@ -182,6 +190,83 @@ public final class EntityUtils {
target.knockBack(attacker, 0.4f, dx, dz);
}
/**
* Finds the nearest space to the specified position that the given entity can teleport to without being inside one
* or more solid blocks. The search volume is twice the size of the entity's bounding box (meaning that when
* teleported to the returned position, the original destination remains within the entity's bounding box).
* @param entity The entity being teleported
* @param destination The target position to search around
* @param accountForPassengers True to take passengers into account when searching for a space, false to ignore them
* @return The resulting position, or null if no space was found.
*/
public static Vec3d findSpaceForTeleport(Entity entity, Vec3d destination, boolean accountForPassengers){
World world = entity.world;
AxisAlignedBB box = entity.getEntityBoundingBox();
if(accountForPassengers){
for(Entity passenger : entity.getPassengers()){
box = box.union(passenger.getEntityBoundingBox());
}
}
box = box.offset(destination.subtract(entity.posX, box.minY, entity.posZ));
// All the parameters of this method are INCLUSIVE, so even the max coordinates should be rounded down
Iterable<BlockPos> cuboid = BlockPos.getAllInBox(MathHelper.floor(box.minX), MathHelper.floor(box.minY),
MathHelper.floor(box.minZ), MathHelper.floor(box.maxX), MathHelper.floor(box.maxY), MathHelper.floor(box.maxZ));
if(Streams.stream(cuboid).noneMatch(b -> world.collidesWithAnyBlock(new AxisAlignedBB(b)))){
// Nothing in the way
return destination;
}else{
// Nearby position search
double dx = box.maxX - box.minX;
double dy = box.maxY - box.minY;
double dz = box.maxZ - box.minZ;
// Minimum space required is (nx + px) blocks * (ny + py) blocks * (nz + pz) blocks
int nx = MathHelper.ceil(dx) / 2;
int px = MathHelper.ceil(dx) - nx;
int ny = MathHelper.ceil(dy) / 2;
int py = MathHelper.ceil(dy) - ny;
int nz = MathHelper.ceil(dz) / 2;
int pz = MathHelper.ceil(dz) - nz;
// Check all the blocks in and around the bounding box...
List<BlockPos> nearby = Streams.stream(BlockPos.getAllInBox(MathHelper.floor(box.minX) - 1,
MathHelper.floor(box.minY) - 1, MathHelper.floor(box.minZ) - 1,
MathHelper.floor(box.maxX) + 1, MathHelper.floor(box.maxY) + 1,
MathHelper.floor(box.maxZ) + 1)).collect(Collectors.toList());
// ... but only return positions actually inside the box
List<BlockPos> possiblePositions = Streams.stream(cuboid).collect(Collectors.toList());
// Rather than iterate over each position and check if the box fits, find all solid blocks and cut out all
// positions whose corresponding box would include them - this is waaay more efficient!
while(!nearby.isEmpty()){
BlockPos pos = nearby.remove(0);
if(world.collidesWithAnyBlock(new AxisAlignedBB(pos))){
Predicate<BlockPos> nearSolidBlock = b -> b.getX() >= pos.getX() - nx && b.getX() <= pos.getX() + px
&& b.getY() >= pos.getY() - ny && b.getY() <= pos.getY() + py
&& b.getZ() >= pos.getZ() - nz && b.getZ() <= pos.getZ() + pz;
nearby.removeIf(nearSolidBlock);
possiblePositions.removeIf(nearSolidBlock);
}
}
if(possiblePositions.isEmpty()) return null; // No space nearby
BlockPos nearest = possiblePositions.stream().min(Comparator.comparingDouble(b -> destination.squareDistanceTo(
b.getX() + 0.5, b.getY() + 0.5, b.getZ() + 0.5))).get(); // The list can't be empty
return GeometryUtils.getFaceCentre(nearest, EnumFacing.DOWN);
}
}
// Damage
// ===============================================================================================================
@@ -370,6 +370,8 @@ item.ebwizardry\:charm_experience_tome.name=Tome of the Diligent
item.ebwizardry\:charm_experience_tome.desc=Increases the rate at which wands gain progression by 50%%
item.ebwizardry\:charm_move_speed.name=Icarus Medallion
item.ebwizardry\:charm_move_speed.desc=Move at near-full speed when casting spells
item.ebwizardry\:charm_spell_discovery.name=Archivist's Eyeglass
item.ebwizardry\:charm_spell_discovery.desc=Spell books found in chests are much more likely to be ones you have not yet discovered
item.ebwizardry\:charm_auto_smelt.name=Metallurgist's Mark
item.ebwizardry\:charm_auto_smelt.desc=Pocket furnace triggers automatically when bound to a wand on your hotbar
item.ebwizardry\:charm_lava_walking.name=Nether Ice Core
@@ -396,6 +398,8 @@ item.ebwizardry\:charm_transportation.name=Ancient Compass
item.ebwizardry\:charm_transportation.desc=Up to four stone circles may be remembered and selected from when using transportation
item.ebwizardry\:charm_black_hole.name=Void Opal
item.ebwizardry\:charm_black_hole.desc=Black hole sucks in and destroys blocks
item.ebwizardry\:charm_mount_teleporting.name=Spectral Tether
item.ebwizardry\:charm_mount_teleporting.desc=Teleporting while riding an animal or vehicle brings it with you
item.ebwizardry\:charm_feeding.name=Bottomless Provisions
item.ebwizardry\:charm_feeding.desc=Replenish hunger and satiety trigger automatically when bound to a wand on your hotbar
@@ -370,6 +370,8 @@ item.ebwizardry\:charm_experience_tome.name=Tome of the Diligent
item.ebwizardry\:charm_experience_tome.desc=Increases the rate at which wands gain progression by 50%%
item.ebwizardry\:charm_move_speed.name=Icarus Medallion
item.ebwizardry\:charm_move_speed.desc=Move at near-full speed when casting spells
item.ebwizardry\:charm_spell_discovery.name=Archivist's Eyeglass
item.ebwizardry\:charm_spell_discovery.desc=Spell books found in chests are much more likely to be ones you have not yet discovered
item.ebwizardry\:charm_auto_smelt.name=Metallurgist's Mark
item.ebwizardry\:charm_auto_smelt.desc=Pocket furnace triggers automatically when bound to a wand on your hotbar
item.ebwizardry\:charm_lava_walking.name=Nether Ice Core
@@ -396,6 +398,8 @@ item.ebwizardry\:charm_transportation.name=Ancient Compass
item.ebwizardry\:charm_transportation.desc=Up to four stone circles may be remembered and selected from when using transportation
item.ebwizardry\:charm_black_hole.name=Void Opal
item.ebwizardry\:charm_black_hole.desc=Black hole sucks in and destroys blocks
item.ebwizardry\:charm_mount_teleporting.name=Spectral Tether
item.ebwizardry\:charm_mount_teleporting.desc=Teleporting while riding an animal or vehicle brings it with you
item.ebwizardry\:charm_feeding.name=Bottomless Provisions
item.ebwizardry\:charm_feeding.desc=Replenish hunger and satiety trigger automatically when bound to a wand on your hotbar
@@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "ebwizardry:items/charm_mount_teleporting"
}
}
@@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "ebwizardry:items/charm_spell_discovery"
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB