13
0
geforkt von Mirrors/Paper
Dieser Commit ist enthalten in:
Nassim Jahnke 2024-12-13 18:40:47 +01:00
Ursprung e9b739bc48
Commit aa998246f7
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: EF6771C01F6EF02F
14 geänderte Dateien mit 129 neuen und 167 gelöschten Zeilen

Datei anzeigen

@ -0,0 +1,35 @@
--- a/net/minecraft/server/rcon/RconConsoleSource.java
+++ b/net/minecraft/server/rcon/RconConsoleSource.java
@@ -13,8 +_,13 @@
private static final Component RCON_COMPONENT = Component.literal("Rcon");
private final StringBuffer buffer = new StringBuffer();
private final MinecraftServer server;
+ // CraftBukkit start
+ public final java.net.SocketAddress socketAddress;
+ private final org.bukkit.craftbukkit.command.CraftRemoteConsoleCommandSender remoteConsole = new org.bukkit.craftbukkit.command.CraftRemoteConsoleCommandSender(this);
- public RconConsoleSource(MinecraftServer server) {
+ public RconConsoleSource(MinecraftServer server, java.net.SocketAddress socketAddress) {
+ this.socketAddress = socketAddress;
+ // CraftBukkit end
this.server = server;
}
@@ -32,6 +_,17 @@
this, Vec3.atLowerCornerOf(serverLevel.getSharedSpawnPos()), Vec2.ZERO, serverLevel, 4, "Rcon", RCON_COMPONENT, this.server, null
);
}
+
+ // CraftBukkit start - Send a String
+ public void sendMessage(String message) {
+ this.buffer.append(message);
+ }
+
+ @Override
+ public org.bukkit.command.CommandSender getBukkitSender(CommandSourceStack wrapper) {
+ return this.remoteConsole;
+ }
+ // CraftBukkit end
@Override
public void sendSystemMessage(Component component) {

Datei anzeigen

@ -0,0 +1,11 @@
--- a/net/minecraft/world/item/enchantment/effects/ApplyMobEffect.java
+++ b/net/minecraft/world/item/enchantment/effects/ApplyMobEffect.java
@@ -44,7 +_,7 @@
int max = Math.max(
0, Math.round(Mth.randomBetween(random, this.minAmplifier.calculate(enchantmentLevel), this.maxAmplifier.calculate(enchantmentLevel)))
);
- livingEntity.addEffect(new MobEffectInstance(randomElement.get(), rounded, max));
+ livingEntity.addEffect(new MobEffectInstance(randomElement.get(), rounded, max), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit
}
}
}

Datei anzeigen

@ -0,0 +1,14 @@
--- a/net/minecraft/world/item/enchantment/effects/ChangeItemDamage.java
+++ b/net/minecraft/world/item/enchantment/effects/ChangeItemDamage.java
@@ -21,9 +_,9 @@
public void apply(ServerLevel level, int enchantmentLevel, EnchantedItemInUse item, Entity entity, Vec3 origin) {
ItemStack itemStack = item.itemStack();
if (itemStack.has(DataComponents.MAX_DAMAGE) && itemStack.has(DataComponents.DAMAGE)) {
- ServerPlayer serverPlayer1 = item.owner() instanceof ServerPlayer serverPlayer ? serverPlayer : null;
+ //ServerPlayer serverPlayer1 = item.owner() instanceof ServerPlayer serverPlayer ? serverPlayer : null; // Paper - EntityDamageItemEvent - always pass in entity
int i = (int)this.amount.calculate(enchantmentLevel);
- itemStack.hurtAndBreak(i, level, serverPlayer1, item.onBreak());
+ itemStack.hurtAndBreak(i, level, item.owner(), item.onBreak()); // Paper - EntityDamageItemEvent - always pass in entity
}
}

Datei anzeigen

@ -0,0 +1,25 @@
--- a/net/minecraft/world/item/enchantment/effects/Ignite.java
+++ b/net/minecraft/world/item/enchantment/effects/Ignite.java
@@ -15,7 +_,21 @@
@Override
public void apply(ServerLevel level, int enchantmentLevel, EnchantedItemInUse item, Entity entity, Vec3 origin) {
- entity.igniteForSeconds(this.duration.calculate(enchantmentLevel));
+ // CraftBukkit start - Call a combust event when somebody hits with a fire enchanted item
+ org.bukkit.event.entity.EntityCombustEvent entityCombustEvent;
+ if (item.owner() != null) {
+ entityCombustEvent = new org.bukkit.event.entity.EntityCombustByEntityEvent(item.owner().getBukkitEntity(), entity.getBukkitEntity(), this.duration.calculate(enchantmentLevel));
+ } else {
+ entityCombustEvent = new org.bukkit.event.entity.EntityCombustEvent(entity.getBukkitEntity(), this.duration.calculate(enchantmentLevel));
+ }
+
+ org.bukkit.Bukkit.getPluginManager().callEvent(entityCombustEvent);
+ if (entityCombustEvent.isCancelled()) {
+ return;
+ }
+
+ entity.igniteForSeconds(entityCombustEvent.getDuration(), false);
+ // CraftBukkit end
}
@Override

Datei anzeigen

@ -0,0 +1,13 @@
--- a/net/minecraft/world/item/enchantment/effects/ReplaceBlock.java
+++ b/net/minecraft/world/item/enchantment/effects/ReplaceBlock.java
@@ -29,8 +_,9 @@
@Override
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
this.triggerGameEvent.ifPresent(holder -> level.gameEvent(entity, (Holder<GameEvent>)holder, blockPos));
}
}

Datei anzeigen

@ -0,0 +1,11 @@
--- a/net/minecraft/world/item/enchantment/effects/ReplaceDisk.java
+++ b/net/minecraft/world/item/enchantment/effects/ReplaceDisk.java
@@ -47,7 +_,7 @@
for (BlockPos blockPos1 : BlockPos.betweenClosed(blockPos.offset(-i, 0, -i), blockPos.offset(i, Math.min(i1 - 1, 0), i))) {
if (blockPos1.distToCenterSqr(origin.x(), blockPos1.getY() + 0.5, origin.z()) < Mth.square(i)
&& this.predicate.map(predicate -> predicate.test(level, blockPos1)).orElse(true)
- && level.setBlockAndUpdate(blockPos1, this.blockState.getState(random, blockPos1))) {
+ && org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(level, blockPos1, this.blockState.getState(random, blockPos1), entity)) { // CraftBukkit - Call EntityBlockFormEvent for Frost Walker
this.triggerGameEvent.ifPresent(event -> level.gameEvent(entity, (Holder<GameEvent>)event, blockPos1));
}
}

Datei anzeigen

