Remap CraftBukkit to Mojang+Yarn Mappings

By: Initial Source <noreply+automated@papermc.io>
This commit is contained in:
CraftBukkit/Spigot
2024-12-11 22:26:55 +01:00
parent a265d64138
commit 30e4583dbe
1780 changed files with 44628 additions and 41274 deletions

View File

@@ -0,0 +1,11 @@
--- a/net/minecraft/world/item/enchantment/effects/ApplyMobEffect.java
+++ b/net/minecraft/world/item/enchantment/effects/ApplyMobEffect.java
@@ -34,7 +34,7 @@
int j = Math.round(Mth.randomBetween(randomsource, this.minDuration.calculate(level), this.maxDuration.calculate(level)) * 20.0F);
int k = Math.max(0, Math.round(Mth.randomBetween(randomsource, this.minAmplifier.calculate(level), this.maxAmplifier.calculate(level))));
- entityliving.addEffect(new MobEffectInstance((Holder) optional.get(), j, k));
+ entityliving.addEffect(new MobEffectInstance((Holder) optional.get(), j, k), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit
}
}

View File

@@ -1,11 +0,0 @@
--- a/net/minecraft/world/item/enchantment/effects/ApplyMobEffect.java
+++ b/net/minecraft/world/item/enchantment/effects/ApplyMobEffect.java
@@ -34,7 +34,7 @@
int j = Math.round(MathHelper.randomBetween(randomsource, this.minDuration.calculate(i), this.maxDuration.calculate(i)) * 20.0F);
int k = Math.max(0, Math.round(MathHelper.randomBetween(randomsource, this.minAmplifier.calculate(i), this.maxAmplifier.calculate(i))));
- entityliving.addEffect(new MobEffect((Holder) optional.get(), j, k));
+ entityliving.addEffect(new MobEffect((Holder) optional.get(), j, k), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit
}
}

View File

