mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-01 04:32:11 -07:00
More mobs
This commit is contained in:
@@ -18,17 +18,17 @@
|
||||
}
|
||||
}
|
||||
@@ -122,12 +_,14 @@
|
||||
public void addAdditionalSaveData(CompoundTag tag) {
|
||||
super.addAdditionalSaveData(tag);
|
||||
tag.putInt("Age", this.age);
|
||||
+ tag.putBoolean("AgeLocked", this.ageLocked); // Paper
|
||||
public void addAdditionalSaveData(CompoundTag compound) {
|
||||
super.addAdditionalSaveData(compound);
|
||||
compound.putInt("Age", this.age);
|
||||
+ compound.putBoolean("AgeLocked", this.ageLocked); // Paper
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readAdditionalSaveData(CompoundTag tag) {
|
||||
super.readAdditionalSaveData(tag);
|
||||
this.setAge(tag.getInt("Age"));
|
||||
+ this.ageLocked = tag.getBoolean("AgeLocked"); // Paper
|
||||
public void readAdditionalSaveData(CompoundTag compound) {
|
||||
super.readAdditionalSaveData(compound);
|
||||
this.setAge(compound.getInt("Age"));
|
||||
+ this.ageLocked = compound.getBoolean("AgeLocked"); // Paper
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -67,18 +67,18 @@
|
||||
private void ageUp() {
|
||||
if (this.level() instanceof ServerLevel serverLevel) {
|
||||
- this.convertTo(EntityType.FROG, ConversionParams.single(this, false, false), mob -> {
|
||||
+ Frog converted = this.convertTo(EntityType.FROG, ConversionParams.single(this, false, false), mob -> { // Paper
|
||||
+ Frog converted = this.convertTo(EntityType.FROG, ConversionParams.single(this, false, false), mob -> { // CraftBukkit
|
||||
mob.finalizeSpawn(serverLevel, this.level().getCurrentDifficultyAt(mob.blockPosition()), EntitySpawnReason.CONVERSION, null);
|
||||
mob.setPersistenceRequired();
|
||||
mob.fudgePositionAfterSizeChange(this.getDimensions(this.getPose()));
|
||||
this.playSound(SoundEvents.TADPOLE_GROW_UP, 0.15F, 1.0F);
|
||||
- });
|
||||
+ // Paper start
|
||||
+ // CraftBukkit start
|
||||
+ }, org.bukkit.event.entity.EntityTransformEvent.TransformReason.METAMORPHOSIS, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.METAMORPHOSIS);
|
||||
+ if (converted == null) {
|
||||
+ this.setAge(0); // Sets the age to 0 for avoid a loop if the event is canceled
|
||||
+ }
|
||||
+ // Paper end
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,19 @@
|
||||
--- a/net/minecraft/world/entity/animal/horse/AbstractChestedHorse.java
|
||||
+++ b/net/minecraft/world/entity/animal/horse/AbstractChestedHorse.java
|
||||
@@ -69,9 +_,16 @@
|
||||
super.dropEquipment(level);
|
||||
if (this.hasChest()) {
|
||||
this.spawnAtLocation(level, Blocks.CHEST);
|
||||
+ //this.setChest(false); // Paper - moved to post death logic
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper start
|
||||
+ protected void postDeathDropItems(org.bukkit.event.entity.EntityDeathEvent event) {
|
||||
+ if (this.hasChest() && (event == null || !event.isCancelled())) {
|
||||
this.setChest(false);
|
||||
}
|
||||
}
|
||||
+ // Paper end
|
||||
|
||||
@Override
|
||||
public void addAdditionalSaveData(CompoundTag compound) {
|
@@ -0,0 +1,200 @@
|
||||
--- a/net/minecraft/world/entity/animal/horse/AbstractHorse.java
|
||||
+++ b/net/minecraft/world/entity/animal/horse/AbstractHorse.java
|
||||
@@ -77,6 +_,17 @@
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraft.world.ticks.ContainerSingleItem;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import java.util.Arrays;
|
||||
+import java.util.List;
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.entity.HumanEntity;
|
||||
+import org.bukkit.event.entity.EntityRegainHealthEvent;
|
||||
+import org.bukkit.inventory.InventoryHolder;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public abstract class AbstractHorse extends Animal implements ContainerListener, HasCustomInventoryScreen, OwnableEntity, PlayerRideableJumping, Saddleable {
|
||||
public static final int EQUIPMENT_SLOT_OFFSET = 400;
|
||||
public static final int CHEST_SLOT_OFFSET = 499;
|
||||
@@ -145,7 +_,53 @@
|
||||
public boolean stillValid(Player player) {
|
||||
return player.getVehicle() == AbstractHorse.this || player.canInteractWithEntity(AbstractHorse.this, 4.0);
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start - add fields and methods
|
||||
+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
|
||||
+ private int maxStack = MAX_STACK;
|
||||
+
|
||||
+ @Override
|
||||
+ public List<ItemStack> getContents() {
|
||||
+ return Arrays.asList(this.getTheItem());
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void onOpen(CraftHumanEntity who) {
|
||||
+ this.transaction.add(who);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void onClose(CraftHumanEntity who) {
|
||||
+ this.transaction.remove(who);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public List<HumanEntity> getViewers() {
|
||||
+ return this.transaction;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public int getMaxStackSize() {
|
||||
+ return this.maxStack;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setMaxStackSize(int size) {
|
||||
+ this.maxStack = size;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public InventoryHolder getOwner() {
|
||||
+ return (org.bukkit.entity.AbstractHorse) AbstractHorse.this.getBukkitEntity();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public Location getLocation() {
|
||||
+ return AbstractHorse.this.getBukkitEntity().getLocation();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
};
|
||||
+ public int maxDomestication = 100; // CraftBukkit - store max domestication value
|
||||
|
||||
protected AbstractHorse(EntityType<? extends AbstractHorse> entityType, Level level) {
|
||||
super(entityType, level);
|
||||
@@ -284,7 +_,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
- public boolean isPushable() {
|
||||
+ public boolean isCollidable(boolean ignoreClimbing) { // Paper - Climbing should not bypass cramming gamerule
|
||||
return !this.isVehicle();
|
||||
}
|
||||
|
||||
@@ -340,7 +_,7 @@
|
||||
|
||||
protected void createInventory() {
|
||||
SimpleContainer simpleContainer = this.inventory;
|
||||
- this.inventory = new SimpleContainer(this.getInventorySize());
|
||||
+ this.inventory = new SimpleContainer(this.getInventorySize(), (org.bukkit.entity.AbstractHorse) this.getBukkitEntity()); // CraftBukkit
|
||||
if (simpleContainer != null) {
|
||||
simpleContainer.removeListener(this);
|
||||
int min = Math.min(simpleContainer.getContainerSize(), this.inventory.getContainerSize());
|
||||
@@ -448,7 +_,7 @@
|
||||
}
|
||||
|
||||
public int getMaxTemper() {
|
||||
- return 100;
|
||||
+ return this.maxDomestication; // CraftBukkit - return stored max domestication instead of 100
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -503,7 +_,7 @@
|
||||
i1 = 5;
|
||||
if (!this.level().isClientSide && this.isTamed() && this.getAge() == 0 && !this.isInLove()) {
|
||||
flag = true;
|
||||
- this.setInLove(player);
|
||||
+ this.setInLove(player, stack.copy()); // Paper - Fix EntityBreedEvent copying
|
||||
}
|
||||
} else if (stack.is(Items.GOLDEN_APPLE) || stack.is(Items.ENCHANTED_GOLDEN_APPLE)) {
|
||||
f = 10.0F;
|
||||
@@ -511,12 +_,12 @@
|
||||
i1 = 10;
|
||||
if (!this.level().isClientSide && this.isTamed() && this.getAge() == 0 && !this.isInLove()) {
|
||||
flag = true;
|
||||
- this.setInLove(player);
|
||||
+ this.setInLove(player, stack.copy()); // Paper - Fix EntityBreedEvent copying
|
||||
}
|
||||
}
|
||||
|
||||
if (this.getHealth() < this.getMaxHealth() && f > 0.0F) {
|
||||
- this.heal(f);
|
||||
+ this.heal(f, EntityRegainHealthEvent.RegainReason.EATING); // CraftBukkit
|
||||
flag = true;
|
||||
}
|
||||
|
||||
@@ -587,7 +_,7 @@
|
||||
super.aiStep();
|
||||
if (this.level() instanceof ServerLevel serverLevel && this.isAlive()) {
|
||||
if (this.random.nextInt(900) == 0 && this.deathTime == 0) {
|
||||
- this.heal(1.0F);
|
||||
+ this.heal(1.0F, EntityRegainHealthEvent.RegainReason.REGEN); // CraftBukkit
|
||||
}
|
||||
|
||||
if (this.canEatGrass()) {
|
||||
@@ -690,6 +_,15 @@
|
||||
}
|
||||
}
|
||||
|
||||
+ // Paper start - Horse API
|
||||
+ public void setMouthOpen(boolean open) {
|
||||
+ this.setFlag(FLAG_OPEN_MOUTH, open);
|
||||
+ }
|
||||
+ public boolean isMouthOpen() {
|
||||
+ return this.getFlag(FLAG_OPEN_MOUTH);
|
||||
+ }
|
||||
+ // Paper end - Horse API
|
||||
+
|
||||
@Override
|
||||
public InteractionResult mobInteract(Player player, InteractionHand hand) {
|
||||
if (this.isVehicle() || this.isBaby()) {
|
||||
@@ -727,6 +_,11 @@
|
||||
this.setFlag(16, eating);
|
||||
}
|
||||
|
||||
+ // Paper start - Horse API
|
||||
+ public void setForceStanding(boolean standing) {
|
||||
+ this.setFlag(FLAG_STANDING, standing);
|
||||
+ }
|
||||
+ // Paper end - Horse API
|
||||
public void setStanding(boolean standing) {
|
||||
if (standing) {
|
||||
this.setEating(false);
|
||||
@@ -838,6 +_,7 @@
|
||||
if (this.getOwnerUUID() != null) {
|
||||
compound.putUUID("Owner", this.getOwnerUUID());
|
||||
}
|
||||
+ compound.putInt("Bukkit.MaxDomestication", this.maxDomestication); // CraftBukkit
|
||||
|
||||
if (!this.inventory.getItem(0).isEmpty()) {
|
||||
compound.put("SaddleItem", this.inventory.getItem(0).save(this.registryAccess()));
|
||||
@@ -862,6 +_,11 @@
|
||||
if (uuid != null) {
|
||||
this.setOwnerUUID(uuid);
|
||||
}
|
||||
+ // CraftBukkit start
|
||||
+ if (compound.contains("Bukkit.MaxDomestication")) {
|
||||
+ this.maxDomestication = compound.getInt("Bukkit.MaxDomestication");
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
if (compound.contains("SaddleItem", 10)) {
|
||||
ItemStack itemStack = ItemStack.parse(this.registryAccess(), compound.getCompound("SaddleItem")).orElse(ItemStack.EMPTY);
|
||||
@@ -959,6 +_,17 @@
|
||||
|
||||
@Override
|
||||
public void handleStartJump(int jumpPower) {
|
||||
+ // CraftBukkit start
|
||||
+ float power;
|
||||
+ if (jumpPower >= 90) {
|
||||
+ power = 1.0F;
|
||||
+ } else {
|
||||
+ power = 0.4F + 0.4F * (float) jumpPower / 90.0F;
|
||||
+ }
|
||||
+ if (!CraftEventFactory.callHorseJumpEvent(this, power)) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.allowStandSliding = true;
|
||||
this.standIfPossible();
|
||||
this.playJumpSound();
|
@@ -0,0 +1,51 @@
|
||||
--- a/net/minecraft/world/entity/animal/horse/Llama.java
|
||||
+++ b/net/minecraft/world/entity/animal/horse/Llama.java
|
||||
@@ -71,17 +_,23 @@
|
||||
@Nullable
|
||||
private Llama caravanHead;
|
||||
@Nullable
|
||||
- private Llama caravanTail;
|
||||
+ public Llama caravanTail; // Paper
|
||||
|
||||
public Llama(EntityType<? extends Llama> entityType, Level level) {
|
||||
super(entityType, level);
|
||||
this.getNavigation().setRequiredPathLength(40.0F);
|
||||
+ this.maxDomestication = 30; // Paper - Missing entity API; configure max temper instead of a hardcoded value
|
||||
}
|
||||
|
||||
public boolean isTraderLlama() {
|
||||
return false;
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public void setStrengthPublic(int strength) {
|
||||
+ this.setStrength(strength);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
private void setStrength(int strength) {
|
||||
this.entityData.set(DATA_STRENGTH_ID, Math.max(1, Math.min(5, strength)));
|
||||
}
|
||||
@@ -168,12 +_,12 @@
|
||||
f = 10.0F;
|
||||
if (this.isTamed() && this.getAge() == 0 && this.canFallInLove()) {
|
||||
flag = true;
|
||||
- this.setInLove(player);
|
||||
+ this.setInLove(player, item.copy()); // Paper - Fix EntityBreedEvent copying
|
||||
}
|
||||
}
|
||||
|
||||
if (this.getHealth() < this.getMaxHealth() && f > 0.0F) {
|
||||
- this.heal(f);
|
||||
+ this.heal(f, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.EATING); // Paper - Add missing regain reason
|
||||
flag = true;
|
||||
}
|
||||
|
||||
@@ -295,7 +_,7 @@
|
||||
|
||||
@Override
|
||||
public int getMaxTemper() {
|
||||
- return 30;
|
||||
+ return super.getMaxTemper(); // Paper - Missing entity API; delegate to parent
|
||||
}
|
||||
|
||||
@Override
|
@@ -0,0 +1,11 @@
|
||||
--- a/net/minecraft/world/entity/animal/horse/SkeletonHorse.java
|
||||
+++ b/net/minecraft/world/entity/animal/horse/SkeletonHorse.java
|
||||
@@ -122,7 +_,7 @@
|
||||
public void aiStep() {
|
||||
super.aiStep();
|
||||
if (this.isTrap() && this.trapTime++ >= 18000) {
|
||||
- this.discard();
|
||||
+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,48 @@
|
||||
--- a/net/minecraft/world/entity/animal/horse/SkeletonTrapGoal.java
|
||||
+++ b/net/minecraft/world/entity/animal/horse/SkeletonTrapGoal.java
|
||||
@@ -18,6 +_,7 @@
|
||||
|
||||
public class SkeletonTrapGoal extends Goal {
|
||||
private final SkeletonHorse horse;
|
||||
+ private java.util.List<org.bukkit.entity.HumanEntity> eligiblePlayers; // Paper
|
||||
|
||||
public SkeletonTrapGoal(SkeletonHorse horse) {
|
||||
this.horse = horse;
|
||||
@@ -25,12 +_,13 @@
|
||||
|
||||
@Override
|
||||
public boolean canUse() {
|
||||
- return this.horse.level().hasNearbyAlivePlayer(this.horse.getX(), this.horse.getY(), this.horse.getZ(), 10.0);
|
||||
+ return !(this.eligiblePlayers = this.horse.level().findNearbyBukkitPlayers(this.horse.getX(), this.horse.getY(), this.horse.getZ(), 10.0, net.minecraft.world.entity.EntitySelector.PLAYER_AFFECTS_SPAWNING)).isEmpty(); // Paper - Affects Spawning API & SkeletonHorseTrapEvent
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
ServerLevel serverLevel = (ServerLevel)this.horse.level();
|
||||
+ if (!new com.destroystokyo.paper.event.entity.SkeletonHorseTrapEvent((org.bukkit.entity.SkeletonHorse) this.horse.getBukkitEntity(), this.eligiblePlayers).callEvent()) return; // Paper
|
||||
DifficultyInstance currentDifficultyAt = serverLevel.getCurrentDifficultyAt(this.horse.blockPosition());
|
||||
this.horse.setTrap(false);
|
||||
this.horse.setTamed(true);
|
||||
@@ -39,11 +_,11 @@
|
||||
if (lightningBolt != null) {
|
||||
lightningBolt.moveTo(this.horse.getX(), this.horse.getY(), this.horse.getZ());
|
||||
lightningBolt.setVisualOnly(true);
|
||||
- serverLevel.addFreshEntity(lightningBolt);
|
||||
+ serverLevel.strikeLightning(lightningBolt, org.bukkit.event.weather.LightningStrikeEvent.Cause.TRAP); // CraftBukkit
|
||||
Skeleton skeleton = this.createSkeleton(currentDifficultyAt, this.horse);
|
||||
if (skeleton != null) {
|
||||
skeleton.startRiding(this.horse);
|
||||
- serverLevel.addFreshEntityWithPassengers(skeleton);
|
||||
+ serverLevel.addFreshEntityWithPassengers(skeleton, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.TRAP); // CraftBukkit
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
AbstractHorse abstractHorse = this.createHorse(currentDifficultyAt);
|
||||
@@ -52,7 +_,7 @@
|
||||
if (skeleton1 != null) {
|
||||
skeleton1.startRiding(abstractHorse);
|
||||
abstractHorse.push(this.horse.getRandom().triangle(0.0, 1.1485), 0.0, this.horse.getRandom().triangle(0.0, 1.1485));
|
||||
- serverLevel.addFreshEntityWithPassengers(abstractHorse);
|
||||
+ serverLevel.addFreshEntityWithPassengers(abstractHorse, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.JOCKEY); // CraftBukkit
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,20 @@
|
||||
--- a/net/minecraft/world/entity/animal/horse/TraderLlama.java
|
||||
+++ b/net/minecraft/world/entity/animal/horse/TraderLlama.java
|
||||
@@ -89,7 +_,7 @@
|
||||
this.despawnDelay = this.isLeashedToWanderingTrader() ? ((WanderingTrader)this.getLeashHolder()).getDespawnDelay() - 1 : this.despawnDelay - 1;
|
||||
if (this.despawnDelay <= 0) {
|
||||
this.removeLeash();
|
||||
- this.discard();
|
||||
+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -148,7 +_,7 @@
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
- this.mob.setTarget(this.ownerLastHurtBy);
|
||||
+ this.mob.setTarget(this.ownerLastHurtBy, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_OWNER, true); // CraftBukkit
|
||||
Entity leashHolder = this.llama.getLeashHolder();
|
||||
if (leashHolder instanceof WanderingTrader) {
|
||||
this.timestamp = ((WanderingTrader)leashHolder).getLastHurtByMobTimestamp();
|
@@ -1,21 +1,5 @@
|
||||
--- a/net/minecraft/world/entity/monster/piglin/Piglin.java
|
||||
+++ b/net/minecraft/world/entity/monster/piglin/Piglin.java
|
||||
@@ -4,15 +_,6 @@
|
||||
import com.mojang.serialization.Dynamic;
|
||||
import java.util.List;
|
||||
import javax.annotation.Nullable;
|
||||
-import net.minecraft.core.BlockPos;
|
||||
-import net.minecraft.nbt.CompoundTag;
|
||||
-import net.minecraft.network.syncher.EntityDataAccessor;
|
||||
-import net.minecraft.network.syncher.EntityDataSerializers;
|
||||
-import net.minecraft.network.syncher.SynchedEntityData;
|
||||
-import net.minecraft.resources.ResourceLocation;
|
||||
-import net.minecraft.server.level.ServerLevel;
|
||||
-import net.minecraft.sounds.SoundEvent;
|
||||
-import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.tags.ItemTags;
|
||||
import net.minecraft.tags.TagKey;
|
||||
import net.minecraft.util.RandomSource;
|
||||
@@ -59,6 +_,25 @@
|
||||
import net.minecraft.world.level.ServerLevelAccessor;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
@@ -79,7 +63,7 @@
|
||||
}
|
||||
|
||||
@VisibleForDebug
|
||||
@@ -325,7 +_,9 @@
|
||||
@@ -325,11 +_,16 @@
|
||||
@Override
|
||||
protected void finishConversion(ServerLevel serverLevel) {
|
||||
PiglinAi.cancelAdmiring(serverLevel, this);
|
||||
@@ -89,6 +73,13 @@
|
||||
super.finishConversion(serverLevel);
|
||||
}
|
||||
|
||||
+
|
||||
private ItemStack createSpawnWeapon() {
|
||||
+ // Food time for 10 minutes WOOP WOOP
|
||||
+ // Please send help cat started singing
|
||||
return this.random.nextFloat() < 0.5 ? new ItemStack(Items.CROSSBOW) : new ItemStack(Items.GOLDEN_SWORD);
|
||||
}
|
||||
|
||||
@@ -400,7 +_,7 @@
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user