#1107: Add getHand() to all relevant events
This commit is contained in:
parent
93061706eb
commit
5329dd6fd2
@ -59,7 +59,7 @@
|
|||||||
ItemStack itemstack = (ItemStack) entry.getValue();
|
ItemStack itemstack = (ItemStack) entry.getValue();
|
||||||
int j = Math.min(this.xpToDurability(this.value), itemstack.getDamageValue());
|
int j = Math.min(this.xpToDurability(this.value), itemstack.getDamageValue());
|
||||||
+ // CraftBukkit start
|
+ // CraftBukkit start
|
||||||
+ org.bukkit.event.player.PlayerItemMendEvent event = CraftEventFactory.callPlayerItemMendEvent(entityhuman, this, itemstack, j);
|
+ org.bukkit.event.player.PlayerItemMendEvent event = CraftEventFactory.callPlayerItemMendEvent(entityhuman, this, itemstack, entry.getKey(), j);
|
||||||
+ j = event.getRepairAmount();
|
+ j = event.getRepairAmount();
|
||||||
+ if (event.isCancelled()) {
|
+ if (event.isCancelled()) {
|
||||||
+ return i;
|
+ return i;
|
||||||
|
@ -188,7 +188,7 @@
|
|||||||
return EnumInteractionResult.PASS;
|
return EnumInteractionResult.PASS;
|
||||||
} else if (this.getLeashHolder() == entityhuman) {
|
} else if (this.getLeashHolder() == entityhuman) {
|
||||||
+ // CraftBukkit start - fire PlayerUnleashEntityEvent
|
+ // CraftBukkit start - fire PlayerUnleashEntityEvent
|
||||||
+ if (CraftEventFactory.callPlayerUnleashEntityEvent(this, entityhuman).isCancelled()) {
|
+ if (CraftEventFactory.callPlayerUnleashEntityEvent(this, entityhuman, enumhand).isCancelled()) {
|
||||||
+ ((EntityPlayer) entityhuman).connection.send(new PacketPlayOutAttachEntity(this, this.getLeashHolder()));
|
+ ((EntityPlayer) entityhuman).connection.send(new PacketPlayOutAttachEntity(this, this.getLeashHolder()));
|
||||||
+ return EnumInteractionResult.PASS;
|
+ return EnumInteractionResult.PASS;
|
||||||
+ }
|
+ }
|
||||||
@ -201,7 +201,7 @@
|
|||||||
|
|
||||||
if (itemstack.is(Items.LEAD) && this.canBeLeashed(entityhuman)) {
|
if (itemstack.is(Items.LEAD) && this.canBeLeashed(entityhuman)) {
|
||||||
+ // CraftBukkit start - fire PlayerLeashEntityEvent
|
+ // CraftBukkit start - fire PlayerLeashEntityEvent
|
||||||
+ if (CraftEventFactory.callPlayerLeashEntityEvent(this, entityhuman, entityhuman).isCancelled()) {
|
+ if (CraftEventFactory.callPlayerLeashEntityEvent(this, entityhuman, entityhuman, enumhand).isCancelled()) {
|
||||||
+ ((EntityPlayer) entityhuman).connection.send(new PacketPlayOutAttachEntity(this, this.getLeashHolder()));
|
+ ((EntityPlayer) entityhuman).connection.send(new PacketPlayOutAttachEntity(this, this.getLeashHolder()));
|
||||||
+ return EnumInteractionResult.PASS;
|
+ return EnumInteractionResult.PASS;
|
||||||
+ }
|
+ }
|
||||||
|
@ -431,11 +431,12 @@
|
|||||||
this.hurtDir = 0.0F;
|
this.hurtDir = 0.0F;
|
||||||
Entity entity1 = damagesource.getEntity();
|
Entity entity1 = damagesource.getEntity();
|
||||||
|
|
||||||
@@ -1258,19 +1485,29 @@
|
@@ -1258,19 +1485,32 @@
|
||||||
EnumHand[] aenumhand = EnumHand.values();
|
EnumHand[] aenumhand = EnumHand.values();
|
||||||
int i = aenumhand.length;
|
int i = aenumhand.length;
|
||||||
|
|
||||||
+ // CraftBukkit start
|
+ // CraftBukkit start
|
||||||
|
+ EnumHand hand = null;
|
||||||
+ ItemStack itemstack1 = ItemStack.EMPTY;
|
+ ItemStack itemstack1 = ItemStack.EMPTY;
|
||||||
for (int j = 0; j < i; ++j) {
|
for (int j = 0; j < i; ++j) {
|
||||||
EnumHand enumhand = aenumhand[j];
|
EnumHand enumhand = aenumhand[j];
|
||||||
@ -443,6 +444,7 @@
|
|||||||
+ itemstack1 = this.getItemInHand(enumhand);
|
+ itemstack1 = this.getItemInHand(enumhand);
|
||||||
|
|
||||||
if (itemstack1.is(Items.TOTEM_OF_UNDYING)) {
|
if (itemstack1.is(Items.TOTEM_OF_UNDYING)) {
|
||||||
|
+ hand = enumhand; // CraftBukkit
|
||||||
itemstack = itemstack1.copy();
|
itemstack = itemstack1.copy();
|
||||||
- itemstack1.shrink(1);
|
- itemstack1.shrink(1);
|
||||||
+ // itemstack1.subtract(1); // CraftBukkit
|
+ // itemstack1.subtract(1); // CraftBukkit
|
||||||
@ -452,7 +454,8 @@
|
|||||||
|
|
||||||
- if (itemstack != null) {
|
- if (itemstack != null) {
|
||||||
- if (this instanceof EntityPlayer) {
|
- if (this instanceof EntityPlayer) {
|
||||||
+ EntityResurrectEvent event = new EntityResurrectEvent((LivingEntity) this.getBukkitEntity());
|
+ org.bukkit.inventory.EquipmentSlot handSlot = (hand != null) ? org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(hand) : null;
|
||||||
|
+ EntityResurrectEvent event = new EntityResurrectEvent((LivingEntity) this.getBukkitEntity(), handSlot);
|
||||||
+ event.setCancelled(itemstack == null);
|
+ event.setCancelled(itemstack == null);
|
||||||
+ this.level.getCraftServer().getPluginManager().callEvent(event);
|
+ this.level.getCraftServer().getPluginManager().callEvent(event);
|
||||||
+
|
+
|
||||||
@ -465,7 +468,7 @@
|
|||||||
EntityPlayer entityplayer = (EntityPlayer) this;
|
EntityPlayer entityplayer = (EntityPlayer) this;
|
||||||
|
|
||||||
entityplayer.awardStat(StatisticList.ITEM_USED.get(Items.TOTEM_OF_UNDYING));
|
entityplayer.awardStat(StatisticList.ITEM_USED.get(Items.TOTEM_OF_UNDYING));
|
||||||
@@ -1278,14 +1515,16 @@
|
@@ -1278,14 +1518,16 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setHealth(1.0F);
|
this.setHealth(1.0F);
|
||||||
@ -487,7 +490,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1390,14 +1629,22 @@
|
@@ -1390,14 +1632,22 @@
|
||||||
IBlockData iblockdata = Blocks.WITHER_ROSE.defaultBlockState();
|
IBlockData iblockdata = Blocks.WITHER_ROSE.defaultBlockState();
|
||||||
|
|
||||||
if (this.level.getBlockState(blockposition).isAir() && iblockdata.canSurvive(this.level, blockposition)) {
|
if (this.level.getBlockState(blockposition).isAir() && iblockdata.canSurvive(this.level, blockposition)) {
|
||||||
@ -512,7 +515,7 @@
|
|||||||
this.level.addFreshEntity(entityitem);
|
this.level.addFreshEntity(entityitem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1417,21 +1664,40 @@
|
@@ -1417,21 +1667,40 @@
|
||||||
|
|
||||||
boolean flag = this.lastHurtByPlayerTime > 0;
|
boolean flag = this.lastHurtByPlayerTime > 0;
|
||||||
|
|
||||||
@ -556,7 +559,7 @@
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1504,6 +1770,28 @@
|
@@ -1504,6 +1773,28 @@
|
||||||
return itemstack.getEatingSound();
|
return itemstack.getEatingSound();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -585,7 +588,7 @@
|
|||||||
@Override
|
@Override
|
||||||
public void setOnGround(boolean flag) {
|
public void setOnGround(boolean flag) {
|
||||||
super.setOnGround(flag);
|
super.setOnGround(flag);
|
||||||
@@ -1559,9 +1847,14 @@
|
@@ -1559,9 +1850,14 @@
|
||||||
int i = this.calculateFallDamage(f, f1);
|
int i = this.calculateFallDamage(f, f1);
|
||||||
|
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
@ -601,7 +604,7 @@
|
|||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return flag;
|
return flag;
|
||||||
@@ -1610,7 +1903,7 @@
|
@@ -1610,7 +1906,7 @@
|
||||||
|
|
||||||
protected float getDamageAfterArmorAbsorb(DamageSource damagesource, float f) {
|
protected float getDamageAfterArmorAbsorb(DamageSource damagesource, float f) {
|
||||||
if (!damagesource.isBypassArmor()) {
|
if (!damagesource.isBypassArmor()) {
|
||||||
@ -610,7 +613,7 @@
|
|||||||
f = CombatMath.getDamageAfterAbsorb(f, (float) this.getArmorValue(), (float) this.getAttributeValue(GenericAttributes.ARMOR_TOUGHNESS));
|
f = CombatMath.getDamageAfterAbsorb(f, (float) this.getArmorValue(), (float) this.getAttributeValue(GenericAttributes.ARMOR_TOUGHNESS));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1623,7 +1916,8 @@
|
@@ -1623,7 +1919,8 @@
|
||||||
} else {
|
} else {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -620,7 +623,7 @@
|
|||||||
i = (this.getEffect(MobEffects.DAMAGE_RESISTANCE).getAmplifier() + 1) * 5;
|
i = (this.getEffect(MobEffects.DAMAGE_RESISTANCE).getAmplifier() + 1) * 5;
|
||||||
int j = 25 - i;
|
int j = 25 - i;
|
||||||
float f1 = f * (float) j;
|
float f1 = f * (float) j;
|
||||||
@@ -1656,29 +1950,172 @@
|
@@ -1656,29 +1953,172 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -803,7 +806,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
public CombatTracker getCombatTracker() {
|
public CombatTracker getCombatTracker() {
|
||||||
@@ -1699,9 +2136,19 @@
|
@@ -1699,9 +2139,19 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void setArrowCount(int i) {
|
public final void setArrowCount(int i) {
|
||||||
@ -824,7 +827,7 @@
|
|||||||
public final int getStingerCount() {
|
public final int getStingerCount() {
|
||||||
return (Integer) this.entityData.get(EntityLiving.DATA_STINGER_COUNT_ID);
|
return (Integer) this.entityData.get(EntityLiving.DATA_STINGER_COUNT_ID);
|
||||||
}
|
}
|
||||||
@@ -1996,6 +2443,12 @@
|
@@ -1996,6 +2446,12 @@
|
||||||
|
|
||||||
public abstract ItemStack getItemBySlot(EnumItemSlot enumitemslot);
|
public abstract ItemStack getItemBySlot(EnumItemSlot enumitemslot);
|
||||||
|
|
||||||
@ -837,7 +840,7 @@
|
|||||||
@Override
|
@Override
|
||||||
public abstract void setItemSlot(EnumItemSlot enumitemslot, ItemStack itemstack);
|
public abstract void setItemSlot(EnumItemSlot enumitemslot, ItemStack itemstack);
|
||||||
|
|
||||||
@@ -2239,6 +2692,7 @@
|
@@ -2239,6 +2695,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.onGround && !this.level.isClientSide) {
|
if (this.onGround && !this.level.isClientSide) {
|
||||||
@ -845,7 +848,7 @@
|
|||||||
this.setSharedFlag(7, false);
|
this.setSharedFlag(7, false);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -2772,6 +3226,7 @@
|
@@ -2772,6 +3229,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.level.isClientSide) {
|
if (!this.level.isClientSide) {
|
||||||
@ -853,7 +856,7 @@
|
|||||||
this.setSharedFlag(7, flag);
|
this.setSharedFlag(7, flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2931,14 +3386,21 @@
|
@@ -2931,14 +3389,21 @@
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isPickable() {
|
public boolean isPickable() {
|
||||||
@ -877,7 +880,7 @@
|
|||||||
@Override
|
@Override
|
||||||
public float getYHeadRot() {
|
public float getYHeadRot() {
|
||||||
return this.yHeadRot;
|
return this.yHeadRot;
|
||||||
@@ -3133,7 +3595,25 @@
|
@@ -3133,7 +3598,26 @@
|
||||||
} else {
|
} else {
|
||||||
if (!this.useItem.isEmpty() && this.isUsingItem()) {
|
if (!this.useItem.isEmpty() && this.isUsingItem()) {
|
||||||
this.triggerItemUseEffects(this.useItem, 16);
|
this.triggerItemUseEffects(this.useItem, 16);
|
||||||
@ -886,7 +889,8 @@
|
|||||||
+ ItemStack itemstack;
|
+ ItemStack itemstack;
|
||||||
+ if (this instanceof EntityPlayer) {
|
+ if (this instanceof EntityPlayer) {
|
||||||
+ org.bukkit.inventory.ItemStack craftItem = CraftItemStack.asBukkitCopy(this.useItem);
|
+ org.bukkit.inventory.ItemStack craftItem = CraftItemStack.asBukkitCopy(this.useItem);
|
||||||
+ PlayerItemConsumeEvent event = new PlayerItemConsumeEvent((Player) this.getBukkitEntity(), craftItem);
|
+ org.bukkit.inventory.EquipmentSlot hand = org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(enumhand);
|
||||||
|
+ PlayerItemConsumeEvent event = new PlayerItemConsumeEvent((Player) this.getBukkitEntity(), craftItem, hand);
|
||||||
+ level.getCraftServer().getPluginManager().callEvent(event);
|
+ level.getCraftServer().getPluginManager().callEvent(event);
|
||||||
+
|
+
|
||||||
+ if (event.isCancelled()) {
|
+ if (event.isCancelled()) {
|
||||||
@ -904,7 +908,7 @@
|
|||||||
|
|
||||||
if (itemstack != this.useItem) {
|
if (itemstack != this.useItem) {
|
||||||
this.setItemInHand(enumhand, itemstack);
|
this.setItemInHand(enumhand, itemstack);
|
||||||
@@ -3211,6 +3691,12 @@
|
@@ -3211,6 +3695,12 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean randomTeleport(double d0, double d1, double d2, boolean flag) {
|
public boolean randomTeleport(double d0, double d1, double d2, boolean flag) {
|
||||||
@ -917,7 +921,7 @@
|
|||||||
double d3 = this.getX();
|
double d3 = this.getX();
|
||||||
double d4 = this.getY();
|
double d4 = this.getY();
|
||||||
double d5 = this.getZ();
|
double d5 = this.getZ();
|
||||||
@@ -3235,16 +3721,41 @@
|
@@ -3235,16 +3725,41 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flag2) {
|
if (flag2) {
|
||||||
@ -962,7 +966,7 @@
|
|||||||
} else {
|
} else {
|
||||||
if (flag) {
|
if (flag) {
|
||||||
world.broadcastEntityEvent(this, (byte) 46);
|
world.broadcastEntityEvent(this, (byte) 46);
|
||||||
@@ -3254,7 +3765,7 @@
|
@@ -3254,7 +3769,7 @@
|
||||||
((EntityCreature) this).getNavigation().stop();
|
((EntityCreature) this).getNavigation().stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -971,7 +975,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3337,7 +3848,7 @@
|
@@ -3337,7 +3852,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stopSleeping() {
|
public void stopSleeping() {
|
||||||
@ -980,7 +984,7 @@
|
|||||||
World world = this.level;
|
World world = this.level;
|
||||||
|
|
||||||
java.util.Objects.requireNonNull(this.level);
|
java.util.Objects.requireNonNull(this.level);
|
||||||
@@ -3369,7 +3880,7 @@
|
@@ -3369,7 +3884,7 @@
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public EnumDirection getBedOrientation() {
|
public EnumDirection getBedOrientation() {
|
||||||
@ -989,7 +993,7 @@
|
|||||||
|
|
||||||
return blockposition != null ? BlockBed.getBedOrientation(this.level, blockposition) : null;
|
return blockposition != null ? BlockBed.getBedOrientation(this.level, blockposition) : null;
|
||||||
}
|
}
|
||||||
@@ -3417,7 +3928,7 @@
|
@@ -3417,7 +3932,7 @@
|
||||||
Pair<MobEffect, Float> pair = (Pair) iterator.next();
|
Pair<MobEffect, Float> pair = (Pair) iterator.next();
|
||||||
|
|
||||||
if (!world.isClientSide && pair.getFirst() != null && world.random.nextFloat() < (Float) pair.getSecond()) {
|
if (!world.isClientSide && pair.getFirst() != null && world.random.nextFloat() < (Float) pair.getSecond()) {
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
((Bucketable) t0).saveToBucketTag(itemstack1);
|
((Bucketable) t0).saveToBucketTag(itemstack1);
|
||||||
+
|
+
|
||||||
+ PlayerBucketEntityEvent playerBucketFishEvent = CraftEventFactory.callPlayerFishBucketEvent(t0, entityhuman, itemstack, itemstack1);
|
+ PlayerBucketEntityEvent playerBucketFishEvent = CraftEventFactory.callPlayerFishBucketEvent(t0, entityhuman, itemstack, itemstack1, enumhand);
|
||||||
+ itemstack1 = CraftItemStack.asNMSCopy(playerBucketFishEvent.getEntityBucket());
|
+ itemstack1 = CraftItemStack.asNMSCopy(playerBucketFishEvent.getEntityBucket());
|
||||||
+ if (playerBucketFishEvent.isCancelled()) {
|
+ if (playerBucketFishEvent.isCancelled()) {
|
||||||
+ ((EntityPlayer) entityhuman).containerMenu.sendAllDataToRemote(); // We need to update inventory to resync client's bucket
|
+ ((EntityPlayer) entityhuman).containerMenu.sendAllDataToRemote(); // We need to update inventory to resync client's bucket
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
if (itemstack.is(Items.BUCKET) && !this.isBaby()) {
|
if (itemstack.is(Items.BUCKET) && !this.isBaby()) {
|
||||||
+ // CraftBukkit start - Got milk?
|
+ // CraftBukkit start - Got milk?
|
||||||
+ org.bukkit.event.player.PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent((WorldServer) entityhuman.level, entityhuman, this.blockPosition(), this.blockPosition(), null, itemstack, Items.MILK_BUCKET);
|
+ org.bukkit.event.player.PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent((WorldServer) entityhuman.level, entityhuman, this.blockPosition(), this.blockPosition(), null, itemstack, Items.MILK_BUCKET, enumhand);
|
||||||
+
|
+
|
||||||
+ if (event.isCancelled()) {
|
+ if (event.isCancelled()) {
|
||||||
+ return EnumInteractionResult.PASS;
|
+ return EnumInteractionResult.PASS;
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
if (itemstack.is(Items.BUCKET) && !this.isBaby()) {
|
if (itemstack.is(Items.BUCKET) && !this.isBaby()) {
|
||||||
+ // CraftBukkit start - Got milk?
|
+ // CraftBukkit start - Got milk?
|
||||||
+ org.bukkit.event.player.PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent((WorldServer) entityhuman.level, entityhuman, this.blockPosition(), this.blockPosition(), null, itemstack, Items.MILK_BUCKET);
|
+ org.bukkit.event.player.PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent((WorldServer) entityhuman.level, entityhuman, this.blockPosition(), this.blockPosition(), null, itemstack, Items.MILK_BUCKET, enumhand);
|
||||||
+
|
+
|
||||||
+ if (event.isCancelled()) {
|
+ if (event.isCancelled()) {
|
||||||
+ return EnumInteractionResult.PASS;
|
+ return EnumInteractionResult.PASS;
|
||||||
|
@ -53,7 +53,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -402,6 +425,21 @@
|
@@ -402,6 +425,22 @@
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
ItemStack itemstack2;
|
ItemStack itemstack2;
|
||||||
@ -65,7 +65,8 @@
|
|||||||
+ ArmorStand self = (ArmorStand) this.getBukkitEntity();
|
+ ArmorStand self = (ArmorStand) this.getBukkitEntity();
|
||||||
+
|
+
|
||||||
+ EquipmentSlot slot = CraftEquipmentSlot.getSlot(enumitemslot);
|
+ EquipmentSlot slot = CraftEquipmentSlot.getSlot(enumitemslot);
|
||||||
+ PlayerArmorStandManipulateEvent armorStandManipulateEvent = new PlayerArmorStandManipulateEvent(player,self,playerHeldItem,armorStandItem,slot);
|
+ EquipmentSlot hand = CraftEquipmentSlot.getHand(enumhand);
|
||||||
|
+ PlayerArmorStandManipulateEvent armorStandManipulateEvent = new PlayerArmorStandManipulateEvent(player,self,playerHeldItem,armorStandItem,slot,hand);
|
||||||
+ this.level.getCraftServer().getPluginManager().callEvent(armorStandManipulateEvent);
|
+ this.level.getCraftServer().getPluginManager().callEvent(armorStandManipulateEvent);
|
||||||
+
|
+
|
||||||
+ if (armorStandManipulateEvent.isCancelled()) {
|
+ if (armorStandManipulateEvent.isCancelled()) {
|
||||||
@ -75,7 +76,7 @@
|
|||||||
|
|
||||||
if (entityhuman.getAbilities().instabuild && itemstack1.isEmpty() && !itemstack.isEmpty()) {
|
if (entityhuman.getAbilities().instabuild && itemstack1.isEmpty() && !itemstack.isEmpty()) {
|
||||||
itemstack2 = itemstack.copy();
|
itemstack2 = itemstack.copy();
|
||||||
@@ -430,9 +468,19 @@
|
@@ -430,9 +469,19 @@
|
||||||
public boolean hurt(DamageSource damagesource, float f) {
|
public boolean hurt(DamageSource damagesource, float f) {
|
||||||
if (!this.level.isClientSide && !this.isRemoved()) {
|
if (!this.level.isClientSide && !this.isRemoved()) {
|
||||||
if (DamageSource.OUT_OF_WORLD.equals(damagesource)) {
|
if (DamageSource.OUT_OF_WORLD.equals(damagesource)) {
|
||||||
@ -96,7 +97,7 @@
|
|||||||
if (damagesource.isExplosion()) {
|
if (damagesource.isExplosion()) {
|
||||||
this.brokenByAnything(damagesource);
|
this.brokenByAnything(damagesource);
|
||||||
this.kill();
|
this.kill();
|
||||||
@@ -472,7 +520,7 @@
|
@@ -472,7 +521,7 @@
|
||||||
} else {
|
} else {
|
||||||
this.brokenByPlayer(damagesource);
|
this.brokenByPlayer(damagesource);
|
||||||
this.showBreakingParticles();
|
this.showBreakingParticles();
|
||||||
@ -105,7 +106,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -533,13 +581,13 @@
|
@@ -533,13 +582,13 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
private void brokenByPlayer(DamageSource damagesource) {
|
private void brokenByPlayer(DamageSource damagesource) {
|
||||||
@ -121,7 +122,7 @@
|
|||||||
|
|
||||||
ItemStack itemstack;
|
ItemStack itemstack;
|
||||||
int i;
|
int i;
|
||||||
@@ -547,7 +595,7 @@
|
@@ -547,7 +596,7 @@
|
||||||
for (i = 0; i < this.handItems.size(); ++i) {
|
for (i = 0; i < this.handItems.size(); ++i) {
|
||||||
itemstack = (ItemStack) this.handItems.get(i);
|
itemstack = (ItemStack) this.handItems.get(i);
|
||||||
if (!itemstack.isEmpty()) {
|
if (!itemstack.isEmpty()) {
|
||||||
@ -130,7 +131,7 @@
|
|||||||
this.handItems.set(i, ItemStack.EMPTY);
|
this.handItems.set(i, ItemStack.EMPTY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -555,10 +603,11 @@
|
@@ -555,10 +604,11 @@
|
||||||
for (i = 0; i < this.armorItems.size(); ++i) {
|
for (i = 0; i < this.armorItems.size(); ++i) {
|
||||||
itemstack = (ItemStack) this.armorItems.get(i);
|
itemstack = (ItemStack) this.armorItems.get(i);
|
||||||
if (!itemstack.isEmpty()) {
|
if (!itemstack.isEmpty()) {
|
||||||
@ -143,7 +144,7 @@
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -659,8 +708,16 @@
|
@@ -659,8 +709,16 @@
|
||||||
return this.isSmall();
|
return this.isSmall();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
entityinsentient = (EntityInsentient) iterator.next();
|
entityinsentient = (EntityInsentient) iterator.next();
|
||||||
if (entityinsentient.getLeashHolder() == entityhuman) {
|
if (entityinsentient.getLeashHolder() == entityhuman) {
|
||||||
+ // CraftBukkit start
|
+ // CraftBukkit start
|
||||||
+ if (CraftEventFactory.callPlayerLeashEntityEvent(entityinsentient, this, entityhuman).isCancelled()) {
|
+ if (CraftEventFactory.callPlayerLeashEntityEvent(entityinsentient, this, entityhuman, enumhand).isCancelled()) {
|
||||||
+ ((EntityPlayer) entityhuman).connection.send(new PacketPlayOutAttachEntity(entityinsentient, entityinsentient.getLeashHolder()));
|
+ ((EntityPlayer) entityhuman).connection.send(new PacketPlayOutAttachEntity(entityinsentient, entityinsentient.getLeashHolder()));
|
||||||
+ continue;
|
+ continue;
|
||||||
+ }
|
+ }
|
||||||
@ -43,7 +43,7 @@
|
|||||||
if (entityinsentient.isLeashed() && entityinsentient.getLeashHolder() == this) {
|
if (entityinsentient.isLeashed() && entityinsentient.getLeashHolder() == this) {
|
||||||
- entityinsentient.dropLeash(true, false);
|
- entityinsentient.dropLeash(true, false);
|
||||||
+ // CraftBukkit start
|
+ // CraftBukkit start
|
||||||
+ if (CraftEventFactory.callPlayerUnleashEntityEvent(entityinsentient, entityhuman).isCancelled()) {
|
+ if (CraftEventFactory.callPlayerUnleashEntityEvent(entityinsentient, entityhuman, enumhand).isCancelled()) {
|
||||||
+ die = false;
|
+ die = false;
|
||||||
+ continue;
|
+ continue;
|
||||||
+ }
|
+ }
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
if (!world.isClientSide) {
|
if (!world.isClientSide) {
|
||||||
- world.addFreshEntity(entityboat);
|
- world.addFreshEntity(entityboat);
|
||||||
+ // CraftBukkit start
|
+ // CraftBukkit start
|
||||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPlaceEvent(world, movingobjectpositionblock.getBlockPos(), movingobjectpositionblock.getDirection(), entityhuman, entityboat).isCancelled()) {
|
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPlaceEvent(world, movingobjectpositionblock.getBlockPos(), movingobjectpositionblock.getDirection(), entityhuman, entityboat, enumhand).isCancelled()) {
|
||||||
+ return InteractionResultWrapper.fail(itemstack);
|
+ return InteractionResultWrapper.fail(itemstack);
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
+ // CraftBukkit start
|
+ // CraftBukkit start
|
||||||
+ ItemStack dummyFluid = ifluidsource.pickupBlock(DummyGeneratorAccess.INSTANCE, blockposition, iblockdata);
|
+ ItemStack dummyFluid = ifluidsource.pickupBlock(DummyGeneratorAccess.INSTANCE, blockposition, iblockdata);
|
||||||
+ if (dummyFluid.isEmpty()) return InteractionResultWrapper.fail(itemstack); // Don't fire event if the bucket won't be filled.
|
+ if (dummyFluid.isEmpty()) return InteractionResultWrapper.fail(itemstack); // Don't fire event if the bucket won't be filled.
|
||||||
+ PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent((WorldServer) world, entityhuman, blockposition, blockposition, movingobjectpositionblock.getDirection(), itemstack, dummyFluid.getItem());
|
+ PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent((WorldServer) world, entityhuman, blockposition, blockposition, movingobjectpositionblock.getDirection(), itemstack, dummyFluid.getItem(), enumhand);
|
||||||
+
|
+
|
||||||
+ if (event.isCancelled()) {
|
+ if (event.isCancelled()) {
|
||||||
+ ((EntityPlayer) entityhuman).connection.send(new PacketPlayOutBlockChange(world, blockposition)); // SPIGOT-5163 (see PlayerInteractManager)
|
+ ((EntityPlayer) entityhuman).connection.send(new PacketPlayOutBlockChange(world, blockposition)); // SPIGOT-5163 (see PlayerInteractManager)
|
||||||
@ -49,29 +49,30 @@
|
|||||||
BlockPosition blockposition2 = iblockdata.getBlock() instanceof IFluidContainer && this.content == FluidTypes.WATER ? blockposition : blockposition1;
|
BlockPosition blockposition2 = iblockdata.getBlock() instanceof IFluidContainer && this.content == FluidTypes.WATER ? blockposition : blockposition1;
|
||||||
|
|
||||||
- if (this.emptyContents(entityhuman, world, blockposition2, movingobjectpositionblock)) {
|
- if (this.emptyContents(entityhuman, world, blockposition2, movingobjectpositionblock)) {
|
||||||
+ if (this.emptyContents(entityhuman, world, blockposition2, movingobjectpositionblock, movingobjectpositionblock.getDirection(), blockposition, itemstack)) { // CraftBukkit
|
+ if (this.emptyContents(entityhuman, world, blockposition2, movingobjectpositionblock, movingobjectpositionblock.getDirection(), blockposition, itemstack, enumhand)) { // CraftBukkit
|
||||||
this.checkExtraContent(entityhuman, world, itemstack, blockposition2);
|
this.checkExtraContent(entityhuman, world, itemstack, blockposition2);
|
||||||
if (entityhuman instanceof EntityPlayer) {
|
if (entityhuman instanceof EntityPlayer) {
|
||||||
CriterionTriggers.PLACED_BLOCK.trigger((EntityPlayer) entityhuman, blockposition2, itemstack);
|
CriterionTriggers.PLACED_BLOCK.trigger((EntityPlayer) entityhuman, blockposition2, itemstack);
|
||||||
@@ -110,6 +131,11 @@
|
@@ -110,6 +131,12 @@
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean emptyContents(@Nullable EntityHuman entityhuman, World world, BlockPosition blockposition, @Nullable MovingObjectPositionBlock movingobjectpositionblock) {
|
public boolean emptyContents(@Nullable EntityHuman entityhuman, World world, BlockPosition blockposition, @Nullable MovingObjectPositionBlock movingobjectpositionblock) {
|
||||||
+ return emptyContents(entityhuman, world, blockposition, movingobjectpositionblock, null, null, null);
|
+ // CraftBukkit start
|
||||||
|
+ return emptyContents(entityhuman, world, blockposition, movingobjectpositionblock, null, null, null, EnumHand.MAIN_HAND);
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ public boolean emptyContents(EntityHuman entityhuman, World world, BlockPosition blockposition, @Nullable MovingObjectPositionBlock movingobjectpositionblock, EnumDirection enumdirection, BlockPosition clicked, ItemStack itemstack) {
|
+ public boolean emptyContents(EntityHuman entityhuman, World world, BlockPosition blockposition, @Nullable MovingObjectPositionBlock movingobjectpositionblock, EnumDirection enumdirection, BlockPosition clicked, ItemStack itemstack, EnumHand enumhand) {
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
if (!(this.content instanceof FluidTypeFlowing)) {
|
if (!(this.content instanceof FluidTypeFlowing)) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
@@ -119,8 +145,18 @@
|
@@ -119,8 +146,18 @@
|
||||||
boolean flag = iblockdata.canBeReplaced(this.content);
|
boolean flag = iblockdata.canBeReplaced(this.content);
|
||||||
boolean flag1 = iblockdata.isAir() || flag || block instanceof IFluidContainer && ((IFluidContainer) block).canPlaceLiquid(world, blockposition, iblockdata, this.content);
|
boolean flag1 = iblockdata.isAir() || flag || block instanceof IFluidContainer && ((IFluidContainer) block).canPlaceLiquid(world, blockposition, iblockdata, this.content);
|
||||||
|
|
||||||
+ // CraftBukkit start
|
+ // CraftBukkit start
|
||||||
+ if (flag1 && entityhuman != null) {
|
+ if (flag1 && entityhuman != null) {
|
||||||
+ PlayerBucketEmptyEvent event = CraftEventFactory.callPlayerBucketEmptyEvent((WorldServer) world, entityhuman, blockposition, clicked, enumdirection, itemstack);
|
+ PlayerBucketEmptyEvent event = CraftEventFactory.callPlayerBucketEmptyEvent((WorldServer) world, entityhuman, blockposition, clicked, enumdirection, itemstack, enumhand);
|
||||||
+ if (event.isCancelled()) {
|
+ if (event.isCancelled()) {
|
||||||
+ ((EntityPlayer) entityhuman).connection.send(new PacketPlayOutBlockChange(world, blockposition)); // SPIGOT-4238: needed when looking through entity
|
+ ((EntityPlayer) entityhuman).connection.send(new PacketPlayOutBlockChange(world, blockposition)); // SPIGOT-4238: needed when looking through entity
|
||||||
+ ((EntityPlayer) entityhuman).getBukkitEntity().updateInventory(); // SPIGOT-4541
|
+ ((EntityPlayer) entityhuman).getBukkitEntity().updateInventory(); // SPIGOT-4541
|
||||||
@ -81,7 +82,7 @@
|
|||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
if (!flag1) {
|
if (!flag1) {
|
||||||
- return movingobjectpositionblock != null && this.emptyContents(entityhuman, world, movingobjectpositionblock.getBlockPos().relative(movingobjectpositionblock.getDirection()), (MovingObjectPositionBlock) null);
|
- return movingobjectpositionblock != null && this.emptyContents(entityhuman, world, movingobjectpositionblock.getBlockPos().relative(movingobjectpositionblock.getDirection()), (MovingObjectPositionBlock) null);
|
||||||
+ return movingobjectpositionblock != null && this.emptyContents(entityhuman, world, movingobjectpositionblock.getBlockPos().relative(movingobjectpositionblock.getDirection()), (MovingObjectPositionBlock) null, enumdirection, clicked, itemstack); // CraftBukkit
|
+ return movingobjectpositionblock != null && this.emptyContents(entityhuman, world, movingobjectpositionblock.getBlockPos().relative(movingobjectpositionblock.getDirection()), (MovingObjectPositionBlock) null, enumdirection, clicked, itemstack, enumhand); // CraftBukkit
|
||||||
} else if (world.dimensionType().ultraWarm() && this.content.is(TagsFluid.WATER)) {
|
} else if (world.dimensionType().ultraWarm() && this.content.is(TagsFluid.WATER)) {
|
||||||
int i = blockposition.getX();
|
int i = blockposition.getX();
|
||||||
int j = blockposition.getY();
|
int j = blockposition.getY();
|
||||||
|
@ -1,15 +1,18 @@
|
|||||||
--- a/net/minecraft/world/item/ItemFishingRod.java
|
--- a/net/minecraft/world/item/ItemFishingRod.java
|
||||||
+++ b/net/minecraft/world/item/ItemFishingRod.java
|
+++ b/net/minecraft/world/item/ItemFishingRod.java
|
||||||
@@ -11,6 +11,8 @@
|
@@ -11,6 +11,11 @@
|
||||||
import net.minecraft.world.level.World;
|
import net.minecraft.world.level.World;
|
||||||
import net.minecraft.world.level.gameevent.GameEvent;
|
import net.minecraft.world.level.gameevent.GameEvent;
|
||||||
|
|
||||||
+import org.bukkit.event.player.PlayerFishEvent; // CraftBukkit
|
+// CraftBukkit start
|
||||||
|
+import org.bukkit.event.player.PlayerFishEvent;
|
||||||
|
+import org.bukkit.craftbukkit.CraftEquipmentSlot;
|
||||||
|
+// CraftBukkit end
|
||||||
+
|
+
|
||||||
public class ItemFishingRod extends Item implements ItemVanishable {
|
public class ItemFishingRod extends Item implements ItemVanishable {
|
||||||
|
|
||||||
public ItemFishingRod(Item.Info item_info) {
|
public ItemFishingRod(Item.Info item_info) {
|
||||||
@@ -33,12 +35,23 @@
|
@@ -33,12 +38,23 @@
|
||||||
world.playSound((EntityHuman) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.FISHING_BOBBER_RETRIEVE, SoundCategory.NEUTRAL, 1.0F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F));
|
world.playSound((EntityHuman) null, entityhuman.getX(), entityhuman.getY(), entityhuman.getZ(), SoundEffects.FISHING_BOBBER_RETRIEVE, SoundCategory.NEUTRAL, 1.0F, 0.4F / (world.getRandom().nextFloat() * 0.4F + 0.8F));
|
||||||
entityhuman.gameEvent(GameEvent.ITEM_INTERACT_FINISH);
|
entityhuman.gameEvent(GameEvent.ITEM_INTERACT_FINISH);
|
||||||
} else {
|
} else {
|
||||||
@ -22,7 +25,7 @@
|
|||||||
- world.addFreshEntity(new EntityFishingHook(entityhuman, world, j, i));
|
- world.addFreshEntity(new EntityFishingHook(entityhuman, world, j, i));
|
||||||
+ // CraftBukkit start
|
+ // CraftBukkit start
|
||||||
+ EntityFishingHook entityfishinghook = new EntityFishingHook(entityhuman, world, j, i);
|
+ EntityFishingHook entityfishinghook = new EntityFishingHook(entityhuman, world, j, i);
|
||||||
+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), null, (org.bukkit.entity.FishHook) entityfishinghook.getBukkitEntity(), PlayerFishEvent.State.FISHING);
|
+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), null, (org.bukkit.entity.FishHook) entityfishinghook.getBukkitEntity(), CraftEquipmentSlot.getHand(enumhand), PlayerFishEvent.State.FISHING);
|
||||||
+ world.getCraftServer().getPluginManager().callEvent(playerFishEvent);
|
+ world.getCraftServer().getPluginManager().callEvent(playerFishEvent);
|
||||||
+
|
+
|
||||||
+ if (playerFishEvent.isCancelled()) {
|
+ if (playerFishEvent.isCancelled()) {
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
public class ItemHanging extends Item {
|
public class ItemHanging extends Item {
|
||||||
|
|
||||||
private final EntityTypes<? extends EntityHanging> type;
|
private final EntityTypes<? extends EntityHanging> type;
|
||||||
@@ -65,6 +70,18 @@
|
@@ -65,6 +70,19 @@
|
||||||
|
|
||||||
if (((EntityHanging) object).survives()) {
|
if (((EntityHanging) object).survives()) {
|
||||||
if (!world.isClientSide) {
|
if (!world.isClientSide) {
|
||||||
@ -20,8 +20,9 @@
|
|||||||
+ Player who = (itemactioncontext.getPlayer() == null) ? null : (Player) itemactioncontext.getPlayer().getBukkitEntity();
|
+ Player who = (itemactioncontext.getPlayer() == null) ? null : (Player) itemactioncontext.getPlayer().getBukkitEntity();
|
||||||
+ org.bukkit.block.Block blockClicked = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
|
+ org.bukkit.block.Block blockClicked = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
|
||||||
+ org.bukkit.block.BlockFace blockFace = org.bukkit.craftbukkit.block.CraftBlock.notchToBlockFace(enumdirection);
|
+ org.bukkit.block.BlockFace blockFace = org.bukkit.craftbukkit.block.CraftBlock.notchToBlockFace(enumdirection);
|
||||||
|
+ org.bukkit.inventory.EquipmentSlot hand = org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(itemactioncontext.getHand());
|
||||||
+
|
+
|
||||||
+ HangingPlaceEvent event = new HangingPlaceEvent((org.bukkit.entity.Hanging) ((EntityHanging) object).getBukkitEntity(), who, blockClicked, blockFace, org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemstack));
|
+ HangingPlaceEvent event = new HangingPlaceEvent((org.bukkit.entity.Hanging) ((EntityHanging) object).getBukkitEntity(), who, blockClicked, blockFace, hand, org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemstack));
|
||||||
+ world.getCraftServer().getPluginManager().callEvent(event);
|
+ world.getCraftServer().getPluginManager().callEvent(event);
|
||||||
+
|
+
|
||||||
+ if (event.isCancelled()) {
|
+ if (event.isCancelled()) {
|
||||||
|
@ -1,21 +1,43 @@
|
|||||||
--- a/net/minecraft/world/item/ItemLeash.java
|
--- a/net/minecraft/world/item/ItemLeash.java
|
||||||
+++ b/net/minecraft/world/item/ItemLeash.java
|
+++ b/net/minecraft/world/item/ItemLeash.java
|
||||||
@@ -15,6 +15,8 @@
|
@@ -15,6 +15,11 @@
|
||||||
import net.minecraft.world.level.gameevent.GameEvent;
|
import net.minecraft.world.level.gameevent.GameEvent;
|
||||||
import net.minecraft.world.phys.AxisAlignedBB;
|
import net.minecraft.world.phys.AxisAlignedBB;
|
||||||
|
|
||||||
+import org.bukkit.event.hanging.HangingPlaceEvent; // CraftBukkit
|
+// CraftBukkit start
|
||||||
|
+import org.bukkit.craftbukkit.CraftEquipmentSlot;
|
||||||
|
+import org.bukkit.event.hanging.HangingPlaceEvent;
|
||||||
|
+// CraftBukkit end
|
||||||
+
|
+
|
||||||
public class ItemLeash extends Item {
|
public class ItemLeash extends Item {
|
||||||
|
|
||||||
public ItemLeash(Item.Info item_info) {
|
public ItemLeash(Item.Info item_info) {
|
||||||
@@ -57,9 +59,25 @@
|
@@ -31,7 +36,7 @@
|
||||||
|
EntityHuman entityhuman = itemactioncontext.getPlayer();
|
||||||
|
|
||||||
|
if (!world.isClientSide && entityhuman != null) {
|
||||||
|
- bindPlayerMobs(entityhuman, world, blockposition);
|
||||||
|
+ bindPlayerMobs(entityhuman, world, blockposition, itemactioncontext.getHand()); // CraftBukkit - Pass hand
|
||||||
|
}
|
||||||
|
|
||||||
|
world.gameEvent(GameEvent.BLOCK_ATTACH, blockposition, GameEvent.a.of((Entity) entityhuman));
|
||||||
|
@@ -41,7 +46,7 @@
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- public static EnumInteractionResult bindPlayerMobs(EntityHuman entityhuman, World world, BlockPosition blockposition) {
|
||||||
|
+ public static EnumInteractionResult bindPlayerMobs(EntityHuman entityhuman, World world, BlockPosition blockposition, net.minecraft.world.EnumHand enumhand) { // CraftBukkit - Add EnumHand
|
||||||
|
EntityLeash entityleash = null;
|
||||||
|
boolean flag = false;
|
||||||
|
double d0 = 7.0D;
|
||||||
|
@@ -57,9 +62,26 @@
|
||||||
if (entityinsentient.getLeashHolder() == entityhuman) {
|
if (entityinsentient.getLeashHolder() == entityhuman) {
|
||||||
if (entityleash == null) {
|
if (entityleash == null) {
|
||||||
entityleash = EntityLeash.getOrCreateKnot(world, blockposition);
|
entityleash = EntityLeash.getOrCreateKnot(world, blockposition);
|
||||||
+
|
+
|
||||||
+ // CraftBukkit start - fire HangingPlaceEvent
|
+ // CraftBukkit start - fire HangingPlaceEvent
|
||||||
+ HangingPlaceEvent event = new HangingPlaceEvent((org.bukkit.entity.Hanging) entityleash.getBukkitEntity(), entityhuman != null ? (org.bukkit.entity.Player) entityhuman.getBukkitEntity() : null, world.getWorld().getBlockAt(i, j, k), org.bukkit.block.BlockFace.SELF);
|
+ org.bukkit.inventory.EquipmentSlot hand = CraftEquipmentSlot.getHand(enumhand);
|
||||||
|
+ HangingPlaceEvent event = new HangingPlaceEvent((org.bukkit.entity.Hanging) entityleash.getBukkitEntity(), entityhuman != null ? (org.bukkit.entity.Player) entityhuman.getBukkitEntity() : null, world.getWorld().getBlockAt(i, j, k), org.bukkit.block.BlockFace.SELF, hand);
|
||||||
+ world.getCraftServer().getPluginManager().callEvent(event);
|
+ world.getCraftServer().getPluginManager().callEvent(event);
|
||||||
+
|
+
|
||||||
+ if (event.isCancelled()) {
|
+ if (event.isCancelled()) {
|
||||||
@ -27,7 +49,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
+ // CraftBukkit start
|
+ // CraftBukkit start
|
||||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerLeashEntityEvent(entityinsentient, entityleash, entityhuman).isCancelled()) {
|
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerLeashEntityEvent(entityinsentient, entityleash, entityhuman, enumhand).isCancelled()) {
|
||||||
+ continue;
|
+ continue;
|
||||||
+ }
|
+ }
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
@ -35,3 +57,14 @@
|
|||||||
entityinsentient.setLeashedTo(entityleash, true);
|
entityinsentient.setLeashedTo(entityleash, true);
|
||||||
flag = true;
|
flag = true;
|
||||||
}
|
}
|
||||||
|
@@ -67,4 +89,10 @@
|
||||||
|
|
||||||
|
return flag ? EnumInteractionResult.SUCCESS : EnumInteractionResult.PASS;
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+ // CraftBukkit start
|
||||||
|
+ public static EnumInteractionResult bindPlayerMobs(EntityHuman entityhuman, World world, BlockPosition blockposition) {
|
||||||
|
+ return bindPlayerMobs(entityhuman, world, blockposition, net.minecraft.world.EnumHand.MAIN_HAND);
|
||||||
|
+ }
|
||||||
|
+ // CraftBukkit end
|
||||||
|
}
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
|
|
||||||
- popResource(world, blockposition, new ItemStack(Items.SWEET_BERRIES, j + (flag ? 1 : 0)));
|
- popResource(world, blockposition, new ItemStack(Items.SWEET_BERRIES, j + (flag ? 1 : 0)));
|
||||||
+ // CraftBukkit start
|
+ // CraftBukkit start
|
||||||
+ PlayerHarvestBlockEvent event = CraftEventFactory.callPlayerHarvestBlockEvent(world, blockposition, entityhuman, Collections.singletonList(new ItemStack(Items.SWEET_BERRIES, j + (flag ? 1 : 0))));
|
+ PlayerHarvestBlockEvent event = CraftEventFactory.callPlayerHarvestBlockEvent(world, blockposition, entityhuman, enumhand, Collections.singletonList(new ItemStack(Items.SWEET_BERRIES, j + (flag ? 1 : 0))));
|
||||||
+ if (event.isCancelled()) {
|
+ if (event.isCancelled()) {
|
||||||
+ return EnumInteractionResult.SUCCESS; // We need to return a success either way, because making it PASS or FAIL will result in a bug where cancelling while harvesting w/ block in hand places block
|
+ return EnumInteractionResult.SUCCESS; // We need to return a success either way, because making it PASS or FAIL will result in a bug where cancelling while harvesting w/ block in hand places block
|
||||||
+ }
|
+ }
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ if (entity instanceof EntityHuman) {
|
+ if (entity instanceof EntityHuman) {
|
||||||
+ PlayerHarvestBlockEvent event = CraftEventFactory.callPlayerHarvestBlockEvent(world, blockposition, (EntityHuman) entity, Collections.singletonList(new ItemStack(Items.GLOW_BERRIES, 1)));
|
+ PlayerHarvestBlockEvent event = CraftEventFactory.callPlayerHarvestBlockEvent(world, blockposition, (EntityHuman) entity, net.minecraft.world.EnumHand.MAIN_HAND, Collections.singletonList(new ItemStack(Items.GLOW_BERRIES, 1)));
|
||||||
+ if (event.isCancelled()) {
|
+ if (event.isCancelled()) {
|
||||||
+ return EnumInteractionResult.SUCCESS; // We need to return a success either way, because making it PASS or FAIL will result in a bug where cancelling while harvesting w/ block in hand places block
|
+ return EnumInteractionResult.SUCCESS; // We need to return a success either way, because making it PASS or FAIL will result in a bug where cancelling while harvesting w/ block in hand places block
|
||||||
+ }
|
+ }
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package org.bukkit.craftbukkit;
|
package org.bukkit.craftbukkit;
|
||||||
|
|
||||||
|
import net.minecraft.world.EnumHand;
|
||||||
import net.minecraft.world.entity.EnumItemSlot;
|
import net.minecraft.world.entity.EnumItemSlot;
|
||||||
import org.bukkit.inventory.EquipmentSlot;
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
|
|
||||||
@ -29,4 +30,18 @@ public class CraftEquipmentSlot {
|
|||||||
public static EnumItemSlot getNMS(EquipmentSlot slot) {
|
public static EnumItemSlot getNMS(EquipmentSlot slot) {
|
||||||
return slots[slot.ordinal()];
|
return slots[slot.ordinal()];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static EquipmentSlot getHand(EnumHand enumhand) {
|
||||||
|
return (enumhand == EnumHand.MAIN_HAND) ? EquipmentSlot.HAND : EquipmentSlot.OFF_HAND;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static EnumHand getHand(EquipmentSlot hand) {
|
||||||
|
if (hand == EquipmentSlot.HAND) {
|
||||||
|
return EnumHand.MAIN_HAND;
|
||||||
|
} else if (hand == EquipmentSlot.OFF_HAND) {
|
||||||
|
return EnumHand.OFF_HAND;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new IllegalArgumentException("EquipmentSlot." + hand + " is not a hand");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,7 @@ import net.minecraft.world.entity.EntityExperienceOrb;
|
|||||||
import net.minecraft.world.entity.EntityInsentient;
|
import net.minecraft.world.entity.EntityInsentient;
|
||||||
import net.minecraft.world.entity.EntityLiving;
|
import net.minecraft.world.entity.EntityLiving;
|
||||||
import net.minecraft.world.entity.EntityTypes;
|
import net.minecraft.world.entity.EntityTypes;
|
||||||
|
import net.minecraft.world.entity.EnumItemSlot;
|
||||||
import net.minecraft.world.entity.animal.EntityAnimal;
|
import net.minecraft.world.entity.animal.EntityAnimal;
|
||||||
import net.minecraft.world.entity.animal.EntityFish;
|
import net.minecraft.world.entity.animal.EntityFish;
|
||||||
import net.minecraft.world.entity.animal.EntityGolem;
|
import net.minecraft.world.entity.animal.EntityGolem;
|
||||||
@ -77,6 +78,7 @@ import org.bukkit.block.Block;
|
|||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.craftbukkit.CraftChunk;
|
import org.bukkit.craftbukkit.CraftChunk;
|
||||||
|
import org.bukkit.craftbukkit.CraftEquipmentSlot;
|
||||||
import org.bukkit.craftbukkit.CraftLootTable;
|
import org.bukkit.craftbukkit.CraftLootTable;
|
||||||
import org.bukkit.craftbukkit.CraftRaid;
|
import org.bukkit.craftbukkit.CraftRaid;
|
||||||
import org.bukkit.craftbukkit.CraftServer;
|
import org.bukkit.craftbukkit.CraftServer;
|
||||||
@ -304,10 +306,10 @@ public class CraftEventFactory {
|
|||||||
/**
|
/**
|
||||||
* Player Harvest Block Event
|
* Player Harvest Block Event
|
||||||
*/
|
*/
|
||||||
public static PlayerHarvestBlockEvent callPlayerHarvestBlockEvent(World world, BlockPosition blockposition, EntityHuman who, List<ItemStack> itemsToHarvest) {
|
public static PlayerHarvestBlockEvent callPlayerHarvestBlockEvent(World world, BlockPosition blockposition, EntityHuman who, EnumHand enumhand, List<ItemStack> itemsToHarvest) {
|
||||||
List<org.bukkit.inventory.ItemStack> bukkitItemsToHarvest = new ArrayList<>(itemsToHarvest.stream().map(CraftItemStack::asBukkitCopy).collect(Collectors.toList()));
|
List<org.bukkit.inventory.ItemStack> bukkitItemsToHarvest = new ArrayList<>(itemsToHarvest.stream().map(CraftItemStack::asBukkitCopy).collect(Collectors.toList()));
|
||||||
Player player = (Player) who.getBukkitEntity();
|
Player player = (Player) who.getBukkitEntity();
|
||||||
PlayerHarvestBlockEvent playerHarvestBlockEvent = new PlayerHarvestBlockEvent(player, CraftBlock.at(world, blockposition), bukkitItemsToHarvest);
|
PlayerHarvestBlockEvent playerHarvestBlockEvent = new PlayerHarvestBlockEvent(player, CraftBlock.at(world, blockposition), CraftEquipmentSlot.getHand(enumhand), bukkitItemsToHarvest);
|
||||||
Bukkit.getPluginManager().callEvent(playerHarvestBlockEvent);
|
Bukkit.getPluginManager().callEvent(playerHarvestBlockEvent);
|
||||||
return playerHarvestBlockEvent;
|
return playerHarvestBlockEvent;
|
||||||
}
|
}
|
||||||
@ -315,13 +317,15 @@ public class CraftEventFactory {
|
|||||||
/**
|
/**
|
||||||
* Player Fish Bucket Event
|
* Player Fish Bucket Event
|
||||||
*/
|
*/
|
||||||
public static PlayerBucketEntityEvent callPlayerFishBucketEvent(EntityLiving fish, EntityHuman entityHuman, ItemStack originalBucket, ItemStack entityBucket) {
|
public static PlayerBucketEntityEvent callPlayerFishBucketEvent(EntityLiving fish, EntityHuman entityHuman, ItemStack originalBucket, ItemStack entityBucket, EnumHand enumhand) {
|
||||||
Player player = (Player) entityHuman.getBukkitEntity();
|
Player player = (Player) entityHuman.getBukkitEntity();
|
||||||
|
EquipmentSlot hand = CraftEquipmentSlot.getHand(enumhand);
|
||||||
|
|
||||||
PlayerBucketEntityEvent event;
|
PlayerBucketEntityEvent event;
|
||||||
if (fish instanceof EntityFish) {
|
if (fish instanceof EntityFish) {
|
||||||
event = new PlayerBucketFishEvent(player, (Fish) fish.getBukkitEntity(), CraftItemStack.asBukkitCopy(originalBucket), CraftItemStack.asBukkitCopy(entityBucket));
|
event = new PlayerBucketFishEvent(player, (Fish) fish.getBukkitEntity(), CraftItemStack.asBukkitCopy(originalBucket), CraftItemStack.asBukkitCopy(entityBucket), hand);
|
||||||
} else {
|
} else {
|
||||||
event = new PlayerBucketEntityEvent(player, fish.getBukkitEntity(), CraftItemStack.asBukkitCopy(originalBucket), CraftItemStack.asBukkitCopy(entityBucket));
|
event = new PlayerBucketEntityEvent(player, fish.getBukkitEntity(), CraftItemStack.asBukkitCopy(originalBucket), CraftItemStack.asBukkitCopy(entityBucket), hand);
|
||||||
}
|
}
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
return event;
|
return event;
|
||||||
@ -406,15 +410,15 @@ public class CraftEventFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static EntityPlaceEvent callEntityPlaceEvent(ItemActionContext itemactioncontext, Entity entity) {
|
public static EntityPlaceEvent callEntityPlaceEvent(ItemActionContext itemactioncontext, Entity entity) {
|
||||||
return callEntityPlaceEvent(itemactioncontext.getLevel(), itemactioncontext.getClickedPos(), itemactioncontext.getClickedFace(), itemactioncontext.getPlayer(), entity);
|
return callEntityPlaceEvent(itemactioncontext.getLevel(), itemactioncontext.getClickedPos(), itemactioncontext.getClickedFace(), itemactioncontext.getPlayer(), entity, itemactioncontext.getHand());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static EntityPlaceEvent callEntityPlaceEvent(World world, BlockPosition clickPosition, EnumDirection clickedFace, EntityHuman human, Entity entity) {
|
public static EntityPlaceEvent callEntityPlaceEvent(World world, BlockPosition clickPosition, EnumDirection clickedFace, EntityHuman human, Entity entity, EnumHand enumhand) {
|
||||||
Player who = (human == null) ? null : (Player) human.getBukkitEntity();
|
Player who = (human == null) ? null : (Player) human.getBukkitEntity();
|
||||||
org.bukkit.block.Block blockClicked = CraftBlock.at(world, clickPosition);
|
org.bukkit.block.Block blockClicked = CraftBlock.at(world, clickPosition);
|
||||||
org.bukkit.block.BlockFace blockFace = org.bukkit.craftbukkit.block.CraftBlock.notchToBlockFace(clickedFace);
|
org.bukkit.block.BlockFace blockFace = org.bukkit.craftbukkit.block.CraftBlock.notchToBlockFace(clickedFace);
|
||||||
|
|
||||||
EntityPlaceEvent event = new EntityPlaceEvent(entity.getBukkitEntity(), who, blockClicked, blockFace);
|
EntityPlaceEvent event = new EntityPlaceEvent(entity.getBukkitEntity(), who, blockClicked, blockFace, CraftEquipmentSlot.getHand(enumhand));
|
||||||
entity.level.getCraftServer().getPluginManager().callEvent(event);
|
entity.level.getCraftServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
return event;
|
return event;
|
||||||
@ -423,15 +427,15 @@ public class CraftEventFactory {
|
|||||||
/**
|
/**
|
||||||
* Bucket methods
|
* Bucket methods
|
||||||
*/
|
*/
|
||||||
public static PlayerBucketEmptyEvent callPlayerBucketEmptyEvent(WorldServer world, EntityHuman who, BlockPosition changed, BlockPosition clicked, EnumDirection clickedFace, ItemStack itemInHand) {
|
public static PlayerBucketEmptyEvent callPlayerBucketEmptyEvent(WorldServer world, EntityHuman who, BlockPosition changed, BlockPosition clicked, EnumDirection clickedFace, ItemStack itemInHand, EnumHand enumhand) {
|
||||||
return (PlayerBucketEmptyEvent) getPlayerBucketEvent(false, world, who, changed, clicked, clickedFace, itemInHand, Items.BUCKET);
|
return (PlayerBucketEmptyEvent) getPlayerBucketEvent(false, world, who, changed, clicked, clickedFace, itemInHand, Items.BUCKET, enumhand);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PlayerBucketFillEvent callPlayerBucketFillEvent(WorldServer world, EntityHuman who, BlockPosition changed, BlockPosition clicked, EnumDirection clickedFace, ItemStack itemInHand, net.minecraft.world.item.Item bucket) {
|
public static PlayerBucketFillEvent callPlayerBucketFillEvent(WorldServer world, EntityHuman who, BlockPosition changed, BlockPosition clicked, EnumDirection clickedFace, ItemStack itemInHand, net.minecraft.world.item.Item bucket, EnumHand enumhand) {
|
||||||
return (PlayerBucketFillEvent) getPlayerBucketEvent(true, world, who, clicked, changed, clickedFace, itemInHand, bucket);
|
return (PlayerBucketFillEvent) getPlayerBucketEvent(true, world, who, clicked, changed, clickedFace, itemInHand, bucket, enumhand);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static PlayerEvent getPlayerBucketEvent(boolean isFilling, WorldServer world, EntityHuman who, BlockPosition changed, BlockPosition clicked, EnumDirection clickedFace, ItemStack itemstack, net.minecraft.world.item.Item item) {
|
private static PlayerEvent getPlayerBucketEvent(boolean isFilling, WorldServer world, EntityHuman who, BlockPosition changed, BlockPosition clicked, EnumDirection clickedFace, ItemStack itemstack, net.minecraft.world.item.Item item, EnumHand enumhand) {
|
||||||
Player player = (Player) who.getBukkitEntity();
|
Player player = (Player) who.getBukkitEntity();
|
||||||
CraftItemStack itemInHand = CraftItemStack.asNewCraftStack(item);
|
CraftItemStack itemInHand = CraftItemStack.asNewCraftStack(item);
|
||||||
Material bucket = CraftMagicNumbers.getMaterial(itemstack.getItem());
|
Material bucket = CraftMagicNumbers.getMaterial(itemstack.getItem());
|
||||||
@ -441,13 +445,14 @@ public class CraftEventFactory {
|
|||||||
Block block = CraftBlock.at(world, changed);
|
Block block = CraftBlock.at(world, changed);
|
||||||
Block blockClicked = CraftBlock.at(world, clicked);
|
Block blockClicked = CraftBlock.at(world, clicked);
|
||||||
BlockFace blockFace = CraftBlock.notchToBlockFace(clickedFace);
|
BlockFace blockFace = CraftBlock.notchToBlockFace(clickedFace);
|
||||||
|
EquipmentSlot hand = CraftEquipmentSlot.getHand(enumhand);
|
||||||
|
|
||||||
PlayerEvent event;
|
PlayerEvent event;
|
||||||
if (isFilling) {
|
if (isFilling) {
|
||||||
event = new PlayerBucketFillEvent(player, block, blockClicked, blockFace, bucket, itemInHand);
|
event = new PlayerBucketFillEvent(player, block, blockClicked, blockFace, bucket, itemInHand, hand);
|
||||||
((PlayerBucketFillEvent) event).setCancelled(!canBuild(world, player, changed.getX(), changed.getZ()));
|
((PlayerBucketFillEvent) event).setCancelled(!canBuild(world, player, changed.getX(), changed.getZ()));
|
||||||
} else {
|
} else {
|
||||||
event = new PlayerBucketEmptyEvent(player, block, blockClicked, blockFace, bucket, itemInHand);
|
event = new PlayerBucketEmptyEvent(player, block, blockClicked, blockFace, bucket, itemInHand, hand);
|
||||||
((PlayerBucketEmptyEvent) event).setCancelled(!canBuild(world, player, changed.getX(), changed.getZ()));
|
((PlayerBucketEmptyEvent) event).setCancelled(!canBuild(world, player, changed.getX(), changed.getZ()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1097,10 +1102,10 @@ public class CraftEventFactory {
|
|||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PlayerItemMendEvent callPlayerItemMendEvent(EntityHuman entity, EntityExperienceOrb orb, net.minecraft.world.item.ItemStack nmsMendedItem, int repairAmount) {
|
public static PlayerItemMendEvent callPlayerItemMendEvent(EntityHuman entity, EntityExperienceOrb orb, net.minecraft.world.item.ItemStack nmsMendedItem, EnumItemSlot slot, int repairAmount) {
|
||||||
Player player = (Player) entity.getBukkitEntity();
|
Player player = (Player) entity.getBukkitEntity();
|
||||||
org.bukkit.inventory.ItemStack bukkitStack = CraftItemStack.asCraftMirror(nmsMendedItem);
|
org.bukkit.inventory.ItemStack bukkitStack = CraftItemStack.asCraftMirror(nmsMendedItem);
|
||||||
PlayerItemMendEvent event = new PlayerItemMendEvent(player, bukkitStack, (ExperienceOrb) orb.getBukkitEntity(), repairAmount);
|
PlayerItemMendEvent event = new PlayerItemMendEvent(player, bukkitStack, CraftEquipmentSlot.getSlot(slot), (ExperienceOrb) orb.getBukkitEntity(), repairAmount);
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
@ -1379,14 +1384,14 @@ public class CraftEventFactory {
|
|||||||
return itemInHand;
|
return itemInHand;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PlayerUnleashEntityEvent callPlayerUnleashEntityEvent(EntityInsentient entity, EntityHuman player) {
|
public static PlayerUnleashEntityEvent callPlayerUnleashEntityEvent(EntityInsentient entity, EntityHuman player, EnumHand enumhand) {
|
||||||
PlayerUnleashEntityEvent event = new PlayerUnleashEntityEvent(entity.getBukkitEntity(), (Player) player.getBukkitEntity());
|
PlayerUnleashEntityEvent event = new PlayerUnleashEntityEvent(entity.getBukkitEntity(), (Player) player.getBukkitEntity(), CraftEquipmentSlot.getHand(enumhand));
|
||||||
entity.level.getCraftServer().getPluginManager().callEvent(event);
|
entity.level.getCraftServer().getPluginManager().callEvent(event);
|
||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PlayerLeashEntityEvent callPlayerLeashEntityEvent(EntityInsentient entity, Entity leashHolder, EntityHuman player) {
|
public static PlayerLeashEntityEvent callPlayerLeashEntityEvent(EntityInsentient entity, Entity leashHolder, EntityHuman player, EnumHand enumhand) {
|
||||||
PlayerLeashEntityEvent event = new PlayerLeashEntityEvent(entity.getBukkitEntity(), leashHolder.getBukkitEntity(), (Player) player.getBukkitEntity());
|
PlayerLeashEntityEvent event = new PlayerLeashEntityEvent(entity.getBukkitEntity(), leashHolder.getBukkitEntity(), (Player) player.getBukkitEntity(), CraftEquipmentSlot.getHand(enumhand));
|
||||||
entity.level.getCraftServer().getPluginManager().callEvent(event);
|
entity.level.getCraftServer().getPluginManager().callEvent(event);
|
||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user