1
0
forked from xjboss/KCauldronX
KCauldronX/patches/net/minecraft/entity/EntityLeashKnot.java.patch

99 lines
3.4 KiB
Diff
Raw Normal View History

2015-03-22 17:38:04 +00:00
--- ../src-base/minecraft/net/minecraft/entity/EntityLeashKnot.java
+++ ../src-work/minecraft/net/minecraft/entity/EntityLeashKnot.java
2015-06-05 13:41:54 +00:00
@@ -2,8 +2,10 @@
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
+
import java.util.Iterator;
import java.util.List;
+
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
@@ -11,6 +13,13 @@
2015-03-22 17:38:04 +00:00
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
+ // CraftBukkit start
+import net.minecraft.entity.player.EntityPlayerMP;
+import net.minecraft.network.play.server.S1BPacketEntityAttach;
2015-06-05 13:41:54 +00:00
+
2015-03-22 17:38:04 +00:00
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+// CraftBukkit end
+
public class EntityLeashKnot extends EntityHanging
{
private static final String __OBFID = "CL_00001548";
2015-06-05 13:41:54 +00:00
@@ -84,6 +93,14 @@
2015-03-22 17:38:04 +00:00
if (entityliving.getLeashed() && entityliving.getLeashedToEntity() == p_130002_1_)
{
+ // CraftBukkit start
+ if (CraftEventFactory.callPlayerLeashEntityEvent(entityliving, this, p_130002_1_).isCancelled())
+ {
+ ((EntityPlayerMP) p_130002_1_).playerNetServerHandler.sendPacket(new S1BPacketEntityAttach(1, entityliving, entityliving.getLeashedToEntity()));
+ continue;
+ }
+
+ // CraftBukkit end
entityliving.setLeashedToEntity(this, true);
flag = true;
}
2015-06-05 13:41:54 +00:00
@@ -93,9 +110,12 @@
2015-03-22 17:38:04 +00:00
if (!this.worldObj.isRemote && !flag)
{
- this.setDead();
+ // CraftBukkit start - Move below
+ //this.setDead();
+ boolean die = true;
- if (p_130002_1_.capabilities.isCreativeMode)
+ // CraftBukkit end
+ if (true || p_130002_1_.capabilities.isCreativeMode) // CraftBukkit - Process for non-creative as well
{
d0 = 7.0D;
list = this.worldObj.getEntitiesWithinAABB(EntityLiving.class, AxisAlignedBB.getBoundingBox(this.posX - d0, this.posY - d0, this.posZ - d0, this.posX + d0, this.posY + d0, this.posZ + d0));
2015-06-05 13:41:54 +00:00
@@ -110,11 +130,27 @@
2015-03-22 17:38:04 +00:00
if (entityliving.getLeashed() && entityliving.getLeashedToEntity() == this)
{
- entityliving.clearLeashed(true, false);
+ // CraftBukkit start
+ if (CraftEventFactory.callPlayerUnleashEntityEvent(entityliving, p_130002_1_).isCancelled())
+ {
+ die = false;
+ continue;
+ }
+
+ entityliving.clearLeashed(true, !p_130002_1_.capabilities.isCreativeMode); // false -> survival mode boolean
+ // CraftBukkit end
}
}
}
}
+
+ // CraftBukkit start
+ if (die)
+ {
+ this.setDead();
+ }
+
+ // CraftBukkit end
}
return true;
2015-06-05 13:41:54 +00:00
@@ -154,4 +190,11 @@
return null;
}
+
+ // Cauldron start
+ @Override
+ public boolean entityProjectileHook() {
2015-06-08 16:18:24 +00:00
+ return true;
2015-06-05 13:41:54 +00:00
+ }
+ // Cauldron end
}