readd conduit effect cause

This commit is contained in:
Lulu13022002 2024-12-15 18:47:15 +01:00
parent 7b4afa8b82
commit a5b1875b2d
No known key found for this signature in database
GPG key ID: 491C8F0B8ACDEB01
16 changed files with 49 additions and 74 deletions

View file

@ -38,7 +38,7 @@
private final Map<MobCategory, List<MobSpawnSettings.SpawnerData>> spawners = Stream.of(MobCategory.values())
- .collect(ImmutableMap.toImmutableMap(key -> (MobCategory)key, value -> Lists.newArrayList()));
+ .collect(Maps.toImmutableEnumMap(mobCategory -> (MobCategory)mobCategory, mobCategory -> new MobList())); // Use MobList instead of ArrayList
+ // Paper end - Perf: keep track of data in a pair set to give O(1) contains calls
+ // Paper end - Perf: keep track of data in a pair set to give O(1) contains calls
private final Map<EntityType<?>, MobSpawnSettings.MobSpawnCost> mobSpawnCosts = Maps.newLinkedHashMap();
private float creatureGenerationProbability = 0.1F;

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/LayeredCauldronBlock.java
+++ b/net/minecraft/world/level/block/LayeredCauldronBlock.java
@@ -61,35 +_,69 @@
@@ -61,35 +_,68 @@
@Override
protected void entityInside(BlockState state, Level level, BlockPos pos, Entity entity) {
@ -50,25 +50,24 @@
+
+ // CraftBukkit start
+ // Paper start - Call CauldronLevelChangeEvent
+ public static boolean changeLevel(Level world, BlockPos blockposition, BlockState newBlock, @javax.annotation.Nullable Entity entity, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason reason) { // Paper - entity is nullable
+ return changeLevel(world, blockposition, newBlock, entity, reason, true);
+ public static boolean changeLevel(Level world, BlockPos pos, BlockState newBlock, @javax.annotation.Nullable Entity entity, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason reason) { // Paper - entity is nullable
+ return changeLevel(world, pos, newBlock, entity, reason, true);
+ }
+
+ public static boolean changeLevel(Level world, BlockPos blockposition, BlockState newBlock, @javax.annotation.Nullable Entity entity, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason reason, boolean sendGameEvent) { // Paper - entity is nullable
+ public static boolean changeLevel(Level world, BlockPos pos, BlockState newBlock, @javax.annotation.Nullable Entity entity, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason reason, boolean sendGameEvent) { // Paper - entity is nullable
+ // Paper end - Call CauldronLevelChangeEvent
+ org.bukkit.craftbukkit.block.CraftBlockState newState = org.bukkit.craftbukkit.block.CraftBlockStates.getBlockState(world, blockposition);
+ org.bukkit.craftbukkit.block.CraftBlockState newState = org.bukkit.craftbukkit.block.CraftBlockStates.getBlockState(world, pos);
+ newState.setData(newBlock);
+
+ org.bukkit.event.block.CauldronLevelChangeEvent event = new org.bukkit.event.block.CauldronLevelChangeEvent(
+ world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()),
+ org.bukkit.craftbukkit.block.CraftBlock.at(world, pos),
+ (entity == null) ? null : entity.getBukkitEntity(), reason, newState
+ );
+ world.getCraftServer().getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ if (!event.callEvent()) {
+ return false;
+ }
+ newState.update(true);
+ if (sendGameEvent) world.gameEvent(GameEvent.BLOCK_CHANGE, blockposition, GameEvent.Context.of(newBlock)); // Paper - Call CauldronLevelChangeEvent
+ if (sendGameEvent) world.gameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Context.of(newBlock)); // Paper - Call CauldronLevelChangeEvent
+ return true;
+ }
+ // CraftBukkit end

View file

@ -21,12 +21,12 @@
} else {
super.fallOn(level, state, pos, entity, fallDistance);
}
@@ -213,10 +_,12 @@
@@ -213,10 +_,11 @@
if (blockPos != null) {
if (fluidAboveStalactite.get().sourceState.is(Blocks.MUD) && fluid == Fluids.WATER) {
BlockState blockState = Blocks.CLAY.defaultBlockState();
- level.setBlockAndUpdate(fluidAboveStalactite.get().pos, blockState);
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(level, fluidAboveStalactite.get().pos, blockState)) { // Paper - Call BlockFormEvent
level.setBlockAndUpdate(fluidAboveStalactite.get().pos, blockState);
Block.pushEntitiesUp(fluidAboveStalactite.get().sourceState, blockState, level, fluidAboveStalactite.get().pos);
level.gameEvent(GameEvent.BLOCK_CHANGE, fluidAboveStalactite.get().pos, GameEvent.Context.of(blockState));
level.levelEvent(1504, blockPos, 0);
@ -39,7 +39,7 @@
createMergedTips(blockState, server, blockPos);
} else if (blockState.isAir() || blockState.is(Blocks.WATER)) {
- createDripstone(server, blockPos, direction, DripstoneThickness.TIP);
+ createDripstone(server, blockPos, direction, DripstoneThickness.TIP, pos); // CraftBukkit;
+ createDripstone(server, blockPos, direction, DripstoneThickness.TIP, pos); // CraftBukkit
}
}

