Did some minor changes to EntityPlayer, and EntityEnderPearl

This commit is contained in:
ImHacking 2022-08-06 18:17:48 -04:00
parent 40f1bec4cb
commit 6dd5f7a17c
4 changed files with 24 additions and 18 deletions

View File

@ -71,7 +71,7 @@ public abstract class Entity implements ICommandListener {
public float pitch;
public float lastYaw;
public float lastPitch;
private AxisAlignedBB boundingBox;
public AxisAlignedBB boundingBox;
public boolean onGround;
public boolean positionChanged;
public boolean E;

View File

@ -54,14 +54,17 @@ public class EntityEnderPearl extends EntityProjectile {
protected void a(final MovingObjectPosition objectPosition) {
final EntityLiving entityliving = this.getShooter();
BlockPosition position = objectPosition.a();
if(position == null) {
if (position == null) {
position = new BlockPosition(this);
}
Block block = this.world.getType(position).getBlock();
if (block == Blocks.TRIPWIRE) {
return;
} else if (block == Blocks.FENCE_GATE) {
} else if (block == Blocks.FENCE_GATE ) {
BlockIterator bi = null;
try {
@ -95,6 +98,7 @@ public class EntityEnderPearl extends EntityProjectile {
}
}
}
if (objectPosition.entity != null) {
if (objectPosition.entity == this.c) {
return;
@ -110,17 +114,17 @@ public class EntityEnderPearl extends EntityProjectile {
this.world.addParticle(EnumParticle.PORTAL, this.locX, this.locY + this.random.nextDouble() * 2.0, this.locZ, this.random.nextGaussian(),
0.0, this.random.nextGaussian());
}
if (!this.world.isClientSide) {
if (entityliving instanceof EntityPlayer) {
final EntityPlayer entityplayer = (EntityPlayer)entityliving;
if (entityplayer.playerConnection.a().g() && entityplayer.world == this.world && !entityplayer.isSleeping() && entityplayer.getBukkitEntity() != null && entityplayer.getBukkitEntity().isOnline()) {
if (entityplayer.playerConnection.a().g() && entityplayer.world == this.world && !entityplayer.isSleeping()) {
if (teleportLocation != null) {
CraftPlayer player = entityplayer.getBukkitEntity();
Location previousLocation = player.getLocation();
teleportLocation.setYaw(previousLocation.getYaw());
teleportLocation.setPitch(previousLocation.getPitch());
// Fix an issue with the pearl actually not teleporting you into the exact Y it will
// randomly/based of the pitch the Y would change, the closer to the thrower/thrown from
@ -144,10 +148,10 @@ public class EntityEnderPearl extends EntityProjectile {
CraftEventFactory.entityDamage = null;
}
} else {
//ImHacking Add Player Pearl Refund
// ImHacking Add Player Pearl Refund
Bukkit.getPluginManager().callEvent(new PlayerPearlRefundEvent(entityplayer.getBukkitEntity()));
// ImHacking (Give back the pearl since the teleport location was not made correctly)
player.getInventory().addItem(new ItemStack(org.bukkit.Material.ENDER_PEARL));
player.getInventory().addItem(new ItemStack(Material.ENDER_PEARL));
}
}
} else if (entityliving != null) {
@ -178,12 +182,12 @@ public class EntityEnderPearl extends EntityProjectile {
} else {
AxisAlignedBB boundingBox = AxisAlignedBB.a(this.locX - 0.3D, this.locY - 0.05D, this.locZ - 0.3D, this.locX + 0.3D, this.locY + 0.5D, this.locZ + 0.3D);
if (!this.world.boundingBoxContainsMaterials(this.getBoundingBox().grow(0.25D,
if (!this.world.boundingBoxContainsMaterials(this.boundingBox.grow(0.25D,
0D, 0.25D), PROHIBITED_PEARL_BLOCKS) && this.world.getCubes(this, boundingBox).isEmpty()) {
this.teleportLocation = getBukkitEntity().getLocation();
}
org.bukkit.block.Block block = this.world.getWorld().getBlockAt(MathHelper.floor(this.locX), MathHelper.floor(this.locY), MathHelper.floor(this.locZ));
org.bukkit.Material typeHere = this.world.getWorld().getBlockAt(MathHelper.floor(this.locX),
Material typeHere = this.world.getWorld().getBlockAt(MathHelper.floor(this.locX),
MathHelper.floor(this.locY), MathHelper.floor(this.locZ)).getType();
if (pearlAbleType.stream().anyMatch(it -> typeHere.name().contains(it))) {
@ -195,7 +199,7 @@ public class EntityEnderPearl extends EntityProjectile {
this.teleportLocation = getBukkitEntity().getLocation();
}
if (typeHere == org.bukkit.Material.FENCE_GATE) {
if (typeHere == Material.FENCE_GATE) {
if (((Openable) block.getState().getData()).isOpen()) {
this.teleportLocation = getBukkitEntity().getLocation();
}
@ -204,7 +208,7 @@ public class EntityEnderPearl extends EntityProjectile {
if (shooter != null) {
final org.bukkit.block.Block newTrap = block.getRelative(getDirection((EntityPlayer) shooter)).getRelative(BlockFace.DOWN);
if (newTrap.getType() == org.bukkit.Material.COBBLE_WALL || newTrap.getType() == Material.FENCE) {
if (newTrap.getType() == Material.COBBLE_WALL || newTrap.getType() == Material.FENCE) {
this.teleportLocation = newTrap.getLocation();
}
}

View File

@ -353,11 +353,12 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
if (this.getHealth() + this.getAbsorptionHearts() != this.bL) {
this.bL = this.getHealth() + this.getAbsorptionHearts();
Collection collection = this.getScoreboard().getObjectivesForCriteria(IScoreboardCriteria.g);
Iterator iterator = collection.iterator();
for (Object o : collection) {
ScoreboardObjective scoreboardobjective = (ScoreboardObjective) o;
while (iterator.hasNext()) {
ScoreboardObjective scoreboardobjective = (ScoreboardObjective) iterator.next();
this.getScoreboard().getPlayerScoreForObjective(this.getName(), scoreboardobjective).updateForList(Arrays.asList(new EntityHuman[]{this}));
this.getScoreboard().getPlayerScoreForObjective(this.getName(), scoreboardobjective).updateForList(Arrays.asList(new EntityHuman[] { this}));
}
// CraftBukkit - Update ALL the scores!
this.world.getServer().getScoreboardManager().updateAllScoresForList(IScoreboardCriteria.g, this.getName(), com.google.common.collect.ImmutableList.of(this));

View File

@ -169,10 +169,11 @@ public class PaperSpigotWorldConfig
log( "Remove invalid mob spawner tile entities: " + removeInvalidMobSpawnerTEs );
}
public static boolean removeUnloadedEnderPearls;
public boolean removeUnloadedEnderPearls;
public static boolean removeUnloadedTNTEntities;
public static boolean removeUnloadedFallingBlocks;
private static void removeUnloaded()
private void removeUnloaded()
{
removeUnloadedEnderPearls = getBoolean( "remove-unloaded.enderpearls", true );
removeUnloadedTNTEntities = getBoolean( "remove-unloaded.tnt-entities", true );
@ -218,10 +219,10 @@ public class PaperSpigotWorldConfig
disableEndCredits = getBoolean( "game-mechanics.disable-end-credits", false );
}
public static boolean loadUnloadedEnderPearls;
public boolean loadUnloadedEnderPearls;
public static boolean loadUnloadedTNTEntities;
public static boolean loadUnloadedFallingBlocks;
private static void loadUnloaded()
private void loadUnloaded()
{
loadUnloadedEnderPearls = getBoolean( "load-chunks.enderpearls", false );
loadUnloadedTNTEntities = getBoolean( "load-chunks.tnt-entities", false );