@@ -1,28 +1,27 @@
--- a/net/minecraft/world/item/enchantment/effects/Ignite.java
+++ b/net/minecraft/world/item/enchantment/effects/Ignite.java
@@ -8,6 +8,11 @@
@@ -7,6 +7,10 @@
import net.minecraft.world.item.enchantment.EnchantedItemInUse;
import net.minecraft.world.item.enchantment.LevelBasedValue;
import net.minecraft.world.phys.Vec3D;
import net.minecraft.world.phys.Vec3;
+// CraftBukkit start
+import org.bukkit.event.entity.EntityCombustByEntityEvent;
+import org.bukkit.event.entity.EntityCombustEvent;
+// CraftBukkit end
+
public record Ignite(LevelBasedValue duration) implements EnchantmentEntityEffect {
public static final MapCodec<Ignite> CODEC = RecordCodecBuilder.mapCodec((instance) -> {
@@ -18,7 +23,21 @@
@@ -18,7 +22,21 @@
@Override
public void apply(WorldServer worldserver, int i, EnchantedItemInUse enchantediteminuse, Entity entity, Vec3D vec3d) {
- entity.igniteForSeconds(this.duration.calculate(i));
public void apply(ServerLevel world, int level, EnchantedItemInUse context, Entity user, Vec3 pos) {
- user.igniteForSeconds(this.duration.calculate(level));
+ // CraftBukkit start - Call a combust event when somebody hits with a fire enchanted item
+ EntityCombustEvent entityCombustEvent;
+ if (enchantediteminuse.owner() != null) {
+ entityCombustEvent = new EntityCombustByEntityEvent(enchantediteminuse.owner().getBukkitEntity(), entity.getBukkitEntity(), this.duration.calculate(i));
+ if (context.owner() != null) {
+ entityCombustEvent = new EntityCombustByEntityEvent(context.owner().getBukkitEntity(), user.getBukkitEntity(), this.duration.calculate(level));
+ } else {
+ entityCombustEvent = new EntityCombustEvent(entity.getBukkitEntity(), this.duration.calculate(i));
+ entityCombustEvent = new EntityCombustEvent(user.getBukkitEntity(), this.duration.calculate(level));
+ }
+
+ org.bukkit.Bukkit.getPluginManager().callEvent(entityCombustEvent);
@@ -30,7 +29,7 @@
+ return;
+ }
+
+ entity.igniteForSeconds(entityCombustEvent.getDuration(), false);
+ user.igniteForSeconds(entityCombustEvent.getDuration(), false);
+ // CraftBukkit end
}

View File

@@ -0,0 +1,11 @@
--- a/net/minecraft/world/item/enchantment/effects/ReplaceBlock.java
+++ b/net/minecraft/world/item/enchantment/effects/ReplaceBlock.java
@@ -26,7 +26,7 @@
if ((Boolean) this.predicate.map((blockpredicate) -> {
return blockpredicate.test(world, blockposition);
- }).orElse(true) && world.setBlockAndUpdate(blockposition, this.blockState.getState(user.getRandom(), blockposition))) {
+ }).orElse(true) && org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition, this.blockState.getState(user.getRandom(), blockposition), user)) { // CraftBukkit - Call EntityBlockFormEvent
this.triggerGameEvent.ifPresent((holder) -> {
world.gameEvent(user, holder, blockposition);
});

View File

@@ -1,11 +0,0 @@
--- a/net/minecraft/world/item/enchantment/effects/ReplaceBlock.java
+++ b/net/minecraft/world/item/enchantment/effects/ReplaceBlock.java
@@ -26,7 +26,7 @@
if ((Boolean) this.predicate.map((blockpredicate) -> {
return blockpredicate.test(worldserver, blockposition);
- }).orElse(true) && worldserver.setBlockAndUpdate(blockposition, this.blockState.getState(entity.getRandom(), blockposition))) {
+ }).orElse(true) && org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(worldserver, blockposition, this.blockState.getState(entity.getRandom(), blockposition), entity)) { // CraftBukkit - Call EntityBlockFormEvent
this.triggerGameEvent.ifPresent((holder) -> {
worldserver.gameEvent(entity, holder, blockposition);
});

View File

@@ -0,0 +1,11 @@
--- a/net/minecraft/world/item/enchantment/effects/ReplaceDisk.java
+++ b/net/minecraft/world/item/enchantment/effects/ReplaceDisk.java
@@ -37,7 +37,7 @@
if (blockposition1.distToCenterSqr(pos.x(), (double) blockposition1.getY() + 0.5D, pos.z()) < (double) Mth.square(j) && (Boolean) this.predicate.map((blockpredicate) -> {
return blockpredicate.test(world, blockposition1);
- }).orElse(true) && world.setBlockAndUpdate(blockposition1, this.blockState.getState(randomsource, blockposition1))) {
+ }).orElse(true) && org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition1, this.blockState.getState(randomsource, blockposition1), user)) { // CraftBukkit - Call EntityBlockFormEvent for Frost Walker
this.triggerGameEvent.ifPresent((holder) -> {
world.gameEvent(user, holder, blockposition1);
});

View File

@@ -1,11 +0,0 @@
--- a/net/minecraft/world/item/enchantment/effects/ReplaceDisk.java
+++ b/net/minecraft/world/item/enchantment/effects/ReplaceDisk.java
@@ -37,7 +37,7 @@
if (blockposition1.distToCenterSqr(vec3d.x(), (double) blockposition1.getY() + 0.5D, vec3d.z()) < (double) MathHelper.square(j) && (Boolean) this.predicate.map((blockpredicate) -> {
return blockpredicate.test(worldserver, blockposition1);
- }).orElse(true) && worldserver.setBlockAndUpdate(blockposition1, this.blockState.getState(randomsource, blockposition1))) {
+ }).orElse(true) && org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(worldserver, blockposition1, this.blockState.getState(randomsource, blockposition1), entity)) { // CraftBukkit - Call EntityBlockFormEvent for Frost Walker
this.triggerGameEvent.ifPresent((holder) -> {
worldserver.gameEvent(entity, holder, blockposition1);
});

View File

@@ -0,0 +1,35 @@
--- a/net/minecraft/world/item/enchantment/effects/SummonEntityEffect.java
+++ b/net/minecraft/world/item/enchantment/effects/SummonEntityEffect.java
@@ -19,6 +19,11 @@
import net.minecraft.world.item.enchantment.EnchantedItemInUse;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.Vec3;
+// CraftBukkit start
+import net.minecraft.world.item.Items;
+import org.bukkit.event.entity.CreatureSpawnEvent;
+import org.bukkit.event.weather.LightningStrikeEvent;
+// CraftBukkit end
public record SummonEntityEffect(HolderSet<EntityType<?>> entityTypes, boolean joinTeam) implements EnchantmentEntityEffect {
@@ -34,7 +39,7 @@
Optional<Holder<EntityType<?>>> optional = this.entityTypes().getRandomElement(world.getRandom());
if (!optional.isEmpty()) {
- Entity entity1 = ((EntityType) ((Holder) optional.get()).value()).spawn(world, blockposition, EntitySpawnReason.TRIGGERED);
+ Entity entity1 = ((EntityType) ((Holder) optional.get()).value()).create(world, null, blockposition, EntitySpawnReason.TRIGGERED, false, false); // CraftBukkit
if (entity1 != null) {
if (entity1 instanceof LightningBolt) {
@@ -46,6 +51,11 @@
entitylightning.setCause(entityplayer);
}
+ // CraftBukkit start
+ world.strikeLightning(entity1, (context.itemStack().getItem() == Items.TRIDENT) ? LightningStrikeEvent.Cause.TRIDENT : LightningStrikeEvent.Cause.ENCHANTMENT);
+ } else {
+ world.addFreshEntityWithPassengers(entity1, CreatureSpawnEvent.SpawnReason.ENCHANTMENT);
+ // CraftBukkit end
}
if (this.joinTeam && user.getTeam() != null) {

View File

@@ -1,36 +0,0 @@
--- a/net/minecraft/world/item/enchantment/effects/SummonEntityEffect.java
+++ b/net/minecraft/world/item/enchantment/effects/SummonEntityEffect.java
@@ -20,6 +20,12 @@
import net.minecraft.world.level.World;
import net.minecraft.world.phys.Vec3D;
+// CraftBukkit start
+import net.minecraft.world.item.Items;
+import org.bukkit.event.entity.CreatureSpawnEvent;
+import org.bukkit.event.weather.LightningStrikeEvent;
+// CraftBukkit end
+
public record SummonEntityEffect(HolderSet<EntityTypes<?>> entityTypes, boolean joinTeam) implements EnchantmentEntityEffect {
public static final MapCodec<SummonEntityEffect> CODEC = RecordCodecBuilder.mapCodec((instance) -> {
@@ -34,7 +40,7 @@
Optional<Holder<EntityTypes<?>>> optional = this.entityTypes().getRandomElement(worldserver.getRandom());
if (!optional.isEmpty()) {
- Entity entity1 = ((EntityTypes) ((Holder) optional.get()).value()).spawn(worldserver, blockposition, EntitySpawnReason.TRIGGERED);
+ Entity entity1 = ((EntityTypes) ((Holder) optional.get()).value()).create(worldserver, null, blockposition, EntitySpawnReason.TRIGGERED, false, false); // CraftBukkit
if (entity1 != null) {
if (entity1 instanceof EntityLightning) {
@@ -46,6 +52,11 @@
entitylightning.setCause(entityplayer);
}
+ // CraftBukkit start
+ worldserver.strikeLightning(entity1, (enchantediteminuse.itemStack().getItem() == Items.TRIDENT) ? LightningStrikeEvent.Cause.TRIDENT : LightningStrikeEvent.Cause.ENCHANTMENT);
+ } else {
+ worldserver.addFreshEntityWithPassengers(entity1, CreatureSpawnEvent.SpawnReason.ENCHANTMENT);
+ // CraftBukkit end
}
if (this.joinTeam && entity.getTeam() != null) {