reapply SummonEntityEffect

This commit is contained in:
Lulu13022002
2024-12-19 18:35:43 +01:00
parent a438cc45f6
commit 1f86b55302
5 changed files with 14 additions and 22 deletions

View File

@@ -1,10 +1,8 @@
--- a/net/minecraft/world/item/enchantment/effects/ReplaceBlock.java
+++ b/net/minecraft/world/item/enchantment/effects/ReplaceBlock.java
@@ -29,8 +_,9 @@
@Override
@@ -30,7 +_,7 @@
public void apply(ServerLevel level, int enchantmentLevel, EnchantedItemInUse item, Entity entity, Vec3 origin) {
BlockPos blockPos = BlockPos.containing(origin).offset(this.offset);
+ // }).orElse(true) &&
if (this.predicate.map(blockPredicate -> blockPredicate.test(level, blockPos)).orElse(true)
- && level.setBlockAndUpdate(blockPos, this.blockState.getState(entity.getRandom(), blockPos))) {
+ && org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(level, blockPos, this.blockState.getState(entity.getRandom(), blockPos), entity)) { // CraftBukkit - Call EntityBlockFormEvent

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/item/enchantment/effects/SummonEntityEffect.java
+++ b/net/minecraft/world/item/enchantment/effects/SummonEntityEffect.java
@@ -34,11 +_,16 @@
@@ -34,11 +_,18 @@
if (Level.isInSpawnableBounds(blockPos)) {
Optional<Holder<EntityType<?>>> randomElement = this.entityTypes().getRandomElement(level.getRandom());
if (!randomElement.isEmpty()) {
@@ -11,9 +11,11 @@
lightningBolt.setCause(serverPlayer);
}
+ // CraftBukkit start
+ level.strikeLightning(entity1, (item.itemStack().getItem() == net.minecraft.world.item.Items.TRIDENT) ? org.bukkit.event.weather.LightningStrikeEvent.Cause.TRIDENT : org.bukkit.event.weather.LightningStrikeEvent.Cause.ENCHANTMENT);
+ } else {
+ level.addFreshEntityWithPassengers(entity1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.ENCHANTMENT);
+ if (entity1 instanceof LightningBolt) {
+ level.strikeLightning(entity1, (item.itemStack().is(net.minecraft.world.item.Items.TRIDENT)) ? org.bukkit.event.weather.LightningStrikeEvent.Cause.TRIDENT : org.bukkit.event.weather.LightningStrikeEvent.Cause.ENCHANTMENT);
+ } else {
+ level.addFreshEntityWithPassengers(entity1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.ENCHANTMENT);
+ }
+ // CraftBukkit end
if (this.joinTeam && entity.getTeam() != null) {

View File

@@ -90,7 +90,7 @@
+ final List<BlockPos> moved = pistonStructureResolver.getToPush();
+ final List<BlockPos> broken = pistonStructureResolver.getToDestroy();
+
+ List<org.bukkit.block.Block> blocks = new java.util.AbstractList<org.bukkit.block.Block>() {
+ List<org.bukkit.block.Block> blocks = new java.util.AbstractList<>() {
+
+ @Override
+ public int size() {
@@ -102,7 +102,7 @@
+ if (index >= this.size() || index < 0) {
+ throw new ArrayIndexOutOfBoundsException(index);
+ }
+ BlockPos pos = (BlockPos) (index < moved.size() ? moved.get(index) : broken.get(index - moved.size()));
+ BlockPos pos = index < moved.size() ? moved.get(index) : broken.get(index - moved.size());
+ return bblock.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ());
+ }
+ };

View File

@@ -1,13 +1,5 @@
--- a/net/minecraft/world/level/block/state/BlockBehaviour.java
+++ b/net/minecraft/world/level/block/state/BlockBehaviour.java
@@ -46,6 +_,7 @@
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.context.BlockPlaceContext;
+import net.minecraft.world.item.context.UseOnContext;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.EmptyBlockGetter;
import net.minecraft.world.level.Explosion;
@@ -167,16 +_,24 @@
}
@@ -17,7 +9,7 @@
+ }
+
+ // CraftBukkit start
+ protected void onPlace(BlockState iblockdata, Level world, BlockPos blockposition, BlockState iblockdata1, boolean flag, @Nullable UseOnContext context) {
+ protected void onPlace(BlockState iblockdata, Level world, BlockPos blockposition, BlockState iblockdata1, boolean flag, @Nullable net.minecraft.world.item.context.UseOnContext context) {
+ this.onPlace(iblockdata, world, blockposition, iblockdata1, flag);
+ }
+ // CraftBukkit end
@@ -152,7 +144,7 @@
+ this.onPlace(level, pos, oldState, movedByPiston, null);
+ }
+
+ public void onPlace(Level level, BlockPos pos, BlockState oldState, boolean movedByPiston, @Nullable UseOnContext context) {
+ public void onPlace(Level level, BlockPos pos, BlockState oldState, boolean movedByPiston, @Nullable net.minecraft.world.item.context.UseOnContext context) {
+ this.getBlock().onPlace(this.asState(), level, pos, oldState, movedByPiston, context);
+ // CraftBukkit end
}