Files
CatServer/patches/net/minecraft/entity/ai/EntityAISkeletonRiders.java.patch
2019-02-24 22:29:41 +08:00

56 lines
3.1 KiB
Diff

--- ../src-base/minecraft/net/minecraft/entity/ai/EntityAISkeletonRiders.java
+++ ../src-work/minecraft/net/minecraft/entity/ai/EntityAISkeletonRiders.java
@@ -12,6 +12,8 @@
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.DifficultyInstance;
+import javax.annotation.Nullable;
+
public class EntityAISkeletonRiders extends EntityAIBase
{
private final EntitySkeletonHorse horse;
@@ -34,17 +36,19 @@
this.horse.setGrowingAge(0);
this.horse.world.addWeatherEffect(new EntityLightningBolt(this.horse.world, this.horse.posX, this.horse.posY, this.horse.posZ, true));
EntitySkeleton entityskeleton = this.createSkeleton(difficultyinstance, this.horse);
- entityskeleton.startRiding(this.horse);
+ if (entityskeleton != null) entityskeleton.startRiding(this.horse);
for (int i = 0; i < 3; ++i)
{
AbstractHorse abstracthorse = this.createHorse(difficultyinstance);
+ if (abstracthorse == null) continue; // CraftBukkit
EntitySkeleton entityskeleton1 = this.createSkeleton(difficultyinstance, abstracthorse);
- entityskeleton1.startRiding(abstracthorse);
+ if (entityskeleton1 != null) entityskeleton1.startRiding(abstracthorse);
abstracthorse.addVelocity(this.horse.getRNG().nextGaussian() * 0.5D, 0.0D, this.horse.getRNG().nextGaussian() * 0.5D);
}
}
+ @Nullable
private AbstractHorse createHorse(DifficultyInstance p_188515_1_)
{
EntitySkeletonHorse entityskeletonhorse = new EntitySkeletonHorse(this.horse.world);
@@ -54,10 +58,11 @@
entityskeletonhorse.enablePersistence();
entityskeletonhorse.setHorseTamed(true);
entityskeletonhorse.setGrowingAge(0);
- entityskeletonhorse.world.spawnEntity(entityskeletonhorse);
+ if (!entityskeletonhorse.world.addEntity(entityskeletonhorse, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.TRAP)) return null; // CraftBukkit
return entityskeletonhorse;
}
+ @Nullable
private EntitySkeleton createSkeleton(DifficultyInstance p_188514_1_, AbstractHorse p_188514_2_)
{
EntitySkeleton entityskeleton = new EntitySkeleton(p_188514_2_.world);
@@ -73,7 +78,7 @@
entityskeleton.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, EnchantmentHelper.addRandomEnchantment(entityskeleton.getRNG(), entityskeleton.getHeldItemMainhand(), (int)(5.0F + p_188514_1_.getClampedAdditionalDifficulty() * (float)entityskeleton.getRNG().nextInt(18)), false));
entityskeleton.setItemStackToSlot(EntityEquipmentSlot.HEAD, EnchantmentHelper.addRandomEnchantment(entityskeleton.getRNG(), entityskeleton.getItemStackFromSlot(EntityEquipmentSlot.HEAD), (int)(5.0F + p_188514_1_.getClampedAdditionalDifficulty() * (float)entityskeleton.getRNG().nextInt(18)), false));
- entityskeleton.world.spawnEntity(entityskeleton);
+ if (!entityskeleton.world.addEntity(entityskeleton, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.JOCKEY)) return null; // CraftBukkit
return entityskeleton;
}
}