More work

This commit is contained in:
Nassim Jahnke 2024-12-03 19:05:31 +01:00
parent 2103d82751
commit 529f01a04a
158 changed files with 113 additions and 117 deletions

View file

@ -271,7 +271,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Paper end - knockback events
}
// CraftBukkit end
entity.setDeltaMovement(entity.getDeltaMovement().add(vec3d));
entity.push(vec3d);
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java

View file

@ -18,9 +18,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
switch (packet.getAction()) {
case PRESS_SHIFT_KEY:
this.player.setShiftKeyDown(true);
switch (packet.getAction()) {
case PRESS_SHIFT_KEY:
this.player.setShiftKeyDown(true);
+
+ // Paper start - Add option to make parrots stay
+ if (this.player.level().paperConfig().entities.behavior.parrotsAreUnaffectedByPlayerMovement) {
@ -28,9 +28,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ }
+ // Paper end - Add option to make parrots stay
+
break;
case RELEASE_SHIFT_KEY:
this.player.setShiftKeyDown(false);
break;
case RELEASE_SHIFT_KEY:
this.player.setShiftKeyDown(false);
diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/player/Player.java

View file

@ -13,14 +13,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
double d0 = entity.getX();
double d1 = entity.getY();
double d2 = entity.getZ();
- double d3 = ServerGamePacketListenerImpl.clampHorizontal(packet.getX());
- double d4 = ServerGamePacketListenerImpl.clampVertical(packet.getY());
- double d5 = ServerGamePacketListenerImpl.clampHorizontal(packet.getZ());
+ double d3 = ServerGamePacketListenerImpl.clampHorizontal(packet.getX()); final double toX = d3; // Paper - OBFHELPER
+ double d4 = ServerGamePacketListenerImpl.clampVertical(packet.getY()); final double toY = d4; // Paper - OBFHELPER
+ double d5 = ServerGamePacketListenerImpl.clampHorizontal(packet.getZ()); final double toZ = d5; // Paper - OBFHELPER
float f = Mth.wrapDegrees(packet.getYRot());
float f1 = Mth.wrapDegrees(packet.getXRot());
- double d3 = ServerGamePacketListenerImpl.clampHorizontal(packet.position().x());
- double d4 = ServerGamePacketListenerImpl.clampVertical(packet.position().y());
- double d5 = ServerGamePacketListenerImpl.clampHorizontal(packet.position().z());
+ double d3 = ServerGamePacketListenerImpl.clampHorizontal(packet.position().x()); final double toX = d3; // Paper - OBFHELPER
+ double d4 = ServerGamePacketListenerImpl.clampVertical(packet.position().y()); final double toY = d4; // Paper - OBFHELPER
+ double d5 = ServerGamePacketListenerImpl.clampHorizontal(packet.position().z()); final double toZ = d5; // Paper - OBFHELPER
float f = Mth.wrapDegrees(packet.yRot());
float f1 = Mth.wrapDegrees(packet.xRot());
double d6 = d3 - this.vehicleFirstGoodX;
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
}
@ -42,7 +42,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
}
if (!this.updateAwaitingTeleport()) {
if (!this.updateAwaitingTeleport() && this.player.hasClientLoaded()) {
- double d0 = ServerGamePacketListenerImpl.clampHorizontal(packet.getX(this.player.getX()));
- double d1 = ServerGamePacketListenerImpl.clampVertical(packet.getY(this.player.getY()));
- double d2 = ServerGamePacketListenerImpl.clampHorizontal(packet.getZ(this.player.getZ()));

View file

@ -0,0 +1,31 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: BillyGalbreath <Blake.Galbreath@GMail.com>
Date: Sat, 8 Sep 2018 18:43:31 -0500
Subject: [PATCH] Allow chests to be placed with NBT data
diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/item/ItemStack.java
+++ b/src/main/java/net/minecraft/world/item/ItemStack.java
@@ -0,0 +0,0 @@ public final class ItemStack implements DataComponentHolder {
enuminteractionresult = InteractionResult.FAIL; // cancel placement
// PAIL: Remove this when MC-99075 fixed
placeEvent.getPlayer().updateInventory();
+ world.capturedTileEntities.clear(); // Paper - Allow chests to be placed with NBT data; clear out block entities as chests and such will pop loot
// revert back all captured blocks
world.preventPoiUpdated = true; // CraftBukkit - SPIGOT-5710
for (BlockState blockstate : blocks) {
diff --git a/src/main/java/net/minecraft/world/level/block/entity/BlockEntityType.java b/src/main/java/net/minecraft/world/level/block/entity/BlockEntityType.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/BlockEntityType.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/BlockEntityType.java
@@ -0,0 +0,0 @@ public class BlockEntityType<T extends BlockEntity> {
public static final BlockEntityType<CrafterBlockEntity> CRAFTER = BlockEntityType.register("crafter", CrafterBlockEntity::new, Blocks.CRAFTER);
public static final BlockEntityType<TrialSpawnerBlockEntity> TRIAL_SPAWNER = BlockEntityType.register("trial_spawner", TrialSpawnerBlockEntity::new, Blocks.TRIAL_SPAWNER);
public static final BlockEntityType<VaultBlockEntity> VAULT = BlockEntityType.register("vault", VaultBlockEntity::new, Blocks.VAULT);
- private static final Set<BlockEntityType<?>> OP_ONLY_CUSTOM_DATA = Set.of(BlockEntityType.COMMAND_BLOCK, BlockEntityType.LECTERN, BlockEntityType.SIGN, BlockEntityType.HANGING_SIGN, BlockEntityType.MOB_SPAWNER, BlockEntityType.TRIAL_SPAWNER, BlockEntityType.CHEST); // CraftBukkit
+ private static final Set<BlockEntityType<?>> OP_ONLY_CUSTOM_DATA = Set.of(BlockEntityType.COMMAND_BLOCK, BlockEntityType.LECTERN, BlockEntityType.SIGN, BlockEntityType.HANGING_SIGN, BlockEntityType.MOB_SPAWNER, BlockEntityType.TRIAL_SPAWNER); // CraftBukkit // Paper - Allow chests to be placed with NBT data
private final BlockEntityType.BlockEntitySupplier<? extends T> factory;
public final Set<Block> validBlocks;
private final Holder.Reference<BlockEntityType<?>> builtInRegistryHolder;

View file

@ -15,14 +15,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
}
boolean isBeingStaredBy(Player player) {
+ // Paper start - EndermanAttackPlayerEvent
+ boolean shouldAttack = isBeingStaredBy0(player);
+ com.destroystokyo.paper.event.entity.EndermanAttackPlayerEvent event = new com.destroystokyo.paper.event.entity.EndermanAttackPlayerEvent((org.bukkit.entity.Enderman) getBukkitEntity(), (org.bukkit.entity.Player) player.getBukkitEntity());
+ // Paper start - EndermanAttackPlayerEvent
+ final boolean shouldAttack = isBeingStaredBy0(player);
+ final com.destroystokyo.paper.event.entity.EndermanAttackPlayerEvent event = new com.destroystokyo.paper.event.entity.EndermanAttackPlayerEvent((org.bukkit.entity.Enderman) getBukkitEntity(), (org.bukkit.entity.Player) player.getBukkitEntity());
+ event.setCancelled(!shouldAttack);
+ return event.callEvent();
+ }
+ private boolean isBeingStaredBy0(Player player) {
+ // Paper end - EndermanAttackPlayerEvent
return this.isLookingAtMe(player, 0.025D, true, false, LivingEntity.PLAYER_NOT_WEARING_DISGUISE_ITEM, new DoubleSupplier[]{this::getEyeY});
+ // Paper end - EndermanAttackPlayerEvent
return !LivingEntity.PLAYER_NOT_WEARING_DISGUISE_ITEM.test(player) ? false : this.isLookingAtMe(player, 0.025D, true, false, new double[]{this.getEyeY()});
}

View file

@ -16,14 +16,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
}
public <T extends ParticleOptions> int sendParticles(ServerPlayer sender, T t0, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6, boolean force) {
public <T extends ParticleOptions> int sendParticlesSource(ServerPlayer sender, T t0, boolean flag, boolean flag1, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6) {
+ // Paper start - Particle API
+ return sendParticles(players, sender, t0, d0, d1, d2, i, d3, d4, d5, d6, force);
+ return this.sendParticlesSource(this.players, sender, t0, flag, flag1, d0, d1, d2, i, d3, d4, d5, d6);
+ }
+ public <T extends ParticleOptions> int sendParticles(List<ServerPlayer> receivers, @Nullable ServerPlayer sender, T t0, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6, boolean force) {
+ public <T extends ParticleOptions> int sendParticlesSource(List<ServerPlayer> receivers, ServerPlayer sender, T t0, boolean flag, boolean flag1, double d0, double d1, double d2, int i, double d3, double d4, double d5, double d6) {
+ // Paper end - Particle API
ClientboundLevelParticlesPacket packetplayoutworldparticles = new ClientboundLevelParticlesPacket(t0, force, d0, d1, d2, (float) d3, (float) d4, (float) d5, (float) d6, i);
// CraftBukkit end
ClientboundLevelParticlesPacket packetplayoutworldparticles = new ClientboundLevelParticlesPacket(t0, flag, flag1, d0, d1, d2, (float) d3, (float) d4, (float) d5, (float) d6, i);
int j = 0;
- for (int k = 0; k < this.players.size(); ++k) {
@ -32,7 +32,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ ServerPlayer entityplayer = (ServerPlayer) entityhuman; // Paper - Particle API
if (sender != null && !entityplayer.getBukkitEntity().canSee(sender.getBukkitEntity())) continue; // CraftBukkit
if (this.sendParticles(entityplayer, force, d0, d1, d2, packetplayoutworldparticles)) { // CraftBukkit
if (this.sendParticles(entityplayer, flag, d0, d1, d2, packetplayoutworldparticles)) {
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@ -51,10 +51,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ if (data != null) {
+ Preconditions.checkArgument(particle.getDataType().isInstance(data), "data (%s) should be %s", data.getClass(), particle.getDataType());
+ }
this.getHandle().sendParticles(
this.getHandle().sendParticlesSource(
- null, // Sender
+ receivers == null ? this.getHandle().players() : receivers.stream().map(player -> ((CraftPlayer) player).getHandle()).collect(java.util.stream.Collectors.toList()), // Paper - Particle API
+ sender != null ? ((CraftPlayer) sender).getHandle() : null, // Sender // Paper - Particle API
CraftParticle.createParticleParam(particle, data), // Particle
false, force,
x, y, z, // Position
count, // Count

View file

@ -211,11 +211,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
if (this.dragonDeathTime == 1 && !this.isSilent()) {
@@ -0,0 +0,0 @@ public class EnderDragon extends Mob implements Enemy {
if (world instanceof ServerLevel) {
ServerLevel worldserver = (ServerLevel) world; // CraftBukkit - decompile error
ServerLevel worldserver1 = (ServerLevel) world1;
if (true) { // CraftBukkit - SPIGOT-2420: Already checked for the game rule when calculating the xp
- ExperienceOrb.award(worldserver, this.position(), Mth.floor((float) short0 * 0.2F));
+ ExperienceOrb.award(worldserver, this.position(), Mth.floor((float) short0 * 0.2F), org.bukkit.entity.ExperienceOrb.SpawnReason.ENTITY_DEATH, this.lastHurtByPlayer, this); // Paper
- ExperienceOrb.award(worldserver1, this.position(), Mth.floor((float) short0 * 0.2F));
+ ExperienceOrb.award(worldserver1, this.position(), Mth.floor((float) short0 * 0.2F), org.bukkit.entity.ExperienceOrb.SpawnReason.ENTITY_DEATH, this.lastHurtByPlayer, this); // Paper
}
if (this.dragonFight != null) {

View file

@ -36,7 +36,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
@@ -0,0 +0,0 @@ public class Main {
Calendar deadline = Calendar.getInstance();
deadline.add(Calendar.DAY_OF_YEAR, -14);
deadline.add(Calendar.DAY_OF_YEAR, -2);
if (buildDate.before(deadline.getTime())) {
- System.err.println("*** Error, this build is outdated ***");
+ // Paper start - This is some stupid bullshit

View file

@ -16,16 +16,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java
@@ -0,0 +0,0 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit
protected NonNullList<ItemStack> items;
public int litTime;
int litDuration;
+ public double cookSpeedMultiplier = 1.0; // Paper - cook speed multiplier API
public int cookingProgress;
public int cookingTotalTime;
protected final ContainerData dataAccess;
public final Reference2IntOpenHashMap<ResourceKey<Recipe<?>>> recipesUsed;
private final RecipeManager.CachedCheck<SingleRecipeInput, ? extends AbstractCookingRecipe> quickCheck;
+ public final RecipeType<? extends AbstractCookingRecipe> recipeType; // Paper - cook speed multiplier API
+ public double cookSpeedMultiplier = 1.0; // Paper - cook speed multiplier API
protected AbstractFurnaceBlockEntity(BlockEntityType<?> blockEntityType, BlockPos pos, BlockState state, RecipeType<? extends AbstractCookingRecipe> recipeType) {
super(blockEntityType, pos, state);
@ -50,9 +45,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@Override
@@ -0,0 +0,0 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit
nbt.putShort("BurnTime", (short) this.litTime);
nbt.putShort("CookTime", (short) this.cookingProgress);
nbt.putShort("CookTimeTotal", (short) this.cookingTotalTime);
nbt.putShort("cooking_total_time", (short) this.cookingTotalTime);
nbt.putShort("lit_time_remaining", (short) this.litTimeRemaining);
nbt.putShort("lit_total_time", (short) this.litTotalTime);
+ nbt.putDouble("Paper.CookSpeedMultiplier", this.cookSpeedMultiplier); // Paper - cook speed multiplier API
ContainerHelper.saveAllItems(nbt, this.items, registries);
CompoundTag nbttagcompound1 = new CompoundTag();
@ -69,10 +64,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit
// CraftBukkit end
++blockEntity.cookingProgress;
- if (blockEntity.cookingProgress == blockEntity.cookingTotalTime) {
+ if (blockEntity.cookingProgress >= blockEntity.cookingTotalTime) { // Paper - cook speed multiplier API
blockEntity.cookingProgress = 0;
++blockEntity.cookingTimer;
- if (blockEntity.cookingTimer == blockEntity.cookingTotalTime) {
+ if (blockEntity.cookingTimer >= blockEntity.cookingTotalTime) { // Paper - cook speed multiplier API
blockEntity.cookingTimer = 0;
- blockEntity.cookingTotalTime = AbstractFurnaceBlockEntity.getTotalCookTime(world, blockEntity);
+ blockEntity.cookingTotalTime = AbstractFurnaceBlockEntity.getTotalCookTime(world, blockEntity, blockEntity.recipeType, blockEntity.cookSpeedMultiplier); // Paper - cook speed multiplier API
if (AbstractFurnaceBlockEntity.burn(blockEntity.level, blockEntity.worldPosition, world.registryAccess(), recipeholder, singlerecipeinput, blockEntity.items, i)) { // CraftBukkit
@ -104,7 +99,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- this.cookingTotalTime = AbstractFurnaceBlockEntity.getTotalCookTime(worldserver, this);
+ this.cookingTotalTime = AbstractFurnaceBlockEntity.getTotalCookTime(worldserver, this, this.recipeType, this.cookSpeedMultiplier); // Paper - cook speed multiplier API
this.cookingProgress = 0;
this.cookingTimer = 0;
this.setChanged();
}
}

View file

@ -60,24 +60,24 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
// SPIGOT-943 - only call if they have an inventory open
if (this.containerMenu != this.inventoryMenu) {
@@ -0,0 +0,0 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player {
}
}
- return super.hurtServer(world, source, amount);
+ // Paper start - cancellable death events
+ //return super.hurt(source, amount);
+ this.queueHealthUpdatePacket = true;
+ boolean damaged = super.hurtServer(world, source, amount);
+ this.queueHealthUpdatePacket = false;
+ if (this.queuedHealthUpdatePacket != null) {
+ this.connection.send(this.queuedHealthUpdatePacket);
+ this.queuedHealthUpdatePacket = null;
+ }
+ return damaged;
+ // Paper end
}
- return super.hurtServer(world, source, amount);
+ // Paper start - cancellable death events
+ //return super.hurt(world, source, amount);
+ this.queueHealthUpdatePacket = true;
+ boolean damaged = super.hurtServer(world, source, amount);
+ this.queueHealthUpdatePacket = false;
+ if (this.queuedHealthUpdatePacket != null) {
+ this.connection.send(this.queuedHealthUpdatePacket);
+ this.queuedHealthUpdatePacket = null;
+ }
+ return damaged;
+ // Paper end - cancellable death events
}
}
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
@ -111,14 +111,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
LivingEntity entityliving = this.getKillCredit();
+ /* // Paper - move down to make death event cancellable - this is the awardKillScore below
if (this.deathScore >= 0 && entityliving != null) {
entityliving.awardKillScore(this, this.deathScore, damageSource);
if (entityliving != null) {
entityliving.awardKillScore(this, damageSource);
}
@@ -0,0 +0,0 @@ public abstract class LivingEntity extends Entity implements Attackable {
if (!this.level().isClientSide && this.hasCustomName()) {
if (org.spigotmc.SpigotConfig.logNamedDeaths) LivingEntity.LOGGER.info("Named entity {} died: {}", this, this.getCombatTracker().getDeathMessage().getString()); // Spigot
}
+ */ // Paper - move down to make death event cancellable - this is the awardKillScore below
+ */ // Paper - move down to make death event cancellable - this is the awardKillScore below
this.dead = true;
- this.getCombatTracker().recheckStatus();
@ -132,8 +132,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Paper start
+ org.bukkit.event.entity.EntityDeathEvent deathEvent = this.dropAllDeathLoot(worldserver, damageSource);
+ if (deathEvent == null || !deathEvent.isCancelled()) {
+ if (this.deathScore >= 0 && entityliving != null) {
+ entityliving.awardKillScore(this, this.deathScore, damageSource);
+ if (entityliving != null) {
+ entityliving.awardKillScore(this, damageSource);
+ }
+ // Paper start - clear equipment if event is not cancelled
+ if (this instanceof Mob) {

View file

@ -35,7 +35,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player {
}
// Paper end - Configurable container update tick rate
if (!this.level().isClientSide && !this.containerMenu.stillValid(this)) {
if (!this.containerMenu.stillValid(this)) {
- this.closeContainer();
+ this.closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.CANT_USE); // Paper - Inventory close reason
this.containerMenu = this.inventoryMenu;

Some files were not shown because too many files have changed in this diff Show more