@ -0,0 +1,20 @@
--- a/net/minecraft/world/item/enchantment/effects/SummonEntityEffect.java
+++ b/net/minecraft/world/item/enchantment/effects/SummonEntityEffect.java
@@ -34,11 +_,16 @@
if (Level.isInSpawnableBounds(blockPos)) {
Optional<Holder<EntityType<?>>> randomElement = this.entityTypes().getRandomElement(level.getRandom());
if (!randomElement.isEmpty()) {
- Entity entity1 = randomElement.get().value().spawn(level, blockPos, EntitySpawnReason.TRIGGERED);
+ Entity entity1 = randomElement.get().value().create(level, null, blockPos, EntitySpawnReason.TRIGGERED, false, false); // CraftBukkit
if (entity1 != null) {
if (entity1 instanceof LightningBolt lightningBolt && item.owner() instanceof ServerPlayer serverPlayer) {
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);
+ // CraftBukkit end
if (this.joinTeam && entity.getTeam() != null) {
level.getScoreboard().addPlayerToTeam(entity1.getScoreboardName(), entity.getTeam());

Datei anzeigen

@ -1,49 +0,0 @@
--- a/net/minecraft/server/rcon/RconConsoleSource.java
+++ b/net/minecraft/server/rcon/RconConsoleSource.java
@@ -8,16 +8,24 @@
import net.minecraft.world.entity.Entity;
import net.minecraft.world.phys.Vec2;
import net.minecraft.world.phys.Vec3;
-
+// CraftBukkit start
+import java.net.SocketAddress;
+import org.bukkit.craftbukkit.command.CraftRemoteConsoleCommandSender;
+// CraftBukkit end
public class RconConsoleSource implements CommandSource {
private static final String RCON = "Rcon";
private static final Component RCON_COMPONENT = Component.literal("Rcon");
private final StringBuffer buffer = new StringBuffer();
private final MinecraftServer server;
+ // CraftBukkit start
+ public final SocketAddress socketAddress;
+ private final CraftRemoteConsoleCommandSender remoteConsole = new CraftRemoteConsoleCommandSender(this);
- public RconConsoleSource(MinecraftServer server) {
- this.server = server;
+ public RconConsoleSource(MinecraftServer minecraftserver, SocketAddress socketAddress) {
+ this.socketAddress = socketAddress;
+ // CraftBukkit end
+ this.server = minecraftserver;
}
public void prepareForCommand() {
@@ -34,7 +42,18 @@
return new CommandSourceStack(this, Vec3.atLowerCornerOf(worldserver.getSharedSpawnPos()), Vec2.ZERO, worldserver, 4, "Rcon", RconConsoleSource.RCON_COMPONENT, this.server, (Entity) null);
}
+ // CraftBukkit start - Send a String
+ public void sendMessage(String message) {
+ this.buffer.append(message);
+ }
+
@Override
+ public org.bukkit.command.CommandSender getBukkitSender(CommandSourceStack wrapper) {
+ return this.remoteConsole;
+ }
+ // CraftBukkit end
+
+ @Override
public void sendSystemMessage(Component message) {
this.buffer.append(message.getString());
}

Datei anzeigen

@ -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(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
}
}

Datei anzeigen

@ -1,14 +0,0 @@
--- a/net/minecraft/world/item/enchantment/effects/ChangeItemDamage.java
+++ b/net/minecraft/world/item/enchantment/effects/ChangeItemDamage.java
@@ -21,9 +21,9 @@
public void apply(ServerLevel world, int level, EnchantedItemInUse context, Entity user, Vec3 pos) {
ItemStack itemStack = context.itemStack();
if (itemStack.has(DataComponents.MAX_DAMAGE) && itemStack.has(DataComponents.DAMAGE)) {
- ServerPlayer serverPlayer2 = context.owner() instanceof ServerPlayer serverPlayer ? serverPlayer : null;
+ // ServerPlayer serverPlayer2 = context.owner() instanceof ServerPlayer serverPlayer ? serverPlayer : null; // Paper - EntityDamageItemEvent - always pass in entity
int i = (int)this.amount.calculate(level);
- itemStack.hurtAndBreak(i, world, serverPlayer2, context.onBreak());
+ itemStack.hurtAndBreak(i, world, context.owner(), context.onBreak()); // Paper - EntityDamageItemEvent - always pass in entity
}
}

Datei anzeigen

@ -1,36 +0,0 @@
--- a/net/minecraft/world/item/enchantment/effects/Ignite.java
+++ b/net/minecraft/world/item/enchantment/effects/Ignite.java
@@ -7,6 +7,10 @@
import net.minecraft.world.item.enchantment.EnchantedItemInUse;
import net.minecraft.world.item.enchantment.LevelBasedValue;
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 {
@@ -18,7 +22,21 @@
@Override
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 (context.owner() != null) {
+ entityCombustEvent = new EntityCombustByEntityEvent(context.owner().getBukkitEntity(), user.getBukkitEntity(), this.duration.calculate(level));
+ } else {
+ entityCombustEvent = new EntityCombustEvent(user.getBukkitEntity(), this.duration.calculate(level));
+ }
+
+ org.bukkit.Bukkit.getPluginManager().callEvent(entityCombustEvent);
+ if (entityCombustEvent.isCancelled()) {
+ return;
+ }
+
+ user.igniteForSeconds(entityCombustEvent.getDuration(), false);
+ // CraftBukkit end
}
@Override

Datei anzeigen

@ -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(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);
});

Datei anzeigen

@ -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(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);
});

Datei anzeigen

@ -1,35 +0,0 @@
--- 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) {