#1209: Clean up various patches
By: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
This commit is contained in:
@@ -1,17 +1,18 @@
|
||||
--- a/net/minecraft/world/entity/ai/behavior/BehaviorFarm.java
|
||||
+++ b/net/minecraft/world/entity/ai/behavior/BehaviorFarm.java
|
||||
@@ -26,6 +26,10 @@
|
||||
@@ -26,6 +26,11 @@
|
||||
import net.minecraft.world.level.block.state.IBlockData;
|
||||
import net.minecraft.world.level.gameevent.GameEvent;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import net.minecraft.world.level.block.Blocks;
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class BehaviorFarm extends Behavior<EntityVillager> {
|
||||
|
||||
private static final int HARVEST_DURATION = 200;
|
||||
@@ -81,8 +85,8 @@
|
||||
@@ -81,8 +86,8 @@
|
||||
|
||||
protected void start(WorldServer worldserver, EntityVillager entityvillager, long i) {
|
||||
if (i > this.nextOkStartTime && this.aboveFarmlandPos != null) {
|
||||
@@ -22,37 +23,29 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -102,7 +106,11 @@
|
||||
@@ -102,7 +107,9 @@
|
||||
Block block1 = worldserver.getBlockState(this.aboveFarmlandPos.below()).getBlock();
|
||||
|
||||
if (block instanceof BlockCrops && ((BlockCrops) block).isMaxAge(iblockdata)) {
|
||||
- worldserver.destroyBlock(this.aboveFarmlandPos, true, entityvillager);
|
||||
+ // CraftBukkit start
|
||||
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entityvillager, this.aboveFarmlandPos, Blocks.AIR.defaultBlockState()).isCancelled()) {
|
||||
+ worldserver.destroyBlock(this.aboveFarmlandPos, true, entityvillager);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+ if (CraftEventFactory.callEntityChangeBlockEvent(entityvillager, this.aboveFarmlandPos, Blocks.AIR.defaultBlockState())) { // CraftBukkit
|
||||
worldserver.destroyBlock(this.aboveFarmlandPos, true, entityvillager);
|
||||
+ } // CraftBukkit
|
||||
}
|
||||
|
||||
if (iblockdata.isAir() && block1 instanceof BlockSoil && entityvillager.hasFarmSeeds()) {
|
||||
@@ -119,9 +127,13 @@
|
||||
@@ -119,9 +126,11 @@
|
||||
ItemBlock itemblock = (ItemBlock) item;
|
||||
IBlockData iblockdata1 = itemblock.getBlock().defaultBlockState();
|
||||
|
||||
- worldserver.setBlockAndUpdate(this.aboveFarmlandPos, iblockdata1);
|
||||
- worldserver.gameEvent(GameEvent.BLOCK_PLACE, this.aboveFarmlandPos, GameEvent.a.of(entityvillager, iblockdata1));
|
||||
- flag = true;
|
||||
+ // CraftBukkit start
|
||||
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entityvillager, this.aboveFarmlandPos, iblockdata1).isCancelled()) {
|
||||
+ worldserver.setBlockAndUpdate(this.aboveFarmlandPos, iblockdata1);
|
||||
+ worldserver.gameEvent(GameEvent.BLOCK_PLACE, this.aboveFarmlandPos, GameEvent.a.of(entityvillager, iblockdata1));
|
||||
+ flag = true;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+ if (CraftEventFactory.callEntityChangeBlockEvent(entityvillager, this.aboveFarmlandPos, iblockdata1)) { // CraftBukkit
|
||||
worldserver.setBlockAndUpdate(this.aboveFarmlandPos, iblockdata1);
|
||||
worldserver.gameEvent(GameEvent.BLOCK_PLACE, this.aboveFarmlandPos, GameEvent.a.of(entityvillager, iblockdata1));
|
||||
flag = true;
|
||||
+ } // CraftBukkit
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,8 +153,8 @@
|
||||
@@ -141,8 +150,8 @@
|
||||
this.aboveFarmlandPos = this.getValidFarmland(worldserver);
|
||||
if (this.aboveFarmlandPos != null) {
|
||||
this.nextOkStartTime = i + 20L;
|
||||
|
||||
@@ -1,26 +1,39 @@
|
||||
--- a/net/minecraft/world/entity/ai/behavior/BehaviorMakeLove.java
|
||||
+++ b/net/minecraft/world/entity/ai/behavior/BehaviorMakeLove.java
|
||||
@@ -116,11 +116,16 @@
|
||||
@@ -18,6 +18,11 @@
|
||||
import net.minecraft.world.entity.npc.EntityVillager;
|
||||
import net.minecraft.world.level.pathfinder.PathEntity;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class BehaviorMakeLove extends Behavior<EntityVillager> {
|
||||
|
||||
private static final int INTERACT_DIST_SQR = 5;
|
||||
@@ -116,11 +121,17 @@
|
||||
if (entityvillager2 == null) {
|
||||
return Optional.empty();
|
||||
} else {
|
||||
- entityvillager.setAge(6000);
|
||||
- entityvillager1.setAge(6000);
|
||||
+ // CraftBukkit start - call EntityBreedEvent
|
||||
entityvillager2.setAge(-24000);
|
||||
entityvillager2.moveTo(entityvillager.getX(), entityvillager.getY(), entityvillager.getZ(), 0.0F, 0.0F);
|
||||
- worldserver.addFreshEntityWithPassengers(entityvillager2);
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityBreedEvent(entityvillager2, entityvillager, entityvillager1, null, null, 0).isCancelled()) {
|
||||
+ // CraftBukkit start - call EntityBreedEvent
|
||||
+ if (CraftEventFactory.callEntityBreedEvent(entityvillager2, entityvillager, entityvillager1, null, null, 0).isCancelled()) {
|
||||
+ return Optional.empty();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+ // Move age setting down
|
||||
+ entityvillager.setAge(6000);
|
||||
+ entityvillager1.setAge(6000);
|
||||
+ worldserver.addFreshEntityWithPassengers(entityvillager2, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - added SpawnReason
|
||||
+ worldserver.addFreshEntityWithPassengers(entityvillager2, CreatureSpawnEvent.SpawnReason.BREEDING);
|
||||
+ // CraftBukkit end
|
||||
worldserver.broadcastEntityEvent(entityvillager2, (byte) 12);
|
||||
return Optional.of(entityvillager2);
|
||||
}
|
||||
@@ -129,6 +134,6 @@
|
||||
@@ -129,6 +140,6 @@
|
||||
private void giveBedToChild(WorldServer worldserver, EntityVillager entityvillager, BlockPosition blockposition) {
|
||||
GlobalPos globalpos = GlobalPos.of(worldserver.dimension(), blockposition);
|
||||
|
||||
|
||||
@@ -11,23 +11,21 @@
|
||||
public class PathfinderGoalEatTile extends PathfinderGoal {
|
||||
|
||||
private static final int EAT_ANIMATION_TICKS = 40;
|
||||
@@ -64,7 +68,8 @@
|
||||
@@ -64,7 +68,7 @@
|
||||
BlockPosition blockposition = this.mob.blockPosition();
|
||||
|
||||
if (PathfinderGoalEatTile.IS_TALL_GRASS.test(this.level.getBlockState(blockposition))) {
|
||||
- if (this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) {
|
||||
+ // CraftBukkit
|
||||
+ if (!CraftEventFactory.callEntityChangeBlockEvent(this.mob, blockposition, Blocks.AIR.defaultBlockState(), !this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)).isCancelled()) {
|
||||
+ if (CraftEventFactory.callEntityChangeBlockEvent(this.mob, blockposition, Blocks.AIR.defaultBlockState(), !this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING))) { // CraftBukkit
|
||||
this.level.destroyBlock(blockposition, false);
|
||||
}
|
||||
|
||||
@@ -73,7 +78,8 @@
|
||||
@@ -73,7 +77,7 @@
|
||||
BlockPosition blockposition1 = blockposition.below();
|
||||
|
||||
if (this.level.getBlockState(blockposition1).is(Blocks.GRASS_BLOCK)) {
|
||||
- if (this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) {
|
||||
+ // CraftBukkit
|
||||
+ if (!CraftEventFactory.callEntityChangeBlockEvent(this.mob, blockposition1, Blocks.AIR.defaultBlockState(), !this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)).isCancelled()) {
|
||||
+ if (CraftEventFactory.callEntityChangeBlockEvent(this.mob, blockposition1, Blocks.AIR.defaultBlockState(), !this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING))) { // CraftBukkit
|
||||
this.level.levelEvent(2001, blockposition1, Block.getId(Blocks.GRASS_BLOCK.defaultBlockState()));
|
||||
this.level.setBlock(blockposition1, Blocks.DIRT.defaultBlockState(), 2);
|
||||
}
|
||||
|
||||
@@ -6,28 +6,24 @@
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.craftbukkit.entity.CraftEntity;
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.event.entity.EntityTeleportEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class PathfinderGoalFollowOwner extends PathfinderGoal {
|
||||
|
||||
public static final int TELEPORT_WHEN_DISTANCE_IS = 12;
|
||||
@@ -122,7 +128,18 @@
|
||||
@@ -122,7 +128,14 @@
|
||||
} else if (!this.canTeleportTo(new BlockPosition(i, j, k))) {
|
||||
return false;
|
||||
} else {
|
||||
- this.tamable.moveTo((double) i + 0.5D, (double) j, (double) k + 0.5D, this.tamable.getYRot(), this.tamable.getXRot());
|
||||
+ // CraftBukkit start
|
||||
+ CraftEntity entity = this.tamable.getBukkitEntity();
|
||||
+ Location to = new Location(entity.getWorld(), (double) i + 0.5D, (double) j, (double) k + 0.5D, this.tamable.getYRot(), this.tamable.getXRot());
|
||||
+ EntityTeleportEvent event = new EntityTeleportEvent(entity, entity.getLocation(), to);
|
||||
+ this.tamable.level().getCraftServer().getPluginManager().callEvent(event);
|
||||
+ EntityTeleportEvent event = CraftEventFactory.callEntityTeleportEvent(this.tamable, (double) i + 0.5D, (double) j, (double) k + 0.5D);
|
||||
+ if (event.isCancelled()) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ to = event.getTo();
|
||||
+
|
||||
+ Location to = event.getTo();
|
||||
+ this.tamable.moveTo(to.getX(), to.getY(), to.getZ(), to.getYaw(), to.getPitch());
|
||||
+ // CraftBukkit end
|
||||
this.navigation.stop();
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
--- a/net/minecraft/world/entity/ai/goal/PathfinderGoalPanic.java
|
||||
+++ b/net/minecraft/world/entity/ai/goal/PathfinderGoalPanic.java
|
||||
@@ -10,6 +10,10 @@
|
||||
import net.minecraft.world.level.IBlockAccess;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import net.minecraft.world.entity.EntityLiving;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class PathfinderGoalPanic extends PathfinderGoal {
|
||||
|
||||
public static final int WATER_CHECK_DISTANCE_VERTICAL = 1;
|
||||
@@ -80,6 +84,12 @@
|
||||
|
||||
@Override
|
||||
public boolean canContinueToUse() {
|
||||
+ // CraftBukkit start - introduce a temporary timeout hack until this is fixed properly
|
||||
+ if ((this.mob.tickCount - this.mob.lastHurtByMobTimestamp) > 100) {
|
||||
+ this.mob.setLastHurtByMob((EntityLiving) null);
|
||||
+ return false;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
return !this.mob.getNavigation().isDone();
|
||||
}
|
||||
|
||||
@@ -89,6 +99,6 @@
|
||||
|
||||
return !iblockaccess.getBlockState(blockposition).getCollisionShape(iblockaccess, blockposition).isEmpty() ? null : (BlockPosition) BlockPosition.findClosestMatch(entity.blockPosition(), i, 1, (blockposition1) -> {
|
||||
return iblockaccess.getFluidState(blockposition1).is(TagsFluid.WATER);
|
||||
- }).orElse((Object) null);
|
||||
+ }).orElse(null); // CraftBukkit - decompile error
|
||||
}
|
||||
}
|
||||
@@ -6,21 +6,18 @@
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.block.CraftBlock;
|
||||
+import org.bukkit.event.entity.EntityInteractEvent;
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class PathfinderGoalRemoveBlock extends PathfinderGoalGotoTarget {
|
||||
|
||||
private final Block blockToRemove;
|
||||
@@ -96,6 +101,14 @@
|
||||
@@ -96,6 +101,11 @@
|
||||
}
|
||||
|
||||
if (this.ticksSinceReachedGoal > 60) {
|
||||
+ // CraftBukkit start - Step on eggs
|
||||
+ EntityInteractEvent event = new EntityInteractEvent(this.removerMob.getBukkitEntity(), CraftBlock.at(world, blockposition1));
|
||||
+ world.getCraftServer().getPluginManager().callEvent((EntityInteractEvent) event);
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
+ if (!CraftEventFactory.callEntityInteractEvent(this.removerMob, CraftBlock.at(world, blockposition1))) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
--- a/net/minecraft/world/entity/ai/goal/PathfinderGoalSit.java
|
||||
+++ b/net/minecraft/world/entity/ai/goal/PathfinderGoalSit.java
|
||||
@@ -22,7 +22,7 @@
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
@Override
|
||||
public boolean canUse() {
|
||||
if (!this.mob.isTame()) {
|
||||
- return false;
|
||||
+ return this.mob.isOrderedToSit() && this.mob.getTarget() == null; // CraftBukkit - Allow sitting for wild animals
|
||||
- if (!this.mob.isTame()) {
|
||||
+ if (false && !this.mob.isTame()) { // CraftBukkit - Allow sitting for wild animals
|
||||
return false;
|
||||
} else if (this.mob.isInWaterOrBubble()) {
|
||||
return false;
|
||||
} else if (!this.mob.onGround()) {
|
||||
|
||||
@@ -1,12 +1,23 @@
|
||||
--- a/net/minecraft/world/entity/ai/goal/PathfinderGoalTame.java
|
||||
+++ b/net/minecraft/world/entity/ai/goal/PathfinderGoalTame.java
|
||||
@@ -62,7 +62,8 @@
|
||||
@@ -7,6 +7,11 @@
|
||||
import net.minecraft.world.entity.player.EntityHuman;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class PathfinderGoalTame extends PathfinderGoal {
|
||||
|
||||
private final EntityHorseAbstract horse;
|
||||
@@ -62,7 +67,7 @@
|
||||
int i = this.horse.getTemper();
|
||||
int j = this.horse.getMaxTemper();
|
||||
|
||||
- if (j > 0 && this.horse.getRandom().nextInt(j) < i) {
|
||||
+ // CraftBukkit - fire EntityTameEvent
|
||||
+ if (j > 0 && this.horse.getRandom().nextInt(j) < i && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this.horse, ((org.bukkit.craftbukkit.entity.CraftHumanEntity) this.horse.getBukkitEntity().getPassenger()).getHandle()).isCancelled()) {
|
||||
+ if (j > 0 && this.horse.getRandom().nextInt(j) < i && !CraftEventFactory.callEntityTameEvent(this.horse, ((CraftHumanEntity) this.horse.getBukkitEntity().getPassenger()).getHandle()).isCancelled()) { // CraftBukkit - fire EntityTameEvent
|
||||
this.horse.tameWithName((EntityHuman) entity);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
--- a/net/minecraft/world/entity/ai/goal/target/PathfinderGoalTarget.java
|
||||
+++ b/net/minecraft/world/entity/ai/goal/target/PathfinderGoalTarget.java
|
||||
@@ -11,6 +11,8 @@
|
||||
@@ -11,6 +11,10 @@
|
||||
import net.minecraft.world.level.pathfinder.PathPoint;
|
||||
import net.minecraft.world.scores.ScoreboardTeamBase;
|
||||
|
||||
+import org.bukkit.event.entity.EntityTargetEvent; // CraftBukkit
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.event.entity.EntityTargetEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public abstract class PathfinderGoalTarget extends PathfinderGoal {
|
||||
|
||||
private static final int EMPTY_REACH_CACHE = 0;
|
||||
@@ -69,7 +71,7 @@
|
||||
@@ -69,7 +73,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +20,7 @@
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -89,7 +91,7 @@
|
||||
@@ -89,7 +93,7 @@
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
|
||||
Reference in New Issue
Block a user