Files
CatServer/patches/net/minecraft/entity/monster/AbstractSkeleton.java.patch
2019-08-06 04:32:24 +08:00

61 lines
2.7 KiB
Diff

--- ../src-base/minecraft/net/minecraft/entity/monster/AbstractSkeleton.java
+++ ../src-work/minecraft/net/minecraft/entity/monster/AbstractSkeleton.java
@@ -42,6 +42,7 @@
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
+import org.bukkit.event.entity.EntityCombustEvent;
public abstract class AbstractSkeleton extends EntityMob implements IRangedAttackMob
{
@@ -136,7 +137,13 @@
if (flag)
{
- this.setFire(8);
+ // this.setFire(8);
+ EntityCombustEvent event = new EntityCombustEvent(this.getBukkitEntity(), 8);
+ this.world.getServer().getPluginManager().callEvent(event);
+
+ if (!event.isCancelled()) {
+ this.setFire(event.getDuration());
+ }
}
}
}
@@ -192,7 +199,7 @@
this.tasks.removeTask(this.aiArrowAttack);
ItemStack itemstack = this.getHeldItemMainhand();
- if (itemstack.getItem() == Items.BOW)
+ if (itemstack.getItem() instanceof net.minecraft.item.ItemBow)
{
int i = 20;
@@ -214,13 +221,24 @@
public void attackEntityWithRangedAttack(EntityLivingBase target, float distanceFactor)
{
EntityArrow entityarrow = this.getArrow(distanceFactor);
+ if (this.getHeldItemMainhand().getItem() instanceof net.minecraft.item.ItemBow)
+ entityarrow = ((net.minecraft.item.ItemBow) this.getHeldItemMainhand().getItem()).customizeArrow(entityarrow);
double d0 = target.posX - this.posX;
double d1 = target.getEntityBoundingBox().minY + (double)(target.height / 3.0F) - entityarrow.posY;
double d2 = target.posZ - this.posZ;
double d3 = (double)MathHelper.sqrt(d0 * d0 + d2 * d2);
entityarrow.shoot(d0, d1 + d3 * 0.20000000298023224D, d2, 1.6F, (float)(14 - this.world.getDifficulty().getDifficultyId() * 4));
+ org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(this, this.getHeldItemMainhand(), entityarrow, 0.8F);
+ if (event.isCancelled()) {
+ event.getProjectile().remove();
+ return;
+ }
+
+ if (event.getProjectile() == entityarrow.getBukkitEntity()) {
+ world.spawnEntity(entityarrow);
+ }
this.playSound(SoundEvents.ENTITY_SKELETON_SHOOT, 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));
- this.world.spawnEntity(entityarrow);
+ // this.world.spawnEntity(entityarrow); // CraftBukkit - moved up
}
protected EntityArrow getArrow(float p_190726_1_)