View file

@ -29,7 +29,7 @@
+ level.captureTreeGeneration = true;
+ this.treeGrower.growTree(level, level.getChunkSource().getGenerator(), pos, state, random);
+ level.captureTreeGeneration = false;
+ if (level.capturedBlockStates.size() > 0) {
+ if (!level.capturedBlockStates.isEmpty()) {
+ org.bukkit.TreeType treeType = SaplingBlock.treeType;
+ SaplingBlock.treeType = null;
+ org.bukkit.Location location = org.bukkit.craftbukkit.util.CraftLocation.toBukkit(pos, level.getWorld());

View file

@ -5,7 +5,7 @@
int distance = getDistance(level, pos);
BlockState blockState = state.setValue(DISTANCE, Integer.valueOf(distance)).setValue(BOTTOM, Boolean.valueOf(this.isBottom(level, pos, distance)));
- if (blockState.getValue(DISTANCE) == 7) {
+ if (blockState.getValue(DISTANCE) == 7&& !org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(level, pos, blockState.getFluidState().createLegacyBlock()).isCancelled()) { // CraftBukkit - BlockFadeEvent // Paper - fix wrong block state
+ if (blockState.getValue(DISTANCE) == 7 && !org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(level, pos, blockState.getFluidState().createLegacyBlock()).isCancelled()) { // CraftBukkit - BlockFadeEvent // Paper - fix wrong block state
if (state.getValue(DISTANCE) == 7) {
FallingBlockEntity.fall(level, pos, blockState);
} else {

View file

@ -1,13 +1,5 @@
--- a/net/minecraft/world/level/block/SculkSpreader.java
+++ b/net/minecraft/world/level/block/SculkSpreader.java
@@ -25,6 +_,7 @@
import net.minecraft.core.Vec3i;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtOps;
+import net.minecraft.nbt.Tag;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
@@ -50,6 +_,7 @@
private final int additionalDecayRate;
private List<SculkSpreader.ChargeCursor> cursors = new ArrayList<>();
@ -25,7 +17,7 @@
}
}
}
@@ -130,13 +_,25 @@
@@ -130,13 +_,24 @@
public void addCursors(BlockPos pos, int charge) {
while (charge > 0) {
int min = Math.min(charge, 1000);
@ -42,8 +34,7 @@
+ if (!this.isWorldGeneration() && fireEvent) { // CraftBukkit - SPIGOT-7475: Don't call event during world generation // Paper - add boolean to conditionally fire SculkBloomEvent
+ org.bukkit.craftbukkit.block.CraftBlock bukkitBlock = org.bukkit.craftbukkit.block.CraftBlock.at(this.level, cursor.pos);
+ org.bukkit.event.block.SculkBloomEvent event = new org.bukkit.event.block.SculkBloomEvent(bukkitBlock, cursor.getCharge());
+ org.bukkit.Bukkit.getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ if (!event.callEvent()) {
+ return;
+ }
+

View file

@ -7,7 +7,7 @@
- && canOpen(state, level, pos, shulkerBoxBlockEntity)) {
- player.openMenu(shulkerBoxBlockEntity);
+ && canOpen(state, level, pos, shulkerBoxBlockEntity) // Paper - Fix InventoryOpenEvent cancellation - expand if for belows check
+ && player.openMenu(shulkerBoxBlockEntity).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation) {
+ && player.openMenu(shulkerBoxBlockEntity).isPresent()) { // Paper - Fix InventoryOpenEvent cancellation
player.awardStat(Stats.OPEN_SHULKER_BOX);
PiglinAi.angerNearbyPiglins(serverLevel, player, true);
}

View file

@ -33,7 +33,7 @@
} else {
if (!blockState.is(Blocks.KELP)
&& !blockState.is(Blocks.KELP_PLANT)
@@ -81,16 +_,57 @@
@@ -81,16 +_,55 @@
return BlockPos.TraversalNodeStatus.SKIP;
}
@ -58,36 +58,34 @@
+ // CraftBukkit start
+ java.util.List<org.bukkit.craftbukkit.block.CraftBlockState> blocks = blockList.getList(); // Is a clone
+ if (!blocks.isEmpty()) {
+ final org.bukkit.block.Block bblock = level.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ());
+ final org.bukkit.block.Block sponge = org.bukkit.craftbukkit.block.CraftBlock.at(level, pos);
+
+ org.bukkit.event.block.SpongeAbsorbEvent event = new org.bukkit.event.block.SpongeAbsorbEvent(bblock, (java.util.List<org.bukkit.block.BlockState>) (java.util.List) blocks);
+ level.getCraftServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ org.bukkit.event.block.SpongeAbsorbEvent event = new org.bukkit.event.block.SpongeAbsorbEvent(sponge, (java.util.List<org.bukkit.block.BlockState>) (java.util.List) blocks);
+ if (!event.callEvent()) {
+ return false;
+ }
+
+ for (org.bukkit.craftbukkit.block.CraftBlockState block : blocks) {
+ BlockPos blockposition1 = block.getPosition();
+ BlockState iblockdata = level.getBlockState(blockposition1);
+ FluidState fluid = level.getFluidState(blockposition1);
+ BlockPos blockPos = block.getPosition();
+ BlockState state = level.getBlockState(blockPos);
+ FluidState fluid = level.getFluidState(blockPos);
+
+ if (fluid.is(FluidTags.WATER)) {
+ if (iblockdata.getBlock() instanceof BucketPickup && !((BucketPickup) iblockdata.getBlock()).pickupBlock(null, blockList, blockposition1, iblockdata).isEmpty()) {
+ if (state.getBlock() instanceof BucketPickup bucketPickup && !bucketPickup.pickupBlock(null, blockList, blockPos, state).isEmpty()) {
+ // NOP
+ } else if (iblockdata.getBlock() instanceof LiquidBlock) {
+ } else if (state.getBlock() instanceof LiquidBlock) {
+ // NOP
+ } else if (iblockdata.is(Blocks.KELP) || iblockdata.is(Blocks.KELP_PLANT) || iblockdata.is(Blocks.SEAGRASS) || iblockdata.is(Blocks.TALL_SEAGRASS)) {
+ BlockEntity tileentity = iblockdata.hasBlockEntity() ? level.getBlockEntity(blockposition1) : null;
+ } else if (state.is(Blocks.KELP) || state.is(Blocks.KELP_PLANT) || state.is(Blocks.SEAGRASS) || state.is(Blocks.TALL_SEAGRASS)) {
+ BlockEntity blockEntity = state.hasBlockEntity() ? level.getBlockEntity(blockPos) : null;
+
+ // Paper start - Fix SpongeAbsortEvent handling
+ if (block.getHandle().isAir()) {
+ dropResources(iblockdata, level, blockposition1, tileentity);
+ dropResources(state, level, blockPos, blockEntity);
+ }
+ // Paper end - Fix SpongeAbsortEvent handling
+ }
+ }
+ level.setBlock(blockposition1, block.getHandle(), block.getFlag());
+ level.setBlock(blockPos, block.getHandle(), block.getFlag());
+ }
+
+ return true;

View file

@ -15,7 +15,7 @@
emitState(level, pos, flag2, flag3, flag, flag1);
if (!attaching) {
+ if (level.getBlockState(pos).getBlock() == Blocks.TRIPWIRE_HOOK) // Paper - Validate tripwire hook placement before update
+ if (level.getBlockState(pos).is(Blocks.TRIPWIRE_HOOK)) // Paper - Validate tripwire hook placement before update
level.setBlock(pos, blockState1.setValue(FACING, direction), 3);
if (shouldNotifyNeighbours) {
notifyNeighbors(block, level, pos, direction);

View file

@ -1,13 +1,5 @@
--- a/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java
+++ b/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java
@@ -20,7 +_,6 @@
import net.minecraft.world.ContainerHelper;
import net.minecraft.world.WorldlyContainer;
import net.minecraft.world.entity.ExperienceOrb;
-import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.player.StackedItemContents;
import net.minecraft.world.inventory.ContainerData;
import net.minecraft.world.inventory.RecipeCraftingHolder;
@@ -99,11 +_,44 @@
};
public final Reference2IntOpenHashMap<ResourceKey<Recipe<?>>> recipesUsed = new Reference2IntOpenHashMap<>();
@ -209,7 +201,7 @@
+ /* passing a null level here is safe. world is only used for map extending recipes which won't happen here */
+ : (net.minecraft.server.MinecraftServer.getServer().getRecipeManager().getRecipeFor(recipeType, singleRecipeInput, level).map(holder -> holder.value().cookingTime()).orElse(200));
+ return (int) Math.ceil (cookTime / cookSpeedMultiplier);
+ // Paper end - cook speed multiplier AP
+ // Paper end - cook speed multiplier API
}
@Override

View file

@ -238,7 +238,7 @@
}
bee.setInLoveTime(Math.max(0, bee.getInLoveTime() - ticksInHive));
+ } // Paper - Honor ageLock
+ } // Paper - Honor ageLock
}
}
}

