mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-14 20:31:37 +01:00
prevent duplicate EntityInsideBlockEvent in fire
This commit is contained in:
parent
56e3949c61
commit
62b6e85d1a
@ -4,11 +4,11 @@
|
|||||||
@Override
|
@Override
|
||||||
protected void onProjectileHit(Level level, BlockState state, BlockHitResult hit, Projectile projectile) {
|
protected void onProjectileHit(Level level, BlockState state, BlockHitResult hit, Projectile projectile) {
|
||||||
if (!level.isClientSide && projectile.isOnFire() && this.canBeLit(state)) {
|
if (!level.isClientSide && projectile.isOnFire() && this.canBeLit(state)) {
|
||||||
+ // CraftBukkit start
|
+ // CraftBukkit start
|
||||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(level, hit.getBlockPos(), projectile).isCancelled()) {
|
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(level, hit.getBlockPos(), projectile).isCancelled()) {
|
||||||
+ return;
|
+ return;
|
||||||
+ }
|
+ }
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
setLit(level, state, hit.getBlockPos(), true);
|
setLit(level, state, hit.getBlockPos(), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,8 +44,8 @@
|
|||||||
- level.setBlock(pos.below(), blockState.setValue(LEAVES, BambooLeaves.SMALL), 3);
|
- level.setBlock(pos.below(), blockState.setValue(LEAVES, BambooLeaves.SMALL), 3);
|
||||||
- level.setBlock(blockPos, blockState1.setValue(LEAVES, BambooLeaves.NONE), 3);
|
- level.setBlock(blockPos, blockState1.setValue(LEAVES, BambooLeaves.NONE), 3);
|
||||||
+ // CraftBukkit start - moved down
|
+ // CraftBukkit start - moved down
|
||||||
+ // world.setBlock(blockposition.below(), (IBlockData) iblockdata1.setValue(BlockBamboo.LEAVES, BlockPropertyBambooSize.SMALL), 3);
|
+ // level.setBlock(pos.below(), blockState.setValue(LEAVES, BambooLeaves.SMALL), 3);
|
||||||
+ // world.setBlock(blockposition1, (IBlockData) iblockdata2.setValue(BlockBamboo.LEAVES, BlockPropertyBambooSize.NONE), 3);
|
+ // level.setBlock(blockPos, blockState1.setValue(LEAVES, BambooLeaves.NONE), 3);
|
||||||
+ shouldUpdateOthers = true;
|
+ shouldUpdateOthers = true;
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
}
|
}
|
||||||
|
@ -8,11 +8,10 @@
|
|||||||
import net.minecraft.world.level.BlockGetter;
|
import net.minecraft.world.level.BlockGetter;
|
||||||
import net.minecraft.world.level.Level;
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||||
@@ -128,6 +_,8 @@
|
@@ -128,6 +_,7 @@
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void entityInside(BlockState state, Level level, BlockPos pos, Entity entity) {
|
protected void entityInside(BlockState state, Level level, BlockPos pos, Entity entity) {
|
||||||
+ if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(level, pos)).callEvent()) { return; } // Paper - Add EntityInsideBlockEvent
|
|
||||||
+ if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(level, pos)).callEvent()) { return; } // Paper - Add EntityInsideBlockEvent
|
+ if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(level, pos)).callEvent()) { return; } // Paper - Add EntityInsideBlockEvent
|
||||||
if (!entity.fireImmune()) {
|
if (!entity.fireImmune()) {
|
||||||
if (entity.getRemainingFireTicks() < 0) {
|
if (entity.getRemainingFireTicks() < 0) {
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
private static final int CHECK_TICK_DELAY = 5;
|
private static final int CHECK_TICK_DELAY = 5;
|
||||||
private int openCount;
|
private int openCount;
|
||||||
private double maxInteractionRange;
|
private double maxInteractionRange;
|
||||||
+ public boolean opened; // CraftBukki
|
+ public boolean opened; // CraftBukkit
|
||||||
|
|
||||||
protected abstract void onOpen(Level level, BlockPos pos, BlockState state);
|
protected abstract void onOpen(Level level, BlockPos pos, BlockState state);
|
||||||
|
|
||||||
@ -24,7 +24,7 @@
|
|||||||
+ public void openerAPICountChanged(Level level, BlockPos blockPos, BlockState blockState, int count, int openCount) {
|
+ public void openerAPICountChanged(Level level, BlockPos blockPos, BlockState blockState, int count, int openCount) {
|
||||||
+ this.openerCountChanged(level, blockPos, blockState, count, openCount);
|
+ this.openerCountChanged(level, blockPos, blockState, count, openCount);
|
||||||
+ }
|
+ }
|
||||||
+ // CraftBukkit en
|
+ // CraftBukkit end
|
||||||
+
|
+
|
||||||
protected abstract boolean isOwnContainer(Player player);
|
protected abstract boolean isOwnContainer(Player player);
|
||||||
|
|
||||||
@ -40,7 +40,7 @@
|
|||||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.callRedstoneChange(level, pos, oldPower, newPower);
|
+ org.bukkit.craftbukkit.event.CraftEventFactory.callRedstoneChange(level, pos, oldPower, newPower);
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+ // CraftBukkit en
|
+ // CraftBukkit end
|
||||||
+
|
+
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
this.onOpen(level, pos, state);
|
this.onOpen(level, pos, state);
|
||||||
|
@ -43,7 +43,7 @@
|
|||||||
+ if (this.level == null) return null;
|
+ if (this.level == null) return null;
|
||||||
+ return io.papermc.paper.util.MCUtil.toLocation(this.level, this.worldPosition);
|
+ return io.papermc.paper.util.MCUtil.toLocation(this.level, this.worldPosition);
|
||||||
+ }
|
+ }
|
||||||
+ // CraftBukkit en
|
+ // CraftBukkit end
|
||||||
+
|
+
|
||||||
public CrafterBlockEntity(BlockPos pos, BlockState state) {
|
public CrafterBlockEntity(BlockPos pos, BlockState state) {
|
||||||
super(BlockEntityType.CRAFTER, pos, state);
|
super(BlockEntityType.CRAFTER, pos, state);
|
||||||
|
@ -122,7 +122,7 @@
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -239,18 +_,54 @@
|
@@ -239,18 +_,56 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,12 +175,14 @@
|
|||||||
|
|
||||||
item.setCount(count);
|
item.setCount(count);
|
||||||
- if (count == 1) {
|
- if (count == 1) {
|
||||||
|
+ // Spigot start
|
||||||
+ item.shrink(origCount - itemStack.getCount());
|
+ item.shrink(origCount - itemStack.getCount());
|
||||||
+ if (count <= level.spigotConfig.hopperAmount) {
|
+ if (count <= level.spigotConfig.hopperAmount) {
|
||||||
|
+ // Spigot end
|
||||||
container.setItem(slot, item);
|
container.setItem(slot, item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -260,12 +_,21 @@
|
@@ -260,12 +_,20 @@
|
||||||
|
|
||||||
public static boolean addItem(Container container, ItemEntity item) {
|
public static boolean addItem(Container container, ItemEntity item) {
|
||||||
boolean flag = false;
|
boolean flag = false;
|
||||||
@ -188,8 +190,7 @@
|
|||||||
+ org.bukkit.event.inventory.InventoryPickupItemEvent event = new org.bukkit.event.inventory.InventoryPickupItemEvent(
|
+ org.bukkit.event.inventory.InventoryPickupItemEvent event = new org.bukkit.event.inventory.InventoryPickupItemEvent(
|
||||||
+ container.getOwner().getInventory(), (org.bukkit.entity.Item) item.getBukkitEntity()
|
+ container.getOwner().getInventory(), (org.bukkit.entity.Item) item.getBukkitEntity()
|
||||||
+ );
|
+ );
|
||||||
+ item.level().getCraftServer().getPluginManager().callEvent(event);
|
+ if (!event.callEvent()) {
|
||||||
+ if (event.isCancelled()) {
|
|
||||||
+ return false;
|
+ return false;
|
||||||
+ }
|
+ }
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
|
@ -65,7 +65,7 @@
|
|||||||
- .ifPresent(holder -> this.jukeboxSongPlayer.setSongWithoutPlaying((Holder<JukeboxSong>)holder, 0L));
|
- .ifPresent(holder -> this.jukeboxSongPlayer.setSongWithoutPlaying((Holder<JukeboxSong>)holder, 0L));
|
||||||
- this.level.updateNeighborsAt(this.getBlockPos(), this.getBlockState().getBlock());
|
- this.level.updateNeighborsAt(this.getBlockPos(), this.getBlockState().getBlock());
|
||||||
+ this.jukeboxSongPlayer.song = null; // CraftBukkit - reset
|
+ this.jukeboxSongPlayer.song = null; // CraftBukkit - reset
|
||||||
+ JukeboxSong.fromStack(this.level != null ? this.level.registryAccess() : org.bukkit.craftbukkit.CraftRegistry.getMinecraftRegistry(), stack) // Paper - fallback to other RegistyrAccess if no level
|
+ JukeboxSong.fromStack(this.level != null ? this.level.registryAccess() : org.bukkit.craftbukkit.CraftRegistry.getMinecraftRegistry(), stack) // Paper - fallback to other RegistryAccess if no level
|
||||||
+ .ifPresent(holder -> this.jukeboxSongPlayer.setSongWithoutPlaying((Holder<JukeboxSong>)holder, ticksSinceSongStarted)); // CraftBukkit - passed ticks since song started
|
+ .ifPresent(holder -> this.jukeboxSongPlayer.setSongWithoutPlaying((Holder<JukeboxSong>)holder, ticksSinceSongStarted)); // CraftBukkit - passed ticks since song started
|
||||||
+ // CraftBukkit start - add null check for level
|
+ // CraftBukkit start - add null check for level
|
||||||
+ if (this.level != null) {
|
+ if (this.level != null) {
|
||||||
|
@ -72,7 +72,7 @@
|
|||||||
@Override
|
@Override
|
||||||
public int getMaxStackSize() {
|
public int getMaxStackSize() {
|
||||||
- return 1;
|
- return 1;
|
||||||
+ return maxStack;
|
+ return this.maxStack; // CraftBukkit
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
this.level.sendBlockUpdated(this.getBlockPos(), this.getBlockState(), this.getBlockState(), 3);
|
this.level.sendBlockUpdated(this.getBlockPos(), this.getBlockState(), this.getBlockState(), 3);
|
||||||
} else {
|
} else {
|
||||||
LOGGER.warn("Player {} just tried to change non-editable sign", player.getName().getString());
|
LOGGER.warn("Player {} just tried to change non-editable sign", player.getName().getString());
|
||||||
+ if (player.distanceToSqr(this.getBlockPos().getX(), this.getBlockPos().getY(), this.getBlockPos().getZ()) < 32 * 32) // Paper - Dont send far away sign update
|
+ if (player.distanceToSqr(this.getBlockPos().getX(), this.getBlockPos().getY(), this.getBlockPos().getZ()) < Mth.square(32)) // Paper - Don't send far away sign update
|
||||||
+ ((net.minecraft.server.level.ServerPlayer) player).connection.send(this.getUpdatePacket()); // CraftBukkit
|
+ ((net.minecraft.server.level.ServerPlayer) player).connection.send(this.getUpdatePacket()); // CraftBukkit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -158,7 +158,7 @@
|
|||||||
+ } : this.commandSource;
|
+ } : this.commandSource;
|
||||||
+ // Paper end - Fix commands from signs not firing command events
|
+ // Paper end - Fix commands from signs not firing command events
|
||||||
+ // CraftBukkit - this
|
+ // CraftBukkit - this
|
||||||
+ return new CommandSourceStack(commandSource, Vec3.atCenterOf(pos), Vec2.ZERO, (ServerLevel) world, 2, string, (Component) component, world.getServer(), player); // Paper - Fix commands from signs not firing command events
|
+ return new CommandSourceStack(commandSource, Vec3.atCenterOf(pos), Vec2.ZERO, (ServerLevel) world, 2, string, component, world.getServer(), player); // Paper - Fix commands from signs not firing command events
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -29,14 +29,14 @@
|
|||||||
+ LoadingCache<com.mojang.datafixers.util.Pair<java.util.UUID, @org.jetbrains.annotations.Nullable GameProfile>, CompletableFuture<Optional<GameProfile>>> loadingCache = profileCacheById; // Paper - player profile events
|
+ LoadingCache<com.mojang.datafixers.util.Pair<java.util.UUID, @org.jetbrains.annotations.Nullable GameProfile>, CompletableFuture<Optional<GameProfile>>> loadingCache = profileCacheById; // Paper - player profile events
|
||||||
return loadingCache != null && !optional.isEmpty()
|
return loadingCache != null && !optional.isEmpty()
|
||||||
- ? loadingCache.getUnchecked(optional.get().getId()).thenApply(optional1 -> optional1.or(() -> optional))
|
- ? loadingCache.getUnchecked(optional.get().getId()).thenApply(optional1 -> optional1.or(() -> optional))
|
||||||
+ ? loadingCache.getUnchecked(new com.mojang.datafixers.util.Pair<>(optional.get().getId(), optional.get())).thenApply(optional1 -> optional1.or(() -> optional)) // Paper - player profile events
|
+ ? loadingCache.getUnchecked(new com.mojang.datafixers.util.Pair<>(optional.get().getId(), optional.get())).thenApply(optional1 -> optional1.or(() -> optional)) // Paper - player profile events
|
||||||
: CompletableFuture.completedFuture(Optional.empty());
|
: CompletableFuture.completedFuture(Optional.empty());
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
- static CompletableFuture<Optional<GameProfile>> fetchProfileById(UUID id, Services services, BooleanSupplier cacheUninitialized) {
|
- static CompletableFuture<Optional<GameProfile>> fetchProfileById(UUID id, Services services, BooleanSupplier cacheUninitialized) {
|
||||||
+ static CompletableFuture<Optional<GameProfile>> fetchProfileById(com.mojang.datafixers.util.Pair<java.util.UUID, @org.jetbrains.annotations.Nullable GameProfile> id, Services services, BooleanSupplier cacheUninitialized) { // Pape
|
+ static CompletableFuture<Optional<GameProfile>> fetchProfileById(com.mojang.datafixers.util.Pair<java.util.UUID, @org.jetbrains.annotations.Nullable GameProfile> id, Services services, BooleanSupplier cacheUninitialized) { // Paper
|
||||||
return CompletableFuture.supplyAsync(() -> {
|
return CompletableFuture.supplyAsync(() -> {
|
||||||
if (cacheUninitialized.getAsBoolean()) {
|
if (cacheUninitialized.getAsBoolean()) {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
|
Loading…
Reference in New Issue
Block a user