mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-27 15:00:13 +01:00
net.minecraft.world.entity.animal.{armadillo|camel|sniffer}
This commit is contained in:
parent
db81fd3455
commit
ff9cf280c2
5 changed files with 94 additions and 171 deletions
|
@ -0,0 +1,46 @@
|
||||||
|
--- a/net/minecraft/world/entity/animal/armadillo/Armadillo.java
|
||||||
|
+++ b/net/minecraft/world/entity/animal/armadillo/Armadillo.java
|
||||||
|
@@ -141,10 +_,12 @@
|
||||||
|
ArmadilloAi.updateActivity(this);
|
||||||
|
profilerFiller.pop();
|
||||||
|
if (this.isAlive() && !this.isBaby() && --this.scuteTime <= 0) {
|
||||||
|
+ this.forceDrops = true; // CraftBukkit
|
||||||
|
if (this.dropFromGiftLootTable(level, BuiltInLootTables.ARMADILLO_SHED, this::spawnAtLocation)) {
|
||||||
|
this.playSound(SoundEvents.ARMADILLO_SCUTE_DROP, 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F);
|
||||||
|
this.gameEvent(GameEvent.ENTITY_PLACE);
|
||||||
|
}
|
||||||
|
+ this.forceDrops = false; // CraftBukkit
|
||||||
|
|
||||||
|
this.scuteTime = this.pickNextScuteDropTime();
|
||||||
|
}
|
||||||
|
@@ -283,7 +_,11 @@
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
- protected void actuallyHurt(ServerLevel level, DamageSource damageSource, float amount) {
|
||||||
|
+ // CraftBukkit start - void -> boolean
|
||||||
|
+ public boolean actuallyHurt(ServerLevel level, DamageSource damageSource, float amount, org.bukkit.event.entity.EntityDamageEvent event) {
|
||||||
|
+ boolean damageResult = super.actuallyHurt(level, damageSource, amount, event);
|
||||||
|
+ if (!damageResult) return false;
|
||||||
|
+ // CraftBukkit end
|
||||||
|
super.actuallyHurt(level, damageSource, amount);
|
||||||
|
if (!this.isNoAi() && !this.isDeadOrDying()) {
|
||||||
|
if (damageSource.getEntity() instanceof LivingEntity) {
|
||||||
|
@@ -295,6 +_,7 @@
|
||||||
|
this.rollOut();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
+ return true; // CraftBukkit
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@@ -313,7 +_,9 @@
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
if (this.level() instanceof ServerLevel serverLevel) {
|
||||||
|
+ this.forceDrops = true; // CraftBukkit
|
||||||
|
this.spawnAtLocation(serverLevel, new ItemStack(Items.ARMADILLO_SCUTE));
|
||||||
|
+ this.forceDrops = false; // CraftBukkit
|
||||||
|
this.gameEvent(GameEvent.ENTITY_INTERACT);
|
||||||
|
this.playSound(SoundEvents.ARMADILLO_BRUSH);
|
||||||
|
}
|
|
@ -1,59 +1,37 @@
|
||||||
--- a/net/minecraft/world/entity/animal/camel/Camel.java
|
--- a/net/minecraft/world/entity/animal/camel/Camel.java
|
||||||
+++ b/net/minecraft/world/entity/animal/camel/Camel.java
|
+++ b/net/minecraft/world/entity/animal/camel/Camel.java
|
||||||
@@ -49,6 +49,9 @@
|
@@ -386,12 +_,12 @@
|
||||||
import net.minecraft.world.level.gameevent.GameEvent;
|
} else {
|
||||||
import net.minecraft.world.phys.Vec2;
|
|
||||||
import net.minecraft.world.phys.Vec3;
|
|
||||||
+// CraftBukkit start
|
|
||||||
+import org.bukkit.event.entity.EntityDamageEvent;
|
|
||||||
+// CraftBukkit end
|
|
||||||
|
|
||||||
public class Camel extends AbstractHorse {
|
|
||||||
|
|
||||||
@@ -143,7 +146,7 @@
|
|
||||||
ProfilerFiller gameprofilerfiller = Profiler.get();
|
|
||||||
|
|
||||||
gameprofilerfiller.push("camelBrain");
|
|
||||||
- Brain<?> behaviorcontroller = this.getBrain();
|
|
||||||
+ Brain<Camel> behaviorcontroller = (Brain<Camel>) this.getBrain(); // CraftBukkit - decompile error
|
|
||||||
|
|
||||||
behaviorcontroller.tick(world, this);
|
|
||||||
gameprofilerfiller.pop();
|
|
||||||
@@ -386,13 +389,13 @@
|
|
||||||
boolean flag = this.getHealth() < this.getMaxHealth();
|
boolean flag = this.getHealth() < this.getMaxHealth();
|
||||||
|
|
||||||
if (flag) {
|
if (flag) {
|
||||||
- this.heal(2.0F);
|
- this.heal(2.0F);
|
||||||
+ this.heal(2.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.EATING); // Paper - Add missing regain reason
|
+ this.heal(2.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.EATING); // Paper - Add missing regain reason
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean flag1 = this.isTamed() && this.getAge() == 0 && this.canFallInLove();
|
boolean flag1 = this.isTamed() && this.getAge() == 0 && this.canFallInLove();
|
||||||
|
|
||||||
if (flag1) {
|
if (flag1) {
|
||||||
- this.setInLove(player);
|
- this.setInLove(player);
|
||||||
+ this.setInLove(player, item.copy()); // Paper - Fix EntityBreedEvent copying
|
+ this.setInLove(player, item.copy()); // Paper - Fix EntityBreedEvent copying
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean flag2 = this.isBaby();
|
boolean isBaby = this.isBaby();
|
||||||
@@ -454,9 +457,15 @@
|
@@ -451,9 +_,13 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
- protected void actuallyHurt(ServerLevel world, DamageSource source, float amount) {
|
- protected void actuallyHurt(ServerLevel level, DamageSource damageSource, float amount) {
|
||||||
+ // CraftBukkit start - void -> boolean
|
+ // CraftBukkit start - void -> boolean
|
||||||
+ public boolean actuallyHurt(ServerLevel worldserver, DamageSource damagesource, float f, EntityDamageEvent event) {
|
+ public boolean actuallyHurt(ServerLevel level, DamageSource damageSource, float amount, org.bukkit.event.entity.EntityDamageEvent event) {
|
||||||
+ boolean damageResult = super.actuallyHurt(worldserver, damagesource, f, event);
|
+ boolean damageResult = super.actuallyHurt(level, damageSource, amount, event);
|
||||||
+ if (!damageResult) {
|
+ if (!damageResult) return false;
|
||||||
+ return false;
|
|
||||||
+ }
|
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
this.standUpInstantly();
|
this.standUpInstantly();
|
||||||
- super.actuallyHurt(world, source, amount);
|
- super.actuallyHurt(level, damageSource, amount);
|
||||||
+ return true; // CraftBukkit
|
+ return true; // CraftBukkit
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -563,7 +572,7 @@
|
@@ -554,7 +_,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sitDown() {
|
public void sitDown() {
|
||||||
|
@ -62,7 +40,7 @@
|
||||||
this.makeSound(SoundEvents.CAMEL_SIT);
|
this.makeSound(SoundEvents.CAMEL_SIT);
|
||||||
this.setPose(Pose.SITTING);
|
this.setPose(Pose.SITTING);
|
||||||
this.gameEvent(GameEvent.ENTITY_ACTION);
|
this.gameEvent(GameEvent.ENTITY_ACTION);
|
||||||
@@ -572,7 +581,7 @@
|
@@ -563,7 +_,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public void standUp() {
|
public void standUp() {
|
||||||
|
@ -71,7 +49,7 @@
|
||||||
this.makeSound(SoundEvents.CAMEL_STAND);
|
this.makeSound(SoundEvents.CAMEL_STAND);
|
||||||
this.setPose(Pose.STANDING);
|
this.setPose(Pose.STANDING);
|
||||||
this.gameEvent(GameEvent.ENTITY_ACTION);
|
this.gameEvent(GameEvent.ENTITY_ACTION);
|
||||||
@@ -581,6 +590,7 @@
|
@@ -572,6 +_,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public void standUpInstantly() {
|
public void standUpInstantly() {
|
|
@ -0,0 +1,36 @@
|
||||||
|
--- a/net/minecraft/world/entity/animal/sniffer/Sniffer.java
|
||||||
|
+++ b/net/minecraft/world/entity/animal/sniffer/Sniffer.java
|
||||||
|
@@ -266,6 +_,13 @@
|
||||||
|
BlockPos headBlock = this.getHeadBlock();
|
||||||
|
this.dropFromGiftLootTable(serverLevel, BuiltInLootTables.SNIFFER_DIGGING, (serverLevel1, itemStack) -> {
|
||||||
|
ItemEntity itemEntity = new ItemEntity(this.level(), headBlock.getX(), headBlock.getY(), headBlock.getZ(), itemStack);
|
||||||
|
+ // CraftBukkit start - handle EntityDropItemEvent
|
||||||
|
+ org.bukkit.event.entity.EntityDropItemEvent event = new org.bukkit.event.entity.EntityDropItemEvent(this.getBukkitEntity(), (org.bukkit.entity.Item) itemEntity.getBukkitEntity());
|
||||||
|
+ org.bukkit.Bukkit.getPluginManager().callEvent(event);
|
||||||
|
+ if (event.isCancelled()) {
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+ // CraftBukkit end
|
||||||
|
itemEntity.setDefaultPickUpDelay();
|
||||||
|
serverLevel1.addFreshEntity(itemEntity);
|
||||||
|
});
|
||||||
|
@@ -325,12 +_,17 @@
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void spawnChildFromBreeding(ServerLevel level, Animal mate) {
|
||||||
|
+ // Paper start - Add EntityFertilizeEggEvent event
|
||||||
|
+ final io.papermc.paper.event.entity.EntityFertilizeEggEvent result = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityFertilizeEggEvent(this, mate);
|
||||||
|
+ if (result.isCancelled()) return;
|
||||||
|
+ // Paper end - Add EntityFertilizeEggEvent event
|
||||||
|
ItemStack itemStack = new ItemStack(Items.SNIFFER_EGG);
|
||||||
|
ItemEntity itemEntity = new ItemEntity(level, this.position().x(), this.position().y(), this.position().z(), itemStack);
|
||||||
|
itemEntity.setDefaultPickUpDelay();
|
||||||
|
- this.finalizeSpawnChildFromBreeding(level, mate, null);
|
||||||
|
+ this.finalizeSpawnChildFromBreeding(level, mate, null, result.getExperience()); // Paper - Add EntityFertilizeEggEvent event
|
||||||
|
+ if (this.spawnAtLocation(level, itemEntity) != null) { // Paper - Call EntityDropItemEvent
|
||||||
|
this.playSound(SoundEvents.SNIFFER_EGG_PLOP, 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 0.5F);
|
||||||
|
- level.addFreshEntity(itemEntity);
|
||||||
|
+ } // Paper - Call EntityDropItemEvent
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
|
@ -1,81 +0,0 @@
|
||||||
--- a/net/minecraft/world/entity/animal/armadillo/Armadillo.java
|
|
||||||
+++ b/net/minecraft/world/entity/animal/armadillo/Armadillo.java
|
|
||||||
@@ -47,6 +47,9 @@
|
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
|
||||||
import net.minecraft.world.level.gameevent.GameEvent;
|
|
||||||
import net.minecraft.world.level.storage.loot.BuiltInLootTables;
|
|
||||||
+// CraftBukkit start
|
|
||||||
+import org.bukkit.event.entity.EntityDamageEvent;
|
|
||||||
+// CraftBukkit end
|
|
||||||
|
|
||||||
public class Armadillo extends Animal {
|
|
||||||
|
|
||||||
@@ -135,16 +138,18 @@
|
|
||||||
ProfilerFiller gameprofilerfiller = Profiler.get();
|
|
||||||
|
|
||||||
gameprofilerfiller.push("armadilloBrain");
|
|
||||||
- this.brain.tick(world, this);
|
|
||||||
+ ((Brain<Armadillo>) this.brain).tick(world, this); // CraftBukkit - decompile error
|
|
||||||
gameprofilerfiller.pop();
|
|
||||||
gameprofilerfiller.push("armadilloActivityUpdate");
|
|
||||||
ArmadilloAi.updateActivity(this);
|
|
||||||
gameprofilerfiller.pop();
|
|
||||||
if (this.isAlive() && !this.isBaby() && --this.scuteTime <= 0) {
|
|
||||||
+ this.forceDrops = true; // CraftBukkit
|
|
||||||
if (this.dropFromGiftLootTable(world, BuiltInLootTables.ARMADILLO_SHED, this::spawnAtLocation)) {
|
|
||||||
this.playSound(SoundEvents.ARMADILLO_SCUTE_DROP, 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F);
|
|
||||||
this.gameEvent(GameEvent.ENTITY_PLACE);
|
|
||||||
}
|
|
||||||
+ this.forceDrops = false; // CraftBukkit
|
|
||||||
|
|
||||||
this.scuteTime = this.pickNextScuteDropTime();
|
|
||||||
}
|
|
||||||
@@ -291,19 +296,25 @@
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
- protected void actuallyHurt(ServerLevel world, DamageSource source, float amount) {
|
|
||||||
- super.actuallyHurt(world, source, amount);
|
|
||||||
+ // CraftBukkit start - void -> boolean
|
|
||||||
+ public boolean actuallyHurt(ServerLevel worldserver, DamageSource damagesource, float f, EntityDamageEvent event) {
|
|
||||||
+ boolean damageResult = super.actuallyHurt(worldserver, damagesource, f, event);
|
|
||||||
+ if (!damageResult) {
|
|
||||||
+ return false;
|
|
||||||
+ }
|
|
||||||
+ // CraftBukkit end
|
|
||||||
if (!this.isNoAi() && !this.isDeadOrDying()) {
|
|
||||||
- if (source.getEntity() instanceof LivingEntity) {
|
|
||||||
+ if (damagesource.getEntity() instanceof LivingEntity) {
|
|
||||||
this.getBrain().setMemoryWithExpiry(MemoryModuleType.DANGER_DETECTED_RECENTLY, true, 80L);
|
|
||||||
if (this.canStayRolledUp()) {
|
|
||||||
this.rollUp();
|
|
||||||
}
|
|
||||||
- } else if (source.is(DamageTypeTags.PANIC_ENVIRONMENTAL_CAUSES)) {
|
|
||||||
+ } else if (damagesource.is(DamageTypeTags.PANIC_ENVIRONMENTAL_CAUSES)) {
|
|
||||||
this.rollOut();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
+ return true; // CraftBukkit
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@@ -327,7 +338,9 @@
|
|
||||||
if (world instanceof ServerLevel) {
|
|
||||||
ServerLevel worldserver = (ServerLevel) world;
|
|
||||||
|
|
||||||
+ this.forceDrops = true; // CraftBukkit
|
|
||||||
this.spawnAtLocation(worldserver, new ItemStack(Items.ARMADILLO_SCUTE));
|
|
||||||
+ this.forceDrops = false; // CraftBukkit
|
|
||||||
this.gameEvent(GameEvent.ENTITY_INTERACT);
|
|
||||||
this.playSound(SoundEvents.ARMADILLO_BRUSH);
|
|
||||||
}
|
|
||||||
@@ -431,7 +444,7 @@
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Armadillo.ArmadilloState fromName(String name) {
|
|
||||||
- return (Armadillo.ArmadilloState) Armadillo.ArmadilloState.CODEC.byName(name, (Enum) Armadillo.ArmadilloState.IDLE);
|
|
||||||
+ return (Armadillo.ArmadilloState) Armadillo.ArmadilloState.CODEC.byName(name, Armadillo.ArmadilloState.IDLE); // CraftBukkit - decompile error
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
|
@ -1,56 +0,0 @@
|
||||||
--- a/net/minecraft/world/entity/animal/sniffer/Sniffer.java
|
|
||||||
+++ b/net/minecraft/world/entity/animal/sniffer/Sniffer.java
|
|
||||||
@@ -267,6 +267,13 @@
|
|
||||||
this.dropFromGiftLootTable(worldserver, BuiltInLootTables.SNIFFER_DIGGING, (worldserver1, itemstack) -> {
|
|
||||||
ItemEntity entityitem = new ItemEntity(this.level(), (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), itemstack);
|
|
||||||
|
|
||||||
+ // CraftBukkit start - handle EntityDropItemEvent
|
|
||||||
+ org.bukkit.event.entity.EntityDropItemEvent event = new org.bukkit.event.entity.EntityDropItemEvent(this.getBukkitEntity(), (org.bukkit.entity.Item) entityitem.getBukkitEntity());
|
|
||||||
+ org.bukkit.Bukkit.getPluginManager().callEvent(event);
|
|
||||||
+ if (event.isCancelled()) {
|
|
||||||
+ return;
|
|
||||||
+ }
|
|
||||||
+ // CraftBukkit end
|
|
||||||
entityitem.setDefaultPickUpDelay();
|
|
||||||
worldserver1.addFreshEntity(entityitem);
|
|
||||||
});
|
|
||||||
@@ -308,7 +315,7 @@
|
|
||||||
List<GlobalPos> list = (List) this.getExploredPositions().limit(20L).collect(Collectors.toList());
|
|
||||||
|
|
||||||
list.add(0, GlobalPos.of(this.level().dimension(), pos));
|
|
||||||
- this.getBrain().setMemory(MemoryModuleType.SNIFFER_EXPLORED_POSITIONS, (Object) list);
|
|
||||||
+ this.getBrain().setMemory(MemoryModuleType.SNIFFER_EXPLORED_POSITIONS, list); // CraftBukkit - decompile error
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -333,13 +340,19 @@
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void spawnChildFromBreeding(ServerLevel world, Animal other) {
|
|
||||||
+ // Paper start - Add EntityFertilizeEggEvent event
|
|
||||||
+ final io.papermc.paper.event.entity.EntityFertilizeEggEvent result = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityFertilizeEggEvent(this, other);
|
|
||||||
+ if (result.isCancelled()) return;
|
|
||||||
+ // Paper end - Add EntityFertilizeEggEvent event
|
|
||||||
+
|
|
||||||
ItemStack itemstack = new ItemStack(Items.SNIFFER_EGG);
|
|
||||||
ItemEntity entityitem = new ItemEntity(world, this.position().x(), this.position().y(), this.position().z(), itemstack);
|
|
||||||
|
|
||||||
entityitem.setDefaultPickUpDelay();
|
|
||||||
- this.finalizeSpawnChildFromBreeding(world, other, (AgeableMob) null);
|
|
||||||
+ this.finalizeSpawnChildFromBreeding(world, other, (AgeableMob) null, result.getExperience()); // Paper - Add EntityFertilizeEggEvent event
|
|
||||||
+ if (this.spawnAtLocation(world, entityitem) != null) { // Paper - Call EntityDropItemEvent
|
|
||||||
this.playSound(SoundEvents.SNIFFER_EGG_PLOP, 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 0.5F);
|
|
||||||
- world.addFreshEntity(entityitem);
|
|
||||||
+ } // Paper - Call EntityDropItemEvent
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@@ -444,7 +457,7 @@
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Brain<Sniffer> getBrain() {
|
|
||||||
- return super.getBrain();
|
|
||||||
+ return (Brain<Sniffer>) super.getBrain(); // CraftBukkit - decompile error
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
Loading…
Reference in a new issue