View file

@ -45,7 +45,7 @@
return raider.isAlive() && !raider.isRemoved() && pos.closerToCenterThan(raider.position(), 48.0) && raider.getType().is(EntityTypeTags.RAIDERS);
}
+ @io.papermc.paper.annotation.DoNotUse // Paper - Add BellRevealRaiderEvent
+ @Deprecated @io.papermc.paper.annotation.DoNotUse // Paper - Add BellRevealRaiderEvent
private static void glow(LivingEntity entity) {
+ // Paper start - Add BellRevealRaiderEvent
+ glow(entity, null);

View file

@ -71,7 +71,7 @@
CrashReportCategory.populateBlockDetails(reportCategory, this.level, this.worldPosition, this.level.getBlockState(this.worldPosition));
}
}
@@ -247,10 +_,16 @@
@@ -247,6 +_,12 @@
}
public final void applyComponents(DataComponentMap components, DataComponentPatch patch) {
@ -84,11 +84,6 @@
final Set<DataComponentType<?>> set = new HashSet<>();
set.add(DataComponents.BLOCK_ENTITY_DATA);
set.add(DataComponents.BLOCK_STATE);
- final DataComponentMap dataComponentMap = PatchedDataComponentMap.fromPatch(components, patch);
+ final PatchedDataComponentMap dataComponentMap = PatchedDataComponentMap.fromPatch(components, patch);
this.applyImplicitComponents(new BlockEntity.DataComponentInput() {
@Nullable
@Override
@@ -267,6 +_,10 @@
});
DataComponentPatch dataComponentPatch = patch.forget(set::contains);

View file

@ -1,13 +1,5 @@
--- a/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java
+++ b/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java
@@ -8,7 +_,6 @@
import net.minecraft.core.NonNullList;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
-import net.minecraft.tags.ItemTags;
import net.minecraft.world.ContainerHelper;
import net.minecraft.world.Containers;
import net.minecraft.world.WorldlyContainer;
@@ -36,6 +_,7 @@
public static final int NUM_DATA_VALUES = 2;
private NonNullList<ItemStack> items = NonNullList.withSize(5, ItemStack.EMPTY);
@ -76,14 +68,12 @@
public BrewingStandBlockEntity(BlockPos pos, BlockState state) {
super(BlockEntityType.BREWING_STAND, pos, state);
@@ -92,9 +_,22 @@
@@ -93,8 +_,21 @@
public static void serverTick(Level level, BlockPos pos, BlockState state, BrewingStandBlockEntity blockEntity) {
ItemStack itemStack = blockEntity.items.get(4);
- if (blockEntity.fuel <= 0 && itemStack.is(ItemTags.BREWING_FUEL)) {
if (blockEntity.fuel <= 0 && itemStack.is(ItemTags.BREWING_FUEL)) {
- blockEntity.fuel = 20;
- itemStack.shrink(1);
+ if (blockEntity.fuel <= 0 && itemStack.is(net.minecraft.tags.ItemTags.BREWING_FUEL)) {
+ // CraftBukkit start
+ org.bukkit.event.inventory.BrewingStandFuelEvent event = new org.bukkit.event.inventory.BrewingStandFuelEvent(
+ org.bukkit.craftbukkit.block.CraftBlock.at(level, pos),

View file

@ -8,7 +8,7 @@
public CampfireBlockEntity(BlockPos pos, BlockState blockState) {
super(BlockEntityType.CAMPFIRE, pos, blockState);
@@ -54,14 +_,42 @@
@@ -54,14 +_,44 @@
ItemStack itemStack = campfire.items.get(i);
if (!itemStack.isEmpty()) {
flag = true;
@ -18,10 +18,12 @@
if (campfire.cookingProgress[i] >= campfire.cookingTime[i]) {
SingleRecipeInput singleRecipeInput = new SingleRecipeInput(itemStack);
- ItemStack itemStack1 = check.getRecipeFor(singleRecipeInput, level)
+ // Paper start - add recipe to cook events
+ final var optionalCookingRecipe = check.getRecipeFor(singleRecipeInput, level);
+ ItemStack itemStack1 = optionalCookingRecipe
.map(recipe -> recipe.value().assemble(singleRecipeInput, level.registryAccess()))
.orElse(itemStack);
+ // Paper end - add recipe to cook events
if (itemStack1.isItemEnabled(level.enabledFeatures())) {
- Containers.dropItemStack(level, pos.getX(), pos.getY(), pos.getZ(), itemStack1);
+ // CraftBukkit start - fire BlockCookEvent

View file

@ -29,7 +29,15 @@
int x = pos.getX();
int y = pos.getY();
int z = pos.getZ();
@@ -185,6 +_,12 @@
@@ -178,13 +_,19 @@
if (!entitiesOfClass.isEmpty()) {
for (Player player : entitiesOfClass) {
if (pos.closerThan(player.blockPosition(), i) && player.isInWaterOrRain()) {
- player.addEffect(new MobEffectInstance(MobEffects.CONDUIT_POWER, 260, 0, true, true));
+ player.addEffect(new MobEffectInstance(MobEffects.CONDUIT_POWER, 260, 0, true, true), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONDUIT); // CraftBukkit
}
}
}
}
private static void updateDestroyTarget(Level level, BlockPos pos, BlockState state, List<BlockPos> positions, ConduitBlockEntity blockEntity) {