Skip to content

Commit

Permalink
readd dropped event in InteractWithDoor
Browse files Browse the repository at this point in the history
  • Loading branch information
Lulu13022002 committed Dec 16, 2024
1 parent 9c973e8 commit 783b3b7
Show file tree
Hide file tree
Showing 33 changed files with 175 additions and 172 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ index 9de400977ec33e485e87cdf1cf145588527e1e10..c83aeaf4e50dd7290c608dfe260a3bd2
}
}
diff --git a/net/minecraft/world/entity/vehicle/AbstractBoat.java b/net/minecraft/world/entity/vehicle/AbstractBoat.java
index 5cd65e94ac7830aaa2a64057fc2a81478b55ea41..b9cb86717d7e6c05eb97f3b1bbf1d0111a0ba6ed 100644
index 3bdb3b0984d0fee21b2c094e1d4c1f917ab68f92..54a4bf2f7df87b4a694187ade81ba158f83f0246 100644
--- a/net/minecraft/world/entity/vehicle/AbstractBoat.java
+++ b/net/minecraft/world/entity/vehicle/AbstractBoat.java
@@ -641,7 +641,7 @@ public abstract class AbstractBoat extends VehicleEntity implements Leashable {
@@ -638,7 +638,7 @@ public abstract class AbstractBoat extends VehicleEntity implements Leashable {
this.waterLevel = this.getY(1.0);
double d2 = this.getWaterLevelAbove() - this.getBbHeight() + 0.101;
if (this.level().noCollision(this, this.getBoundingBox().move(0.0, d2 - this.getY(), 0.0))) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,7 @@
+ {
+ {
+ Either<net.minecraft.world.entity.player.Player.BedSleepingProblem, Unit> either = super.startSleepInBed(at, force).ifRight((unit) -> {
+ // CraftBukkit end
+ // CraftBukkit end
this.awardStat(Stats.SLEEP_IN_BED);
CriteriaTriggers.SLEPT_IN_BED.trigger(this);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
+ return result;
+ }
+
+ public void onOpen(org.bukkit.craftbukkit.entity.CraftHumanEntity who) {
+ this.container1.onOpen(who);
+ this.container2.onOpen(who);
+ this.transaction.add(who);
+ public void onOpen(org.bukkit.craftbukkit.entity.CraftHumanEntity player) {
+ this.container1.onOpen(player);
+ this.container2.onOpen(player);
+ this.transaction.add(player);
+ }
+
+ public void onClose(org.bukkit.craftbukkit.entity.CraftHumanEntity who) {
+ this.container1.onClose(who);
+ this.container2.onClose(who);
+ this.transaction.remove(who);
+ public void onClose(org.bukkit.craftbukkit.entity.CraftHumanEntity player) {
+ this.container1.onClose(player);
+ this.container2.onClose(player);
+ this.transaction.remove(player);
+ }
+
+ public java.util.List<org.bukkit.entity.HumanEntity> getViewers() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
+ // Paper start
+ java.util.List<ItemStack> getContents();
+
+ void onOpen(org.bukkit.craftbukkit.entity.CraftHumanEntity who);
+ void onOpen(org.bukkit.craftbukkit.entity.CraftHumanEntity player);
+
+ void onClose(org.bukkit.craftbukkit.entity.CraftHumanEntity who);
+ void onClose(org.bukkit.craftbukkit.entity.CraftHumanEntity player);
+
+ java.util.List<org.bukkit.entity.HumanEntity> getViewers();
+
Expand All @@ -31,6 +31,6 @@
+
+ org.bukkit.Location getLocation();
+
+ int MAX_STACK = 99;
+ int MAX_STACK = Item.ABSOLUTE_MAX_STACK_SIZE;
+ // Paper end
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
+ return this.items;
+ }
+
+ public void onOpen(org.bukkit.craftbukkit.entity.CraftHumanEntity who) {
+ this.transaction.add(who);
+ public void onOpen(org.bukkit.craftbukkit.entity.CraftHumanEntity player) {
+ this.transaction.add(player);
+ }
+
+ public void onClose(org.bukkit.craftbukkit.entity.CraftHumanEntity who) {
+ this.transaction.remove(who);
+ public void onClose(org.bukkit.craftbukkit.entity.CraftHumanEntity player) {
+ this.transaction.remove(player);
+ }
+
+ public List<org.bukkit.entity.HumanEntity> getViewers() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
--- a/net/minecraft/world/entity/ai/behavior/Behavior.java
+++ b/net/minecraft/world/entity/ai/behavior/Behavior.java
@@ -14,6 +_,9 @@
@@ -14,6 +_,7 @@
private long endTimestamp;
private final int minDuration;
private final int maxDuration;
+ // Paper start - configurable behavior tick rate and timings
+ private final String configKey;
+ // Paper end - configurable behavior tick rate and timings
+ private final String configKey; // Paper - configurable behavior tick rate and timings

public Behavior(Map<MemoryModuleType<?>, MemoryStatus> entryCondition) {
this(entryCondition, 60);
Expand All @@ -29,12 +27,12 @@

@Override
public final boolean tryStart(ServerLevel level, E owner, long gameTime) {
+ // Paper start - configurable behavior tick rate and timings
+ int tickRate = java.util.Objects.requireNonNullElse(level.paperConfig().tickRates.behavior.get(owner.getType(), this.configKey), -1);
+ if (tickRate > -1 && gameTime < this.endTimestamp + tickRate) {
+ return false;
+ }
+ // Paper end - configurable behavior tick rate and timings
+ // Paper start - configurable behavior tick rate and timings
+ int tickRate = java.util.Objects.requireNonNullElse(level.paperConfig().tickRates.behavior.get(owner.getType(), this.configKey), -1);
+ if (tickRate > -1 && gameTime < this.endTimestamp + tickRate) {
+ return false;
+ }
+ // Paper end - configurable behavior tick rate and timings
if (this.hasRequiredMemories(owner) && this.checkExtraStartConditions(level, owner)) {
this.status = Behavior.Status.RUNNING;
int i = this.minDuration + level.getRandom().nextInt(this.maxDuration + 1 - this.minDuration);
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
+ if (event.isCancelled()) {
+ return false;
+ }
+ if (!(event.getTarget() instanceof org.bukkit.craftbukkit.entity.CraftItem)) { // Paper - only erase allay memory on non-item targets
+ if (!(event.getTarget() instanceof org.bukkit.craftbukkit.entity.CraftItem targetItem)) { // Paper - only erase allay memory on non-item targets
+ nearestVisibleWantedItem.erase();
+ return false; // Paper - only erase allay memory on non-item targets
+ }
+
+ itemEntity = (ItemEntity) ((org.bukkit.craftbukkit.entity.CraftEntity) event.getTarget()).getHandle();
+ itemEntity = targetItem.getHandle();
+ }
+ // CraftBukkit end
WalkTarget walkTarget1 = new WalkTarget(new EntityTracker(itemEntity, false), speedModifier, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,20 @@
+ if (!event.callEvent()) {
+ return false;
+ }
+ // CraftBukkit end
+ // CraftBukkit end - entities opening doors
doorBlock.setOpen(entity, level, blockState, blockPos, true);
}

@@ -69,6 +_,12 @@
if (blockState1.is(BlockTags.MOB_INTERACTABLE_DOORS, state -> state.getBlock() instanceof DoorBlock)) {
DoorBlock doorBlock1 = (DoorBlock)blockState1.getBlock();
if (!doorBlock1.isOpen(blockState1)) {
+ // CraftBukkit start - entities opening doors
+ org.bukkit.event.entity.EntityInteractEvent event = new org.bukkit.event.entity.EntityInteractEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(entity.level(), blockPos1));
+ if (!event.callEvent()) {
+ return false;
+ }
+ // CraftBukkit end - entities opening doors
doorBlock1.setOpen(entity, level, blockState1, blockPos1, true);
optional = rememberDoorToClose(doorsToClose, optional, level, blockPos1);
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@
+ }
+
+ @Override
+ public void onOpen(CraftHumanEntity who) {
+ this.transaction.add(who);
+ public void onOpen(CraftHumanEntity player) {
+ this.transaction.add(player);
+ }
+
+ @Override
+ public void onClose(CraftHumanEntity who) {
+ this.transaction.remove(who);
+ public void onClose(CraftHumanEntity player) {
+ this.transaction.remove(player);
+ }
+
+ @Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
private int timesChanged;

+ // CraftBukkit start - add fields and methods
+ public List<org.bukkit.entity.HumanEntity> transaction = new java.util.ArrayList<org.bukkit.entity.HumanEntity>();
+ public List<org.bukkit.entity.HumanEntity> transaction = new java.util.ArrayList<>();
+ private int maxStack = MAX_STACK;
+
+ public List<ItemStack> getContents() {
Expand All @@ -21,12 +21,12 @@
+ return this.armor;
+ }
+
+ public void onOpen(org.bukkit.craftbukkit.entity.CraftHumanEntity who) {
+ this.transaction.add(who);
+ public void onOpen(org.bukkit.craftbukkit.entity.CraftHumanEntity player) {
+ this.transaction.add(player);
+ }
+
+ public void onClose(org.bukkit.craftbukkit.entity.CraftHumanEntity who) {
+ this.transaction.remove(who);
+ public void onClose(org.bukkit.craftbukkit.entity.CraftHumanEntity player) {
+ this.transaction.remove(player);
+ }
+
+ public List<org.bukkit.entity.HumanEntity> getViewers() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/vehicle/AbstractBoat.java
+++ b/net/minecraft/world/entity/vehicle/AbstractBoat.java
@@ -83,6 +_,14 @@
@@ -83,6 +_,15 @@
private Leashable.LeashData leashData;
private final Supplier<Item> dropItem;

Expand All @@ -10,6 +10,7 @@
+ public double occupiedDeceleration = 0.2D;
+ public double unoccupiedDeceleration = -1;
+ public boolean landBoats = false;
+ private org.bukkit.Location lastLocation;
+ // CraftBukkit end
+
public AbstractBoat(EntityType<? extends AbstractBoat> entityType, Level level, Supplier<Item> dropItem) {
Expand Down Expand Up @@ -55,30 +56,19 @@
super.push(entity);
}
}
@@ -243,6 +_,7 @@
return this.getDirection().getClockWise();
}

+ private org.bukkit.Location lastLocation; // CraftBukkit
@Override
public void tick() {
this.oldStatus = this.status;
@@ -283,6 +_,21 @@
@@ -283,6 +_,18 @@
this.setDeltaMovement(Vec3.ZERO);
}

+ // CraftBukkit start
+ org.bukkit.Server server = this.level().getCraftServer();
+ org.bukkit.World bworld = this.level().getWorld();
+
+ org.bukkit.Location to = org.bukkit.craftbukkit.util.CraftLocation.toBukkit(this.position(), bworld, this.getYRot(), this.getXRot());
+ org.bukkit.Location to = org.bukkit.craftbukkit.util.CraftLocation.toBukkit(this.position(), this.level().getWorld(), this.getYRot(), this.getXRot());
+ org.bukkit.entity.Vehicle vehicle = (org.bukkit.entity.Vehicle) this.getBukkitEntity();
+
+ server.getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleUpdateEvent(vehicle));
+ new org.bukkit.event.vehicle.VehicleUpdateEvent(vehicle).callEvent();
+
+ if (this.lastLocation != null && !this.lastLocation.equals(to)) {
+ org.bukkit.event.vehicle.VehicleMoveEvent event = new org.bukkit.event.vehicle.VehicleMoveEvent(vehicle, this.lastLocation, to);
+ server.getPluginManager().callEvent(event);
+ event.callEvent();
+ }
+ this.lastLocation = vehicle.getLocation();
+ // CraftBukkit end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,11 @@
return null;
} else {
this.unpackLootTable(playerInventory.player);
@@ -198,4 +_,59 @@
@@ -198,4 +_,58 @@
public void stopOpen(Player player) {
this.level().gameEvent(GameEvent.CONTAINER_CLOSE, this.position(), GameEvent.Context.of(player));
}
+
+
+ // Paper start - LootTable API
+ final com.destroystokyo.paper.loottable.PaperLootableInventoryData lootableData = new com.destroystokyo.paper.loottable.PaperLootableInventoryData();
+
Expand All @@ -64,13 +63,13 @@
+ }
+
+ @Override
+ public void onOpen(org.bukkit.craftbukkit.entity.CraftHumanEntity who) {
+ this.transaction.add(who);
+ public void onOpen(org.bukkit.craftbukkit.entity.CraftHumanEntity player) {
+ this.transaction.add(player);
+ }
+
+ @Override
+ public void onClose(org.bukkit.craftbukkit.entity.CraftHumanEntity who) {
+ this.transaction.remove(who);
+ public void onClose(org.bukkit.craftbukkit.entity.CraftHumanEntity player) {
+ this.transaction.remove(player);
+ }
+
+ @Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
+ if (!collides) {
+ return false;
+ }
+ org.bukkit.event.vehicle.VehicleEntityCollisionEvent collisionEvent = new org.bukkit.event.vehicle.VehicleEntityCollisionEvent((org.bukkit.entity.Vehicle) getBukkitEntity(), entity.getBukkitEntity());
+
+ org.bukkit.event.vehicle.VehicleEntityCollisionEvent collisionEvent = new org.bukkit.event.vehicle.VehicleEntityCollisionEvent((org.bukkit.entity.Vehicle) getBukkitEntity(), entity.getBukkitEntity());
+ return collisionEvent.callEvent();
+ // Paper end - fix VehicleEntityCollisionEvent not called when colliding with player
}
Expand Down Expand Up @@ -141,7 +141,7 @@
double d = entity.getX() - this.getX();
double d1 = entity.getZ() - this.getZ();
double d2 = d * d + d1 * d1;
@@ -602,4 +_,27 @@
@@ -602,4 +_,28 @@
public boolean isFurnace() {
return false;
}
Expand All @@ -167,5 +167,6 @@
+ this.derailedZ = derailed.getZ();
+ }
+ // CraftBukkit end
+
+ public net.minecraft.world.item.Item publicGetDropItem() { return getDropItem(); } // Paper - api to get boat and minecart material - expose public drop item
}
Loading

0 comments on commit 783b3b7

Please sign in to comment.