mirror of
https://github.com/barkeser2002/CatServer.git
synced 2026-09-25 02:20:01 +03:00
72 lines
3.2 KiB
Diff
72 lines
3.2 KiB
Diff
--- ../src-base/minecraft/net/minecraft/entity/EntityLeashKnot.java
|
|
+++ ../src-work/minecraft/net/minecraft/entity/EntityLeashKnot.java
|
|
@@ -4,8 +4,10 @@
|
|
import javax.annotation.Nullable;
|
|
import net.minecraft.block.BlockFence;
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
+import net.minecraft.entity.player.EntityPlayerMP;
|
|
import net.minecraft.init.SoundEvents;
|
|
import net.minecraft.nbt.NBTTagCompound;
|
|
+import net.minecraft.network.play.server.SPacketEntityAttach;
|
|
import net.minecraft.util.EnumFacing;
|
|
import net.minecraft.util.EnumHand;
|
|
import net.minecraft.util.math.AxisAlignedBB;
|
|
@@ -14,6 +16,7 @@
|
|
import net.minecraft.world.World;
|
|
import net.minecraftforge.fml.relauncher.Side;
|
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
|
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
|
|
|
public class EntityLeashKnot extends EntityHanging
|
|
{
|
|
@@ -43,6 +46,7 @@
|
|
this.posX = (double)this.hangingPosition.getX() + 0.5D;
|
|
this.posY = (double)this.hangingPosition.getY() + 0.5D;
|
|
this.posZ = (double)this.hangingPosition.getZ() + 0.5D;
|
|
+ if (this.isAddedToWorld() && !this.world.isRemote) this.world.updateEntityWithOptionalForce(this, false); // Forge - Process chunk registration after moving.
|
|
}
|
|
|
|
public void updateFacingWithBoundingBox(EnumFacing facingDirectionIn)
|
|
@@ -104,6 +108,10 @@
|
|
{
|
|
if (entityliving.getLeashed() && entityliving.getLeashHolder() == player)
|
|
{
|
|
+ if (CraftEventFactory.callPlayerLeashEntityEvent(entityliving, this, player).isCancelled()) {
|
|
+ ((EntityPlayerMP) player).connection.sendPacket(new SPacketEntityAttach(entityliving, entityliving.getLeashHolder()));
|
|
+ continue;
|
|
+ }
|
|
entityliving.setLeashHolder(this, true);
|
|
flag = true;
|
|
}
|
|
@@ -111,17 +119,25 @@
|
|
|
|
if (!flag)
|
|
{
|
|
- this.setDead();
|
|
-
|
|
- if (player.capabilities.isCreativeMode)
|
|
- {
|
|
+ // CraftBukkit start - Move below
|
|
+ // this.setDead();
|
|
+ if (true || player.capabilities.isCreativeMode) { // CraftBukkit - Process for non-creative as well
|
|
+ boolean die = true;
|
|
for (EntityLiving entityliving1 : list)
|
|
{
|
|
if (entityliving1.getLeashed() && entityliving1.getLeashHolder() == this)
|
|
{
|
|
- entityliving1.clearLeashed(true, false);
|
|
+ // entityliving1.clearLeashed(true, false);
|
|
+ if (CraftEventFactory.callPlayerUnleashEntityEvent(entityliving1, player).isCancelled()) {
|
|
+ die = false;
|
|
+ continue;
|
|
+ }
|
|
+ entityliving1.clearLeashed(true, !player.capabilities.isCreativeMode); // false -> survival mode boolean
|
|
}
|
|
}
|
|
+ if (die) {
|
|
+ this.setDead();
|
|
+ }
|
|
}
|
|
}
|
|
|