all api patches done*
*still waiting for leaf to port datafixer to 1.18 so i can do entity serialization
This commit is contained in:
parent
4df6820f86
commit
c1d14dc076
34 changed files with 49 additions and 62 deletions
|
@ -5,10 +5,10 @@ Subject: [PATCH] Add Raw Byte Entity Serialization
|
|||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index 996f09eaf7d1d6c5e27e2bb2630a6bcb18854172..6d2cc9d1813c862dfd23cb6897d4f4f4845af529 100644
|
||||
index dcfc726ab96dccc05848219e824ad7612dbfbdab..7713f26d4a97df94c27694d28881d298e4c54147 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -2008,6 +2008,15 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n
|
||||
@@ -1788,6 +1788,15 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, i
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ index ee50ea695585639d0ff184b675f3fb3b205b9f86..0bd800e1aeda87689a6c56ee6fadda38
|
|||
// Paper end
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||
index eb11abe4bc8f06d457da674848b39fc3b3873d1a..424f3a9a645d57ad43c52932f5b388b5f146b9f0 100644
|
||||
index 691b110e8a64081b68868456089908fe38fbc1cf..673b5192c32ee1b3c0d15462d3fadb0f31cd6a03 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||
@@ -421,6 +421,29 @@ public final class CraftMagicNumbers implements UnsafeValues {
|
|
@ -1,86 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Sun, 3 Jan 2021 17:58:11 -0800
|
||||
Subject: [PATCH] Add BlockBreakBlockEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/Block.java b/src/main/java/net/minecraft/world/level/block/Block.java
|
||||
index 1a5605b11170dfe1bd37165de886bad0f2e38ecd..8c30e28b97ac7e8b54322c903e0b75ee8135620b 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/Block.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/Block.java
|
||||
@@ -331,6 +331,23 @@ public class Block extends BlockBehaviour implements ItemLike {
|
||||
}
|
||||
|
||||
}
|
||||
+ // Paper start
|
||||
+ public static boolean dropResources(BlockState state, LevelAccessor world, BlockPos pos, @Nullable BlockEntity blockEntity, BlockPos source) {
|
||||
+ if (world instanceof ServerLevel) {
|
||||
+ List<org.bukkit.inventory.ItemStack> items = com.google.common.collect.Lists.newArrayList();
|
||||
+ for (net.minecraft.world.item.ItemStack drop : net.minecraft.world.level.block.Block.getDrops(state, world.getMinecraftWorld(), pos, blockEntity)) {
|
||||
+ items.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(drop));
|
||||
+ }
|
||||
+ io.papermc.paper.event.block.BlockBreakBlockEvent event = new io.papermc.paper.event.block.BlockBreakBlockEvent(org.bukkit.craftbukkit.block.CraftBlock.at(world, pos), org.bukkit.craftbukkit.block.CraftBlock.at(world, source), items);
|
||||
+ event.callEvent();
|
||||
+ for (var drop : event.getDrops()) {
|
||||
+ popResource(world.getMinecraftWorld(), pos, org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(drop));
|
||||
+ }
|
||||
+ state.spawnAfterBreak(world.getMinecraftWorld(), pos, ItemStack.EMPTY);
|
||||
+ }
|
||||
+ return true;
|
||||
+ }
|
||||
+ // Paper end
|
||||
|
||||
public static void dropResources(BlockState state, Level world, BlockPos pos, @Nullable BlockEntity blockEntity, Entity entity, ItemStack stack) {
|
||||
if (world instanceof ServerLevel) {
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java b/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java
|
||||
index 3678f75822b55c3c4c77565893269af4b7f9d8c9..d770649a9e9e9bb28b52d00cd082b87de5814593 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java
|
||||
@@ -410,7 +410,7 @@ public class PistonBaseBlock extends DirectionalBlock {
|
||||
iblockdata1 = world.getBlockState(blockposition3);
|
||||
BlockEntity tileentity = iblockdata1.hasBlockEntity() ? world.getBlockEntity(blockposition3) : null;
|
||||
|
||||
- dropResources(iblockdata1, (LevelAccessor) world, blockposition3, tileentity);
|
||||
+ dropResources(iblockdata1, (LevelAccessor) world, blockposition3, tileentity, pos); // Paper
|
||||
world.setBlock(blockposition3, Blocks.AIR.defaultBlockState(), 18);
|
||||
if (!iblockdata1.is((Tag) BlockTags.FIRE)) {
|
||||
world.addDestroyBlockEffect(blockposition3, iblockdata1);
|
||||
diff --git a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
|
||||
index 6e3e873efa1f50f53cb6503bde8a981f9cefd006..7fda7da544b2d0bbd3803d88ee34c92350a8b8ef 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
|
||||
@@ -295,7 +295,7 @@ public abstract class FlowingFluid extends Fluid {
|
||||
((LiquidBlockContainer) state.getBlock()).placeLiquid(world, pos, state, fluidState);
|
||||
} else {
|
||||
if (!state.isAir()) {
|
||||
- this.beforeDestroyingBlock(world, pos, state);
|
||||
+ this.beforeDestroyingBlock(world, pos, state, pos.relative(direction.getOpposite())); // Paper
|
||||
}
|
||||
|
||||
world.setBlock(pos, fluidState.createLegacyBlock(), 3);
|
||||
@@ -303,6 +303,7 @@ public abstract class FlowingFluid extends Fluid {
|
||||
|
||||
}
|
||||
|
||||
+ protected void beforeDestroyingBlock(LevelAccessor world, BlockPos pos, BlockState state, BlockPos source) { beforeDestroyingBlock(world, pos, state); } // Paper - add source parameter
|
||||
protected abstract void beforeDestroyingBlock(LevelAccessor world, BlockPos pos, BlockState state);
|
||||
|
||||
private static short getCacheKey(BlockPos blockposition, BlockPos blockposition1) {
|
||||
diff --git a/src/main/java/net/minecraft/world/level/material/WaterFluid.java b/src/main/java/net/minecraft/world/level/material/WaterFluid.java
|
||||
index c2beaba9095c9163f25a46c8b2c423e820639cf6..56d50b9310d30e0f81f3d2549ff5c256eb07cc2a 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/material/WaterFluid.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/material/WaterFluid.java
|
||||
@@ -63,6 +63,13 @@ public abstract class WaterFluid extends FlowingFluid {
|
||||
return true;
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ protected void beforeDestroyingBlock(LevelAccessor world, BlockPos pos, BlockState state, BlockPos source) {
|
||||
+ BlockEntity tileentity = state.hasBlockEntity() ? world.getBlockEntity(pos) : null;
|
||||
+ Block.dropResources(state, world, pos, tileentity, source);
|
||||
+ }
|
||||
+ // Paper end
|
||||
@Override
|
||||
protected void beforeDestroyingBlock(LevelAccessor world, BlockPos pos, BlockState state) {
|
||||
BlockEntity blockEntity = state.hasBlockEntity() ? world.getBlockEntity(pos) : null;
|
|
@ -1,84 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Sun, 26 Sep 2021 12:57:28 -0700
|
||||
Subject: [PATCH] Option to prevent NBT copy in smithing recipes
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/item/crafting/UpgradeRecipe.java b/src/main/java/net/minecraft/world/item/crafting/UpgradeRecipe.java
|
||||
index 21e9ce106cb7c1cdeabbad38a83d2439570e452b..88d99451748bfbd2cd24b1f29971a275dc6df597 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/crafting/UpgradeRecipe.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/crafting/UpgradeRecipe.java
|
||||
@@ -26,8 +26,15 @@ public class UpgradeRecipe implements net.minecraft.world.item.crafting.Recipe<C
|
||||
final Ingredient addition;
|
||||
final ItemStack result;
|
||||
private final ResourceLocation id;
|
||||
+ final boolean copyNbt; // Paper
|
||||
|
||||
public UpgradeRecipe(ResourceLocation id, Ingredient base, Ingredient addition, ItemStack result) {
|
||||
+ // Paper start
|
||||
+ this(id, base, addition, result, true);
|
||||
+ }
|
||||
+ public UpgradeRecipe(ResourceLocation id, Ingredient base, Ingredient addition, ItemStack result, boolean copyNbt) {
|
||||
+ this.copyNbt = copyNbt;
|
||||
+ // Paper end
|
||||
this.id = id;
|
||||
this.base = base;
|
||||
this.addition = addition;
|
||||
@@ -42,11 +49,13 @@ public class UpgradeRecipe implements net.minecraft.world.item.crafting.Recipe<C
|
||||
@Override
|
||||
public ItemStack assemble(Container inventory) {
|
||||
ItemStack itemstack = this.result.copy();
|
||||
+ if (copyNbt) { // Paper - copy nbt conditionally
|
||||
CompoundTag nbttagcompound = inventory.getItem(0).getTag();
|
||||
|
||||
if (nbttagcompound != null) {
|
||||
itemstack.setTag(nbttagcompound.copy());
|
||||
}
|
||||
+ } // Paper
|
||||
|
||||
return itemstack;
|
||||
}
|
||||
@@ -97,7 +106,7 @@ public class UpgradeRecipe implements net.minecraft.world.item.crafting.Recipe<C
|
||||
public Recipe toBukkitRecipe() {
|
||||
CraftItemStack result = CraftItemStack.asCraftMirror(this.result);
|
||||
|
||||
- CraftSmithingRecipe recipe = new CraftSmithingRecipe(CraftNamespacedKey.fromMinecraft(this.id), result, CraftRecipe.toBukkit(this.base), CraftRecipe.toBukkit(this.addition));
|
||||
+ CraftSmithingRecipe recipe = new CraftSmithingRecipe(CraftNamespacedKey.fromMinecraft(this.id), result, CraftRecipe.toBukkit(this.base), CraftRecipe.toBukkit(this.addition), this.copyNbt); // Paper
|
||||
|
||||
return recipe;
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingRecipe.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingRecipe.java
|
||||
index 0353ba44015cb72efa3892c527568902c9fa626b..bfd6b859fcfed89d0ebaca5200b7ca6f5d353d04 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingRecipe.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftSmithingRecipe.java
|
||||
@@ -8,15 +8,21 @@ import org.bukkit.inventory.RecipeChoice;
|
||||
import org.bukkit.inventory.SmithingRecipe;
|
||||
|
||||
public class CraftSmithingRecipe extends SmithingRecipe implements CraftRecipe {
|
||||
+ @Deprecated // Paper
|
||||
public CraftSmithingRecipe(NamespacedKey key, ItemStack result, RecipeChoice base, RecipeChoice addition) {
|
||||
super(key, result, base, addition);
|
||||
}
|
||||
+ // Paper start
|
||||
+ public CraftSmithingRecipe(NamespacedKey key, ItemStack result, RecipeChoice base, RecipeChoice addition, boolean copyNbt) {
|
||||
+ super(key, result, base, addition, copyNbt);
|
||||
+ }
|
||||
+ // Paper end
|
||||
|
||||
public static CraftSmithingRecipe fromBukkitRecipe(SmithingRecipe recipe) {
|
||||
if (recipe instanceof CraftSmithingRecipe) {
|
||||
return (CraftSmithingRecipe) recipe;
|
||||
}
|
||||
- CraftSmithingRecipe ret = new CraftSmithingRecipe(recipe.getKey(), recipe.getResult(), recipe.getBase(), recipe.getAddition());
|
||||
+ CraftSmithingRecipe ret = new CraftSmithingRecipe(recipe.getKey(), recipe.getResult(), recipe.getBase(), recipe.getAddition(), recipe.willCopyNbt()); // Paper
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -24,6 +30,6 @@ public class CraftSmithingRecipe extends SmithingRecipe implements CraftRecipe {
|
||||
public void addToCraftingManager() {
|
||||
ItemStack result = this.getResult();
|
||||
|
||||
- MinecraftServer.getServer().getRecipeManager().addRecipe(new net.minecraft.world.item.crafting.UpgradeRecipe(CraftNamespacedKey.toMinecraft(this.getKey()), toNMS(this.getBase(), true), toNMS(this.getAddition(), true), CraftItemStack.asNMSCopy(result)));
|
||||
+ MinecraftServer.getServer().getRecipeManager().addRecipe(new net.minecraft.world.item.crafting.UpgradeRecipe(CraftNamespacedKey.toMinecraft(this.getKey()), toNMS(this.getBase(), true), toNMS(this.getAddition(), true), CraftItemStack.asNMSCopy(result), this.willCopyNbt())); // Paper
|
||||
}
|
||||
}
|
|
@ -1,100 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Thu, 23 Sep 2021 10:40:09 -0700
|
||||
Subject: [PATCH] More CommmandBlock API
|
||||
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/commands/PaperCommandBlockHolder.java b/src/main/java/io/papermc/paper/commands/PaperCommandBlockHolder.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..0b42306f17bf8850a13a51067c2d19e7583187e5
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/commands/PaperCommandBlockHolder.java
|
||||
@@ -0,0 +1,33 @@
|
||||
+package io.papermc.paper.commands;
|
||||
+
|
||||
+import io.papermc.paper.adventure.PaperAdventure;
|
||||
+import io.papermc.paper.command.CommandBlockHolder;
|
||||
+import net.kyori.adventure.text.Component;
|
||||
+import net.minecraft.world.level.BaseCommandBlock;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import org.jetbrains.annotations.Nullable;
|
||||
+
|
||||
+public interface PaperCommandBlockHolder extends CommandBlockHolder {
|
||||
+
|
||||
+ BaseCommandBlock getCommandBlockHandle();
|
||||
+
|
||||
+ @Override
|
||||
+ default @NotNull Component lastOutput() {
|
||||
+ return PaperAdventure.asAdventure(getCommandBlockHandle().getLastOutput());
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ default void lastOutput(@Nullable Component lastOutput) {
|
||||
+ getCommandBlockHandle().setLastOutput(PaperAdventure.asVanilla(lastOutput));
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ default int getSuccessCount() {
|
||||
+ return getCommandBlockHandle().getSuccessCount();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ default void setSuccessCount(int successCount) {
|
||||
+ getCommandBlockHandle().setSuccessCount(successCount);
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftCommandBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftCommandBlock.java
|
||||
index 5df1e8c7277759bda57253db449907eb1185cce3..f36aa9d37facc5f1e2c6ae95f27c7020b5d0002b 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftCommandBlock.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftCommandBlock.java
|
||||
@@ -5,7 +5,7 @@ import org.bukkit.World;
|
||||
import org.bukkit.block.CommandBlock;
|
||||
import org.bukkit.craftbukkit.util.CraftChatMessage;
|
||||
|
||||
-public class CraftCommandBlock extends CraftBlockEntityState<CommandBlockEntity> implements CommandBlock {
|
||||
+public class CraftCommandBlock extends CraftBlockEntityState<CommandBlockEntity> implements CommandBlock, io.papermc.paper.commands.PaperCommandBlockHolder {
|
||||
|
||||
public CraftCommandBlock(World world, CommandBlockEntity tileEntity) {
|
||||
super(world, tileEntity);
|
||||
@@ -41,5 +41,10 @@ public class CraftCommandBlock extends CraftBlockEntityState<CommandBlockEntity>
|
||||
public void name(net.kyori.adventure.text.Component name) {
|
||||
getSnapshot().getCommandBlock().setName(name == null ? new net.minecraft.network.chat.TextComponent("@") : io.papermc.paper.adventure.PaperAdventure.asVanilla(name));
|
||||
}
|
||||
+
|
||||
+ @Override
|
||||
+ public net.minecraft.world.level.BaseCommandBlock getCommandBlockHandle() {
|
||||
+ return getSnapshot().getCommandBlock();
|
||||
+ }
|
||||
// Paper end
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartCommand.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartCommand.java
|
||||
index f9863e138994f6c7a7975a852f106faa96d52315..b709a1d909c189f60d0c3aa97b4b96623e7c1db0 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartCommand.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartCommand.java
|
||||
@@ -14,7 +14,7 @@ import org.bukkit.permissions.PermissionAttachment;
|
||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
-public class CraftMinecartCommand extends CraftMinecart implements CommandMinecart {
|
||||
+public class CraftMinecartCommand extends CraftMinecart implements CommandMinecart, io.papermc.paper.commands.PaperCommandBlockHolder {
|
||||
private final PermissibleBase perm = new PermissibleBase(this);
|
||||
|
||||
public CraftMinecartCommand(CraftServer server, MinecartCommandBlock entity) {
|
||||
@@ -70,6 +70,17 @@ public class CraftMinecartCommand extends CraftMinecart implements CommandMineca
|
||||
public net.kyori.adventure.text.@org.jetbrains.annotations.NotNull Component name() {
|
||||
return io.papermc.paper.adventure.PaperAdventure.asAdventure(this.getHandle().getCommandBlock().getName());
|
||||
}
|
||||
+
|
||||
+ @Override
|
||||
+ public net.minecraft.world.level.BaseCommandBlock getCommandBlockHandle() {
|
||||
+ return getHandle().getCommandBlock();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void lastOutput(net.kyori.adventure.text.Component lastOutput) {
|
||||
+ io.papermc.paper.commands.PaperCommandBlockHolder.super.lastOutput(lastOutput);
|
||||
+ getCommandBlockHandle().onUpdated();
|
||||
+ }
|
||||
// Paper end
|
||||
|
||||
@Override
|
|
@ -1,65 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Fri, 1 Oct 2021 08:04:39 -0700
|
||||
Subject: [PATCH] Add missing team sidebar display slots
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardTranslations.java b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardTranslations.java
|
||||
index f1be7a4f96a556569e4a607959bfd085fa0cb64c..ca58cde37f4e5abeb33e2f583b3d53e80697eba9 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardTranslations.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardTranslations.java
|
||||
@@ -7,7 +7,8 @@ import org.bukkit.scoreboard.DisplaySlot;
|
||||
import org.bukkit.scoreboard.RenderType;
|
||||
|
||||
public final class CraftScoreboardTranslations {
|
||||
- static final int MAX_DISPLAY_SLOT = 3;
|
||||
+ static final int MAX_DISPLAY_SLOT = Scoreboard.getDisplaySlotNames().length; // Paper
|
||||
+ @Deprecated // Paper
|
||||
static ImmutableBiMap<DisplaySlot, String> SLOTS = ImmutableBiMap.of(
|
||||
DisplaySlot.BELOW_NAME, "belowName",
|
||||
DisplaySlot.PLAYER_LIST, "list",
|
||||
@@ -16,10 +17,12 @@ public final class CraftScoreboardTranslations {
|
||||
private CraftScoreboardTranslations() {}
|
||||
|
||||
public static DisplaySlot toBukkitSlot(int i) {
|
||||
+ if (true) return org.bukkit.scoreboard.DisplaySlot.NAMES.value(Scoreboard.getDisplaySlotName(i)); // Paper
|
||||
return CraftScoreboardTranslations.SLOTS.inverse().get(Scoreboard.getDisplaySlotName(i));
|
||||
}
|
||||
|
||||
public static int fromBukkitSlot(DisplaySlot slot) {
|
||||
+ if (true) return Scoreboard.getDisplaySlotByName(slot.getId()); // Paper
|
||||
return Scoreboard.getDisplaySlotByName(CraftScoreboardTranslations.SLOTS.get(slot));
|
||||
}
|
||||
|
||||
diff --git a/src/test/java/io/papermc/paper/scoreboard/DisplaySlotTest.java b/src/test/java/io/papermc/paper/scoreboard/DisplaySlotTest.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..bb41a2f2c0a5e3b4cb3fe1b584e0ceb7a7116afb
|
||||
--- /dev/null
|
||||
+++ b/src/test/java/io/papermc/paper/scoreboard/DisplaySlotTest.java
|
||||
@@ -0,0 +1,26 @@
|
||||
+package io.papermc.paper.scoreboard;
|
||||
+
|
||||
+import net.minecraft.world.scores.Scoreboard;
|
||||
+import org.bukkit.craftbukkit.scoreboard.CraftScoreboardTranslations;
|
||||
+import org.bukkit.scoreboard.DisplaySlot;
|
||||
+import org.junit.Test;
|
||||
+
|
||||
+import static org.junit.Assert.assertNotEquals;
|
||||
+import static org.junit.Assert.assertNotNull;
|
||||
+
|
||||
+public class DisplaySlotTest {
|
||||
+
|
||||
+ @Test
|
||||
+ public void testBukkitToMinecraftDisplaySlots() {
|
||||
+ for (DisplaySlot value : DisplaySlot.values()) {
|
||||
+ assertNotEquals(-1, CraftScoreboardTranslations.fromBukkitSlot(value));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @Test
|
||||
+ public void testMinecraftToBukkitDisplaySlots() {
|
||||
+ for (String name : Scoreboard.getDisplaySlotNames()) {
|
||||
+ assertNotNull(CraftScoreboardTranslations.toBukkitSlot(Scoreboard.getDisplaySlotByName(name)));
|
||||
+ }
|
||||
+ }
|
||||
+}
|
|
@ -1,47 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Sun, 16 May 2021 09:39:46 -0700
|
||||
Subject: [PATCH] Add back EntityPortalExitEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index 4f164f238177b5e2b18c76b7cc14596ec93409d1..e17bda0d13bae337cfad5ae31b118aa7a85499fc 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -3181,6 +3181,25 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n
|
||||
} else {
|
||||
// CraftBukkit start
|
||||
worldserver = shapedetectorshape.world;
|
||||
+
|
||||
+ // Paper start - Call EntityPortalExitEvent
|
||||
+ CraftEntity bukkitEntity = this.getBukkitEntity();
|
||||
+ Vec3 position = shapedetectorshape.pos;
|
||||
+ float yaw = shapedetectorshape.yRot;
|
||||
+ float pitch = bukkitEntity.getLocation().getPitch(); // Keep entity pitch as per moveTo line below
|
||||
+ Vec3 velocity = shapedetectorshape.speed;
|
||||
+ org.bukkit.event.entity.EntityPortalExitEvent event = new org.bukkit.event.entity.EntityPortalExitEvent(bukkitEntity,
|
||||
+ bukkitEntity.getLocation(), new Location(worldserver.getWorld(), position.x, position.y, position.z, yaw, pitch),
|
||||
+ bukkitEntity.getVelocity(), org.bukkit.craftbukkit.util.CraftVector.toBukkit(shapedetectorshape.speed));
|
||||
+ if (event.callEvent() && event.getTo() != null && this.isAlive()) {
|
||||
+ worldserver = ((CraftWorld) event.getTo().getWorld()).getHandle();
|
||||
+ position = new Vec3(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ());
|
||||
+ yaw = event.getTo().getYaw();
|
||||
+ pitch = event.getTo().getPitch();
|
||||
+ velocity = org.bukkit.craftbukkit.util.CraftVector.toNMS(event.getAfter());
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
this.unRide();
|
||||
// CraftBukkit end
|
||||
|
||||
@@ -3194,8 +3213,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n
|
||||
|
||||
if (entity != null) {
|
||||
entity.restoreFrom(this);
|
||||
- entity.moveTo(shapedetectorshape.pos.x, shapedetectorshape.pos.y, shapedetectorshape.pos.z, shapedetectorshape.yRot, entity.getXRot());
|
||||
- entity.setDeltaMovement(shapedetectorshape.speed);
|
||||
+ entity.moveTo(position.x, position.y, position.z, yaw, pitch); // Paper - use EntityPortalExitEvent values
|
||||
+ entity.setDeltaMovement(velocity); // Paper - use EntityPortalExitEvent values
|
||||
worldserver.addDuringTeleport(entity);
|
||||
if (worldserver.getTypeKey() == DimensionType.END_LOCATION) { // CraftBukkit
|
||||
ServerLevel.makeObsidianPlatform(worldserver, this); // CraftBukkit
|
|
@ -1,58 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jakub Zacek <dawon@dawon.eu>
|
||||
Date: Mon, 4 Oct 2021 10:16:44 +0200
|
||||
Subject: [PATCH] Add methods to find targets for lightning strikes
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index 08c6ea9f19fa9218af089ed3bd2dcda1e83591ed..710a1064cec9c7ec93e1258b0786e74ab9af0c12 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -956,6 +956,11 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
}
|
||||
|
||||
protected BlockPos findLightningTargetAround(BlockPos pos) {
|
||||
+ // Paper start
|
||||
+ return this.findLightningTargetAround(pos, false);
|
||||
+ }
|
||||
+ public BlockPos findLightningTargetAround(BlockPos pos, boolean returnNullWhenNoTarget) {
|
||||
+ // Paper end
|
||||
BlockPos blockposition1 = this.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, pos);
|
||||
Optional<BlockPos> optional = this.findLightningRod(blockposition1);
|
||||
|
||||
@@ -970,6 +975,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
if (!list.isEmpty()) {
|
||||
return ((LivingEntity) list.get(this.random.nextInt(list.size()))).blockPosition();
|
||||
} else {
|
||||
+ if (returnNullWhenNoTarget) return null; // Paper
|
||||
if (blockposition1.getY() == this.getMinBuildHeight() - 1) {
|
||||
blockposition1 = blockposition1.above(2);
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
index e5e23c907d49ee64218f3302e2a2323d6937a8a1..858e29ad77aee8a1b7797c2d82902abbfd662da2 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
|
||||
@@ -701,6 +701,23 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||
return (LightningStrike) lightning.getBukkitEntity();
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ public Location findLightningRod(Location location) {
|
||||
+ return this.world.findLightningRod(net.minecraft.server.MCUtil.toBlockPosition(location))
|
||||
+ .map(blockPos -> net.minecraft.server.MCUtil.toLocation(this.world, blockPos)
|
||||
+ // get the actual rod pos
|
||||
+ .subtract(0, 1, 0))
|
||||
+ .orElse(null);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public Location findLightningTarget(Location location) {
|
||||
+ final BlockPos pos = this.world.findLightningTargetAround(net.minecraft.server.MCUtil.toBlockPosition(location), true);
|
||||
+ return pos == null ? null : net.minecraft.server.MCUtil.toLocation(this.world, pos);
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
@Override
|
||||
public boolean generateTree(Location loc, TreeType type) {
|
||||
return generateTree(loc, CraftWorld.rand, type);
|
|
@ -1,159 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Fri, 20 Aug 2021 13:03:21 -0700
|
||||
Subject: [PATCH] Get entity default attributes
|
||||
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/attribute/UnmodifiableAttributeInstance.java b/src/main/java/io/papermc/paper/attribute/UnmodifiableAttributeInstance.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..12135ffeacd648f6bc4d7d327059ea1a7e8c79c4
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/attribute/UnmodifiableAttributeInstance.java
|
||||
@@ -0,0 +1,30 @@
|
||||
+package io.papermc.paper.attribute;
|
||||
+
|
||||
+import net.minecraft.world.entity.ai.attributes.AttributeInstance;
|
||||
+import org.bukkit.attribute.Attribute;
|
||||
+import org.bukkit.attribute.AttributeModifier;
|
||||
+import org.bukkit.craftbukkit.attribute.CraftAttributeInstance;
|
||||
+
|
||||
+import java.util.Collection;
|
||||
+
|
||||
+public class UnmodifiableAttributeInstance extends CraftAttributeInstance {
|
||||
+
|
||||
+ public UnmodifiableAttributeInstance(AttributeInstance handle, Attribute attribute) {
|
||||
+ super(handle, attribute);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setBaseValue(double d) {
|
||||
+ throw new UnsupportedOperationException("Cannot modify default attributes");
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void addModifier(AttributeModifier modifier) {
|
||||
+ throw new UnsupportedOperationException("Cannot modify default attributes");
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void removeModifier(AttributeModifier modifier) {
|
||||
+ throw new UnsupportedOperationException("Cannot modify default attributes");
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/attribute/UnmodifiableAttributeMap.java b/src/main/java/io/papermc/paper/attribute/UnmodifiableAttributeMap.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..4ecba0b02c2813a890aecc558698787946d2ccb8
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/attribute/UnmodifiableAttributeMap.java
|
||||
@@ -0,0 +1,43 @@
|
||||
+package io.papermc.paper.attribute;
|
||||
+
|
||||
+import com.google.common.collect.Maps;
|
||||
+import com.google.common.util.concurrent.Callables;
|
||||
+import com.google.common.util.concurrent.Runnables;
|
||||
+import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
|
||||
+import org.bukkit.attribute.Attributable;
|
||||
+import org.bukkit.attribute.Attribute;
|
||||
+import org.bukkit.attribute.AttributeInstance;
|
||||
+import org.bukkit.craftbukkit.attribute.CraftAttributeInstance;
|
||||
+import org.bukkit.craftbukkit.attribute.CraftAttributeMap;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import org.jetbrains.annotations.Nullable;
|
||||
+
|
||||
+import java.util.Map;
|
||||
+import java.util.function.Consumer;
|
||||
+import java.util.function.Function;
|
||||
+
|
||||
+public class UnmodifiableAttributeMap implements Attributable {
|
||||
+
|
||||
+
|
||||
+ private final Map<Attribute, AttributeInstance> attributes = Maps.newHashMap();
|
||||
+ private final AttributeSupplier handle;
|
||||
+
|
||||
+ public UnmodifiableAttributeMap(@NotNull AttributeSupplier handle) {
|
||||
+ this.handle = handle;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public @Nullable AttributeInstance getAttribute(@NotNull Attribute attribute) {
|
||||
+ var nmsAttribute = CraftAttributeMap.toMinecraft(attribute);
|
||||
+ var nmsAttributeInstance = this.handle.instances.get(nmsAttribute);
|
||||
+ if (nmsAttribute == null) {
|
||||
+ return null;
|
||||
+ }
|
||||
+ return new UnmodifiableAttributeInstance(nmsAttributeInstance, attribute);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void registerAttribute(@NotNull Attribute attribute) {
|
||||
+ throw new UnsupportedOperationException("Cannot register new attributes here");
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||
index ff1f178b69efc4f167cb34095b7fd3acd4d00680..26273a6b9d49f0e12fe1ff3206c7f017a2f36e44 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||
@@ -516,6 +516,18 @@ public final class CraftMagicNumbers implements UnsafeValues {
|
||||
public int getProtocolVersion() {
|
||||
return net.minecraft.SharedConstants.getCurrentVersion().getProtocolVersion();
|
||||
}
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean hasDefaultEntityAttributes(NamespacedKey bukkitEntityKey) {
|
||||
+ return net.minecraft.world.entity.ai.attributes.DefaultAttributes.hasSupplier(net.minecraft.core.Registry.ENTITY_TYPE.get(CraftNamespacedKey.toMinecraft(bukkitEntityKey)));
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public org.bukkit.attribute.Attributable getDefaultEntityAttributes(NamespacedKey bukkitEntityKey) {
|
||||
+ Preconditions.checkArgument(hasDefaultEntityAttributes(bukkitEntityKey), bukkitEntityKey + " doesn't have default attributes");
|
||||
+ var supplier = net.minecraft.world.entity.ai.attributes.DefaultAttributes.getSupplier((net.minecraft.world.entity.EntityType<? extends net.minecraft.world.entity.LivingEntity>) net.minecraft.core.Registry.ENTITY_TYPE.get(CraftNamespacedKey.toMinecraft(bukkitEntityKey)));
|
||||
+ return new io.papermc.paper.attribute.UnmodifiableAttributeMap(supplier);
|
||||
+ }
|
||||
// Paper end
|
||||
|
||||
/**
|
||||
diff --git a/src/test/java/io/papermc/paper/attribute/EntityTypeAttributesTest.java b/src/test/java/io/papermc/paper/attribute/EntityTypeAttributesTest.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..7b999deba66aa6d22cd7520f6c13550a44ca327d
|
||||
--- /dev/null
|
||||
+++ b/src/test/java/io/papermc/paper/attribute/EntityTypeAttributesTest.java
|
||||
@@ -0,0 +1,39 @@
|
||||
+package io.papermc.paper.attribute;
|
||||
+
|
||||
+import org.bukkit.attribute.Attributable;
|
||||
+import org.bukkit.attribute.Attribute;
|
||||
+import org.bukkit.attribute.AttributeInstance;
|
||||
+import org.bukkit.attribute.AttributeModifier;
|
||||
+import org.bukkit.entity.EntityType;
|
||||
+import org.bukkit.support.AbstractTestingBase;
|
||||
+import org.junit.Test;
|
||||
+
|
||||
+import static org.junit.Assert.assertFalse;
|
||||
+import static org.junit.Assert.assertNotNull;
|
||||
+import static org.junit.Assert.assertThrows;
|
||||
+import static org.junit.Assert.assertTrue;
|
||||
+
|
||||
+public class EntityTypeAttributesTest extends AbstractTestingBase {
|
||||
+
|
||||
+ @Test
|
||||
+ public void testIllegalEntity() {
|
||||
+ assertFalse(EntityType.EGG.hasDefaultAttributes());
|
||||
+ assertThrows(IllegalArgumentException.class, () -> EntityType.EGG.getDefaultAttributes());
|
||||
+ }
|
||||
+
|
||||
+ @Test
|
||||
+ public void testLegalEntity() {
|
||||
+ assertTrue(EntityType.ZOMBIE.hasDefaultAttributes());
|
||||
+ EntityType.ZOMBIE.getDefaultAttributes();
|
||||
+ }
|
||||
+
|
||||
+ @Test
|
||||
+ public void testUnmodifiabilityOfAttributable() {
|
||||
+ Attributable attributable = EntityType.ZOMBIE.getDefaultAttributes();
|
||||
+ assertThrows(UnsupportedOperationException.class, () -> attributable.registerAttribute(Attribute.GENERIC_ATTACK_DAMAGE));
|
||||
+ AttributeInstance instance = attributable.getAttribute(Attribute.GENERIC_FOLLOW_RANGE);
|
||||
+ assertNotNull(instance);
|
||||
+ assertThrows(UnsupportedOperationException.class, () -> instance.addModifier(new AttributeModifier("test", 3, AttributeModifier.Operation.ADD_NUMBER)));
|
||||
+ assertThrows(UnsupportedOperationException.class, () -> instance.setBaseValue(3.2));
|
||||
+ }
|
||||
+}
|
|
@ -1,26 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: William Blake Galbreath <blake.galbreath@gmail.com>
|
||||
Date: Thu, 14 Oct 2021 12:36:58 -0500
|
||||
Subject: [PATCH] Left handed API
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java
|
||||
index 2386edf499cb292241f6ba60c1cdb46f2fe704ff..5a43e420f14fa52d71d41ff3694a179e7a1a5be3 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java
|
||||
@@ -134,5 +134,15 @@ public abstract class CraftMob extends CraftLivingEntity implements Mob {
|
||||
public int getMaxHeadPitch() {
|
||||
return getHandle().getMaxHeadXRot();
|
||||
}
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isLeftHanded() {
|
||||
+ return getHandle().isLeftHanded();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setLeftHanded(boolean leftHanded) {
|
||||
+ getHandle().setLeftHanded(leftHanded);
|
||||
+ }
|
||||
// Paper end
|
||||
}
|
|
@ -1,155 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: syldium <syldium@mailo.com>
|
||||
Date: Fri, 9 Jul 2021 18:50:40 +0200
|
||||
Subject: [PATCH] Add advancement display API
|
||||
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/advancement/PaperAdvancementDisplay.java b/src/main/java/io/papermc/paper/advancement/PaperAdvancementDisplay.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..0567e500c40d3d424ddc19062c4f6da902e8586e
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/advancement/PaperAdvancementDisplay.java
|
||||
@@ -0,0 +1,63 @@
|
||||
+package io.papermc.paper.advancement;
|
||||
+
|
||||
+import io.papermc.paper.adventure.PaperAdventure;
|
||||
+import net.kyori.adventure.text.Component;
|
||||
+import net.minecraft.advancements.DisplayInfo;
|
||||
+import net.minecraft.advancements.FrameType;
|
||||
+import org.bukkit.NamespacedKey;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
+import org.bukkit.craftbukkit.util.CraftNamespacedKey;
|
||||
+import org.bukkit.inventory.ItemStack;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import org.jetbrains.annotations.Nullable;
|
||||
+
|
||||
+public record PaperAdvancementDisplay(DisplayInfo handle) implements AdvancementDisplay {
|
||||
+
|
||||
+ @Override
|
||||
+ public @NotNull Frame frame() {
|
||||
+ return asPaperFrame(this.handle.getFrame());
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public @NotNull Component title() {
|
||||
+ return PaperAdventure.asAdventure(this.handle.getTitle());
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public @NotNull Component description() {
|
||||
+ return PaperAdventure.asAdventure(this.handle.getDescription());
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public @NotNull ItemStack icon() {
|
||||
+ return CraftItemStack.asBukkitCopy(this.handle.getIcon());
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean doesShowToast() {
|
||||
+ return this.handle.shouldShowToast();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean doesAnnounceToChat() {
|
||||
+ return this.handle.shouldAnnounceChat();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isHidden() {
|
||||
+ return this.handle.isHidden();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public @Nullable NamespacedKey backgroundPath() {
|
||||
+ return this.handle.getBackground() == null ? null : CraftNamespacedKey.fromMinecraft(this.handle.getBackground());
|
||||
+ }
|
||||
+
|
||||
+ public static @NotNull Frame asPaperFrame(@NotNull FrameType frameType) {
|
||||
+ return switch (frameType) {
|
||||
+ case TASK -> Frame.TASK;
|
||||
+ case CHALLENGE -> Frame.CHALLENGE;
|
||||
+ case GOAL -> Frame.GOAL;
|
||||
+ };
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/advancements/DisplayInfo.java b/src/main/java/net/minecraft/advancements/DisplayInfo.java
|
||||
index dea17bc7a6e4db470afaaad3c98940297a50e4e4..0b78ccceb55a1c0fa1f27f9ff1e303396c8f447d 100644
|
||||
--- a/src/main/java/net/minecraft/advancements/DisplayInfo.java
|
||||
+++ b/src/main/java/net/minecraft/advancements/DisplayInfo.java
|
||||
@@ -27,6 +27,7 @@ public class DisplayInfo {
|
||||
private final boolean hidden;
|
||||
private float x;
|
||||
private float y;
|
||||
+ public final io.papermc.paper.advancement.AdvancementDisplay paper = new io.papermc.paper.advancement.PaperAdvancementDisplay(this); // Paper
|
||||
|
||||
public DisplayInfo(ItemStack icon, Component title, Component description, @Nullable ResourceLocation background, FrameType frame, boolean showToast, boolean announceToChat, boolean hidden) {
|
||||
this.title = title;
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/advancement/CraftAdvancement.java b/src/main/java/org/bukkit/craftbukkit/advancement/CraftAdvancement.java
|
||||
index 20d51358b4b47cbf43c3d172765243e96aa1966c..fd42cf61699337acde751249131c016555fd1ea5 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/advancement/CraftAdvancement.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/advancement/CraftAdvancement.java
|
||||
@@ -27,4 +27,33 @@ public class CraftAdvancement implements org.bukkit.advancement.Advancement {
|
||||
public Collection<String> getCriteria() {
|
||||
return Collections.unmodifiableCollection(this.handle.getCriteria().keySet());
|
||||
}
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ public io.papermc.paper.advancement.AdvancementDisplay getDisplay() {
|
||||
+ return this.handle.getDisplay() == null ? null : this.handle.getDisplay().paper;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public org.bukkit.advancement.Advancement getParent() {
|
||||
+ return this.handle.getParent() == null ? null : this.handle.getParent().bukkit;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public Collection<org.bukkit.advancement.Advancement> getChildren() {
|
||||
+ final var children = com.google.common.collect.ImmutableList.<org.bukkit.advancement.Advancement>builder();
|
||||
+ for (Advancement advancement : this.handle.getChildren()) {
|
||||
+ children.add(advancement.bukkit);
|
||||
+ }
|
||||
+ return children.build();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public org.bukkit.advancement.Advancement getRoot() {
|
||||
+ Advancement advancement = this.handle;
|
||||
+ while (advancement.getParent() != null) {
|
||||
+ advancement = advancement.getParent();
|
||||
+ }
|
||||
+ return advancement.bukkit;
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
||||
diff --git a/src/test/java/io/papermc/paper/advancement/AdvancementFrameTest.java b/src/test/java/io/papermc/paper/advancement/AdvancementFrameTest.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..520801e294a33ae62d9aa24dc0247591e379311d
|
||||
--- /dev/null
|
||||
+++ b/src/test/java/io/papermc/paper/advancement/AdvancementFrameTest.java
|
||||
@@ -0,0 +1,24 @@
|
||||
+package io.papermc.paper.advancement;
|
||||
+
|
||||
+import io.papermc.paper.adventure.PaperAdventure;
|
||||
+import net.kyori.adventure.text.format.TextColor;
|
||||
+import net.minecraft.advancements.FrameType;
|
||||
+import net.minecraft.network.chat.TranslatableComponent;
|
||||
+import org.junit.Test;
|
||||
+
|
||||
+import static org.junit.Assert.assertEquals;
|
||||
+
|
||||
+public class AdvancementFrameTest {
|
||||
+
|
||||
+ @Test
|
||||
+ public void test() {
|
||||
+ for (FrameType nmsFrameType : FrameType.values()) {
|
||||
+ final TextColor expectedColor = PaperAdventure.asAdventure(nmsFrameType.getChatColor());
|
||||
+ final String expectedTranslationKey = ((TranslatableComponent) nmsFrameType.getDisplayName()).getKey();
|
||||
+ final var frame = PaperAdvancementDisplay.asPaperFrame(nmsFrameType);
|
||||
+ assertEquals("The translation keys should be the same", expectedTranslationKey, frame.translationKey());
|
||||
+ assertEquals("The frame colors should be the same", expectedColor, frame.color());
|
||||
+ assertEquals(nmsFrameType.getName(), AdvancementDisplay.Frame.NAMES.key(frame));
|
||||
+ }
|
||||
+ }
|
||||
+}
|
|
@ -1,28 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: William Blake Galbreath <blake.galbreath@gmail.com>
|
||||
Date: Thu, 14 Oct 2021 12:09:39 -0500
|
||||
Subject: [PATCH] Add ItemFactory#getMonsterEgg API
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java
|
||||
index fcbd28fdeab4815c005c7dca547aee246f52fd26..1c0ecd8bb3156a8e1718e84455dd9af667adaf7a 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java
|
||||
@@ -410,5 +410,17 @@ public final class CraftItemFactory implements ItemFactory {
|
||||
entity.getUniqueId().toString(),
|
||||
new net.md_5.bungee.api.chat.TextComponent(customName));
|
||||
}
|
||||
+
|
||||
+ @Override
|
||||
+ public ItemStack getSpawnEgg(org.bukkit.entity.EntityType type) {
|
||||
+ if (type == null) {
|
||||
+ return null;
|
||||
+ }
|
||||
+ String typeId = type.getKey().toString();
|
||||
+ net.minecraft.resources.ResourceLocation typeKey = new net.minecraft.resources.ResourceLocation(typeId);
|
||||
+ net.minecraft.world.entity.EntityType<?> nmsType = net.minecraft.core.Registry.ENTITY_TYPE.get(typeKey);
|
||||
+ net.minecraft.world.item.SpawnEggItem eggItem = net.minecraft.world.item.SpawnEggItem.BY_ID.get(nmsType);
|
||||
+ return eggItem == null ? null : new net.minecraft.world.item.ItemStack(eggItem).asBukkitMirror();
|
||||
+ }
|
||||
// Paper end
|
||||
}
|
|
@ -1,168 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: dodison <kacpik@mapik.eu>
|
||||
Date: Mon, 26 Jul 2021 17:32:36 +0200
|
||||
Subject: [PATCH] Add critical damage API
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/damagesource/DamageSource.java b/src/main/java/net/minecraft/world/damagesource/DamageSource.java
|
||||
index 80d19af2ad423bd3de0e039c5bb8f97af536aaa9..a828cad27fcd39f8bfbaefa97052a2a3b6650ee7 100644
|
||||
--- a/src/main/java/net/minecraft/world/damagesource/DamageSource.java
|
||||
+++ b/src/main/java/net/minecraft/world/damagesource/DamageSource.java
|
||||
@@ -64,6 +64,19 @@ public class DamageSource {
|
||||
return this;
|
||||
}
|
||||
// CraftBukkit end
|
||||
+ // Paper start - add critical damage API
|
||||
+ private boolean critical;
|
||||
+ public boolean isCritical() {
|
||||
+ return this.critical;
|
||||
+ }
|
||||
+ public DamageSource critical() {
|
||||
+ return this.critical(true);
|
||||
+ }
|
||||
+ public DamageSource critical(boolean critical) {
|
||||
+ this.critical = critical;
|
||||
+ return this;
|
||||
+ }
|
||||
+ // Paper end
|
||||
|
||||
public static DamageSource sting(LivingEntity attacker) {
|
||||
return new EntityDamageSource("sting", attacker);
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
index 1018f4640bab5876c5e0afb5b88f71437fb79662..cbdff14b26f67b5040c13659f9d64d9ec4c7eaed 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -2571,15 +2571,27 @@ public abstract class LivingEntity extends Entity {
|
||||
return this.hasEffect(MobEffects.JUMP) ? (double) (0.1F * (float) (this.getEffect(MobEffects.JUMP).getAmplifier() + 1)) : 0.0D;
|
||||
}
|
||||
|
||||
+ protected long lastJumpTime = 0L; // Paper - add critical damage API
|
||||
protected void jumpFromGround() {
|
||||
double d0 = (double) this.getJumpPower() + this.getJumpBoostPower();
|
||||
Vec3 vec3d = this.getDeltaMovement();
|
||||
+ // Paper start - add critical damage API
|
||||
+ long time = System.nanoTime();
|
||||
+ boolean canCrit = true;
|
||||
+ if (this instanceof net.minecraft.world.entity.player.Player) {
|
||||
+ canCrit = false;
|
||||
+ if (time - this.lastJumpTime > (long)(0.250e9)) {
|
||||
+ this.lastJumpTime = time;
|
||||
+ canCrit = true;
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper end - add critical damage API
|
||||
|
||||
this.setDeltaMovement(vec3d.x, d0, vec3d.z);
|
||||
if (this.isSprinting()) {
|
||||
float f = this.getYRot() * 0.017453292F;
|
||||
|
||||
- this.setDeltaMovement(this.getDeltaMovement().add((double) (-Mth.sin(f) * 0.2F), 0.0D, (double) (Mth.cos(f) * 0.2F)));
|
||||
+ if (canCrit) this.setDeltaMovement(this.getDeltaMovement().add((double) (-Mth.sin(f) * 0.2F), 0.0D, (double) (Mth.cos(f) * 0.2F))); // Paper - add critical damage API
|
||||
}
|
||||
|
||||
this.hasImpulse = true;
|
||||
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 ce713e1857121ca52467ad561c4fbb30ae054d87..94e76e295dbd0f3bac4b30a3e7338cd56a971207 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/player/Player.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java
|
||||
@@ -1218,7 +1218,7 @@ public abstract class Player extends LivingEntity {
|
||||
flag1 = true;
|
||||
}
|
||||
|
||||
- boolean flag2 = flag && this.fallDistance > 0.0F && !this.onGround && !this.onClimbable() && !this.isInWater() && !this.hasEffect(MobEffects.BLINDNESS) && !this.isPassenger() && target instanceof LivingEntity;
|
||||
+ boolean flag2 = flag && this.fallDistance > 0.0F && !this.onGround && !this.onClimbable() && !this.isInWater() && !this.hasEffect(MobEffects.BLINDNESS) && !this.isPassenger() && target instanceof LivingEntity; // Paper - Add critical damage API - conflict on change
|
||||
|
||||
flag2 = flag2 && !level.paperConfig.disablePlayerCrits; // Paper
|
||||
flag2 = flag2 && !this.isSprinting();
|
||||
@@ -1258,7 +1258,7 @@ public abstract class Player extends LivingEntity {
|
||||
}
|
||||
|
||||
Vec3 vec3d = target.getDeltaMovement();
|
||||
- boolean flag5 = target.hurt(DamageSource.playerAttack(this), f);
|
||||
+ boolean flag5 = target.hurt(DamageSource.playerAttack(this).critical(flag2), f); // Paper - add critical damage API
|
||||
|
||||
if (flag5) {
|
||||
if (i > 0) {
|
||||
@@ -1286,7 +1286,7 @@ public abstract class Player extends LivingEntity {
|
||||
|
||||
if (entityliving != this && entityliving != target && !this.isAlliedTo(entityliving) && (!(entityliving instanceof ArmorStand) || !((ArmorStand) entityliving).isMarker()) && this.distanceToSqr((Entity) entityliving) < 9.0D) {
|
||||
// CraftBukkit start - Only apply knockback if the damage hits
|
||||
- if (entityliving.hurt(DamageSource.playerAttack(this).sweep(), f4)) {
|
||||
+ if (entityliving.hurt(DamageSource.playerAttack(this).sweep().critical(flag2), f4)) { // Paper - add critical damage API
|
||||
entityliving.knockback(0.4000000059604645D, (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F)), this); // Paper
|
||||
}
|
||||
// CraftBukkit end
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
|
||||
index 6636845ea044c3810e1880aad8b679134cd33668..52e4948fd1657fa1776ac6b0142e8c21e7567976 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
|
||||
@@ -381,6 +381,7 @@ public abstract class AbstractArrow extends Projectile {
|
||||
}
|
||||
}
|
||||
|
||||
+ if (this.isCritArrow()) damagesource = damagesource.critical(); // Paper - add critical damage API
|
||||
boolean flag = entity.getType() == EntityType.ENDERMAN;
|
||||
int k = entity.getRemainingFireTicks();
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
||||
index 2b2654ec04e8abca9db09d6257edf11099bb0d9b..c0b46ff81994e037e734b75afadcce372c2ddd7f 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
||||
@@ -964,7 +964,7 @@ public class CraftEventFactory {
|
||||
} else {
|
||||
damageCause = DamageCause.ENTITY_EXPLOSION;
|
||||
}
|
||||
- event = new EntityDamageByEntityEvent(damager.getBukkitEntity(), entity.getBukkitEntity(), damageCause, modifiers, modifierFunctions);
|
||||
+ event = new EntityDamageByEntityEvent(damager.getBukkitEntity(), entity.getBukkitEntity(), damageCause, modifiers, modifierFunctions, source.isCritical()); // Paper - add critical damage API
|
||||
}
|
||||
event.setCancelled(cancelled);
|
||||
|
||||
@@ -989,7 +989,7 @@ public class CraftEventFactory {
|
||||
cause = DamageCause.THORNS;
|
||||
}
|
||||
|
||||
- return CraftEventFactory.callEntityDamageEvent(damager, entity, cause, modifiers, modifierFunctions, cancelled);
|
||||
+ return CraftEventFactory.callEntityDamageEvent(damager, entity, cause, modifiers, modifierFunctions, cancelled, source.isCritical()); // Paper - add critical damage API
|
||||
} else if (source == DamageSource.OUT_OF_WORLD) {
|
||||
EntityDamageEvent event = new EntityDamageByBlockEvent(null, entity.getBukkitEntity(), DamageCause.VOID, modifiers, modifierFunctions);
|
||||
event.setCancelled(cancelled);
|
||||
@@ -1044,7 +1044,7 @@ public class CraftEventFactory {
|
||||
} else {
|
||||
throw new IllegalStateException(String.format("Unhandled damage of %s by %s from %s", entity, damager.getHandle(), source.msgId));
|
||||
}
|
||||
- EntityDamageEvent event = new EntityDamageByEntityEvent(damager, entity.getBukkitEntity(), cause, modifiers, modifierFunctions);
|
||||
+ EntityDamageEvent event = new EntityDamageByEntityEvent(damager, entity.getBukkitEntity(), cause, modifiers, modifierFunctions, source.isCritical()); // Paper - add critical damage API
|
||||
event.setCancelled(cancelled);
|
||||
CraftEventFactory.callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
@@ -1087,20 +1087,28 @@ public class CraftEventFactory {
|
||||
}
|
||||
|
||||
if (cause != null) {
|
||||
- return CraftEventFactory.callEntityDamageEvent(null, entity, cause, modifiers, modifierFunctions, cancelled);
|
||||
+ return CraftEventFactory.callEntityDamageEvent(null, entity, cause, modifiers, modifierFunctions, cancelled, source.isCritical()); // Paper - add critical damage API
|
||||
}
|
||||
|
||||
throw new IllegalStateException(String.format("Unhandled damage of %s from %s", entity, source.msgId));
|
||||
}
|
||||
|
||||
+ @Deprecated // Paper - Add critical damage API
|
||||
private static EntityDamageEvent callEntityDamageEvent(Entity damager, Entity damagee, DamageCause cause, Map<DamageModifier, Double> modifiers, Map<DamageModifier, Function<? super Double, Double>> modifierFunctions) {
|
||||
return CraftEventFactory.callEntityDamageEvent(damager, damagee, cause, modifiers, modifierFunctions, false);
|
||||
}
|
||||
|
||||
+ // Paper start - Add critical damage API
|
||||
+ @Deprecated
|
||||
private static EntityDamageEvent callEntityDamageEvent(Entity damager, Entity damagee, DamageCause cause, Map<DamageModifier, Double> modifiers, Map<DamageModifier, Function<? super Double, Double>> modifierFunctions, boolean cancelled) {
|
||||
+ return CraftEventFactory.callEntityDamageEvent(damager, damagee, cause, modifiers, modifierFunctions, false, false);
|
||||
+ }
|
||||
+
|
||||
+ private static EntityDamageEvent callEntityDamageEvent(Entity damager, Entity damagee, DamageCause cause, Map<DamageModifier, Double> modifiers, Map<DamageModifier, Function<? super Double, Double>> modifierFunctions, boolean cancelled, boolean critical) {
|
||||
+ // Paper end
|
||||
EntityDamageEvent event;
|
||||
if (damager != null) {
|
||||
- event = new EntityDamageByEntityEvent(damager.getBukkitEntity(), damagee.getBukkitEntity(), cause, modifiers, modifierFunctions);
|
||||
+ event = new EntityDamageByEntityEvent(damager.getBukkitEntity(), damagee.getBukkitEntity(), cause, modifiers, modifierFunctions, critical); // Paper - add critical damage API
|
||||
} else {
|
||||
event = new EntityDamageEvent(damagee.getBukkitEntity(), cause, modifiers, modifierFunctions);
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Sun, 24 Oct 2021 20:29:45 -0700
|
||||
Subject: [PATCH] Fix issues with mob conversion
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/monster/Skeleton.java b/src/main/java/net/minecraft/world/entity/monster/Skeleton.java
|
||||
index 116709ba2b298268ac806e6e45f2e910ca600706..1eeaf0cc9b00afd54f38f9cb50404ec9f9ba51f8 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/monster/Skeleton.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/monster/Skeleton.java
|
||||
@@ -86,10 +86,15 @@ public class Skeleton extends AbstractSkeleton {
|
||||
}
|
||||
|
||||
protected void doFreezeConversion() {
|
||||
- this.convertTo(EntityType.STRAY, true, org.bukkit.event.entity.EntityTransformEvent.TransformReason.FROZEN, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.FROZEN); // CraftBukkit - add spawn and transform reasons
|
||||
- if (!this.isSilent()) {
|
||||
+ Stray stray = this.convertTo(EntityType.STRAY, true, org.bukkit.event.entity.EntityTransformEvent.TransformReason.FROZEN, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.FROZEN); // CraftBukkit - add spawn and transform reasons // Paper - track result of conversion
|
||||
+ if (stray != null && !this.isSilent()) { // Paper - only send event if conversion succeeded
|
||||
this.level.levelEvent((Player) null, 1048, this.blockPosition(), 0);
|
||||
}
|
||||
+ // Paper start - reset conversion time to prevent event spam
|
||||
+ if (stray == null) {
|
||||
+ this.conversionTime = 300;
|
||||
+ }
|
||||
+ // Paper end
|
||||
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java b/src/main/java/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java
|
||||
index cbf181b30bae134150933c721f22161e3e9ffca3..12a1cb536d5cb109cac75636369ed1b2bfa3a0a4 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java
|
||||
@@ -105,6 +105,11 @@ public abstract class AbstractPiglin extends Monster {
|
||||
if (entitypigzombie != null) {
|
||||
entitypigzombie.addEffect(new MobEffectInstance(MobEffects.CONFUSION, 200, 0));
|
||||
}
|
||||
+ // Paper start - reset to prevent event spam
|
||||
+ else {
|
||||
+ this.timeInOverworld = 0;
|
||||
+ }
|
||||
+ // Paper end
|
||||
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeleton.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeleton.java
|
||||
index 61e2841fea6603e3e5fbd004de7ffdfb79fc9981..4a873a278a4dc76d868d789574a7890bf53832d7 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeleton.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSkeleton.java
|
||||
@@ -28,7 +28,7 @@ public class CraftSkeleton extends CraftAbstractSkeleton implements Skeleton {
|
||||
this.getHandle().conversionTime = -1;
|
||||
this.getHandle().getEntityData().set(net.minecraft.world.entity.monster.Skeleton.DATA_STRAY_CONVERSION_ID, false);
|
||||
} else {
|
||||
- this.getHandle().getSwimAmount(time); // PAIL rename startStrayConversion
|
||||
+ this.getHandle().startFreezeConversion(time); // PAIL rename startStrayConversion // Paper - nope, that's not the right method
|
||||
}
|
||||
}
|
||||
|
|
@ -1,55 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Thu, 4 Nov 2021 11:50:40 -0700
|
||||
Subject: [PATCH] Add isCollidable methods to various places
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
||||
index e3944d0f4fd18ef6c545dc4a131c0b120dff753a..5154cfffc414e1f6039e55f1a256bbaacb56bc55 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
|
||||
@@ -470,6 +470,11 @@ public class CraftBlock implements Block {
|
||||
public boolean isSolid() {
|
||||
return getNMS().getMaterial().blocksMotion();
|
||||
}
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isCollidable() {
|
||||
+ return getNMS().getBlock().hasCollision;
|
||||
+ }
|
||||
// Paper end
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java
|
||||
index 7b9e943b391c061782fccd2b8d705ceec8db50fe..966ac60daebb7bb211ab8096fc0c5f33db67320a 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java
|
||||
@@ -324,4 +324,11 @@ public class CraftBlockState implements BlockState {
|
||||
throw new IllegalStateException("The blockState must be placed to call this method");
|
||||
}
|
||||
}
|
||||
+
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ public boolean isCollidable() {
|
||||
+ return this.data.getBlock().hasCollision;
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||
index 26273a6b9d49f0e12fe1ff3206c7f017a2f36e44..eb11abe4bc8f06d457da674848b39fc3b3873d1a 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||
@@ -528,6 +528,12 @@ public final class CraftMagicNumbers implements UnsafeValues {
|
||||
var supplier = net.minecraft.world.entity.ai.attributes.DefaultAttributes.getSupplier((net.minecraft.world.entity.EntityType<? extends net.minecraft.world.entity.LivingEntity>) net.minecraft.core.Registry.ENTITY_TYPE.get(CraftNamespacedKey.toMinecraft(bukkitEntityKey)));
|
||||
return new io.papermc.paper.attribute.UnmodifiableAttributeMap(supplier);
|
||||
}
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isCollidable(Material material) {
|
||||
+ Preconditions.checkArgument(material.isBlock(), material + " is not a block");
|
||||
+ return getBlock(material).hasCollision;
|
||||
+ }
|
||||
// Paper end
|
||||
|
||||
/**
|
|
@ -1,44 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Seggan <segganew@gmail.com>
|
||||
Date: Thu, 5 Aug 2021 13:10:27 -0400
|
||||
Subject: [PATCH] Goat ram API
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/goat/Goat.java b/src/main/java/net/minecraft/world/entity/animal/goat/Goat.java
|
||||
index 32d0387b6c66462ca965add78a562dec3c4b95a9..c7e24da48aaff9fbd1a8272483231744326e3a8e 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/animal/goat/Goat.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/animal/goat/Goat.java
|
||||
@@ -279,6 +279,17 @@ public class Goat extends Animal {
|
||||
return new Goat.GoatPathNavigation(this, world);
|
||||
}
|
||||
|
||||
+ // Paper start - Goat ram API
|
||||
+ public void ram(LivingEntity entity) {
|
||||
+ Brain<Goat> brain = this.getBrain();
|
||||
+ brain.setMemory(MemoryModuleType.RAM_TARGET, entity.position());
|
||||
+ brain.eraseMemory(MemoryModuleType.RAM_COOLDOWN_TICKS);
|
||||
+ brain.eraseMemory(MemoryModuleType.BREED_TARGET);
|
||||
+ brain.eraseMemory(MemoryModuleType.TEMPTING_PLAYER);
|
||||
+ brain.setActiveActivityIfPossible(net.minecraft.world.entity.schedule.Activity.RAM);
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
private static class GoatPathNavigation extends GroundPathNavigation {
|
||||
|
||||
GoatPathNavigation(Goat goat, Level world) {
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftGoat.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftGoat.java
|
||||
index ae74df5c9845ac125968a52897f4343b0f348217..436aa41563b8fab112d03c8cc516cf6ff37587bd 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftGoat.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftGoat.java
|
||||
@@ -34,4 +34,11 @@ public class CraftGoat extends CraftAnimals implements Goat {
|
||||
public void setScreaming(boolean screaming) {
|
||||
this.getHandle().setScreamingGoat(screaming);
|
||||
}
|
||||
+
|
||||
+ // Paper start - Goat ram API
|
||||
+ @Override
|
||||
+ public void ram(@org.jetbrains.annotations.NotNull org.bukkit.entity.LivingEntity entity) {
|
||||
+ this.getHandle().ram(((CraftLivingEntity) entity).getHandle());
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: booky10 <boooky10@gmail.com>
|
||||
Date: Fri, 5 Nov 2021 21:01:36 +0100
|
||||
Subject: [PATCH] Add API for resetting a single score
|
||||
|
||||
It was only possible to reset all scores for a specific entry, instead of resetting only specific scores.
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScore.java b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScore.java
|
||||
index 2c4ffed5e828f051c44f494a8ed599a8197d7450..3b26793b67282c3a20c023b9c13a2a9b54d5d932 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScore.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScore.java
|
||||
@@ -68,4 +68,12 @@ final class CraftScore implements Score {
|
||||
public CraftScoreboard getScoreboard() {
|
||||
return this.objective.getScoreboard();
|
||||
}
|
||||
+
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ public void resetScore() {
|
||||
+ Scoreboard board = this.objective.checkState().board;
|
||||
+ board.resetPlayerScore(entry, this.objective.getHandle());
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue