Skip to content

Commit

Permalink
Update CraftBukkit-1.21.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Mgazul committed Dec 7, 2024
1 parent 0396e29 commit 40c6716
Show file tree
Hide file tree
Showing 53 changed files with 1,082 additions and 316 deletions.
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Progress
- [x] Rectify NeoForge([**00f3f80ef9**](https://github.com/neoforged/NeoForge/commit/00f3f80ef9))
- [ ] Start patch
* [x] Bukkit([**3339db16**](https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/commits/3339db16))
* [ ] CraftBukkit([**d50f50585**](https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/commits/d50f50585))
* [ ] CraftBukkit([**665900b91**](https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/commits/665900b91))
* [ ] Spigot ([**d2eba2c8**](https://hub.spigotmc.org/stash/projects/SPIGOT/repos/spigot/commits/d2eba2c8))
* [ ] Bukkit-Patches
* [ ] CraftBukkit-Patches
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@
public final boolean preventProxyConnections = this.get("prevent-proxy-connections", false);
public final String serverIp = this.get("server-ip", "");
public final boolean pvp = this.get("pvp", true);
@@ -103,6 +_,7 @@
@@ -99,10 +_,11 @@
public final Settings<DedicatedServerProperties>.MutableValue<Boolean> whiteList = this.getMutable("white-list", false);
public final boolean enforceSecureProfile = this.get("enforce-secure-profile", true);
public final boolean logIPs = this.get("log-ips", true);
- public final int pauseWhenEmptySeconds = this.get("pause-when-empty-seconds", 60);
+ public int pauseWhenEmptySeconds = this.get("pause-when-empty-seconds", 60);
private final DedicatedServerProperties.WorldDimensionData worldDimensionData;
public final WorldOptions worldOptions;
public boolean acceptsTransfers = this.get("accepts-transfers", false);
Expand Down
13 changes: 13 additions & 0 deletions patches/net/minecraft/world/entity/vehicle/MinecartTNT.java.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--- a/net/minecraft/world/entity/vehicle/MinecartTNT.java
+++ b/net/minecraft/world/entity/vehicle/MinecartTNT.java
@@ -31,8 +_,8 @@
private static final float DEFAULT_EXPLOSION_POWER_BASE = 4.0F;
private static final float DEFAULT_EXPLOSION_SPEED_FACTOR = 1.0F;
public int fuse = -1;
- private float explosionPowerBase = 4.0F;
- private float explosionSpeedFactor = 1.0F;
+ public float explosionPowerBase = 4.0F;
+ public float explosionSpeedFactor = 1.0F;

public MinecartTNT(EntityType<? extends MinecartTNT> p_38649_, Level p_38650_) {
super(p_38649_, p_38650_);
39 changes: 36 additions & 3 deletions patches/net/minecraft/world/item/crafting/Ingredient.java.patch
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
--- a/net/minecraft/world/item/crafting/Ingredient.java
+++ b/net/minecraft/world/item/crafting/Ingredient.java
@@ -23,16 +_,20 @@
@@ -21,18 +_,42 @@
import net.minecraft.world.item.Items;
import net.minecraft.world.item.crafting.display.SlotDisplay;
import net.minecraft.world.level.ItemLike;
+import org.jetbrains.annotations.Nullable;

public class Ingredient implements StackedContents.IngredientInfo<Holder<Item>>, Predicate<ItemStack> {
- public static final StreamCodec<RegistryFriendlyByteBuf, Ingredient> CONTENTS_STREAM_CODEC = ByteBufCodecs.holderSet(Registries.ITEM)
Expand All @@ -24,10 +27,29 @@
+ private net.neoforged.neoforge.common.crafting.ICustomIngredient customIngredient = null;
+ @org.jetbrains.annotations.Nullable
+ private List<Holder<Item>> customIngredientValues;
+
+ // CraftBukkit start
+ @Nullable
+ private List<ItemStack> itemStacks;
+
+ public boolean isExact() {
+ return this.itemStacks != null;
+ }
+
+ public List<ItemStack> itemStacks() {
+ return this.itemStacks;
+ }
+
+ public static Ingredient ofStacks(List<ItemStack> stacks) {
+ Ingredient recipe = Ingredient.of(stacks.stream().map(ItemStack::getItem));
+ recipe.itemStacks = stacks;
+ return recipe;
+ }
+ // CraftBukkit end

private Ingredient(HolderSet<Item> p_365027_) {
p_365027_.unwrap().ifRight(p_360057_ -> {
@@ -45,30 +_,96 @@
@@ -45,30 +_,107 @@
this.values = p_365027_;
}

Expand Down Expand Up @@ -59,6 +81,17 @@
+ if (this.customIngredient != null) {
+ return this.customIngredient.test(p_43914_);
+ }
+ // CraftBukkit start
+ if (this.isExact()) {
+ for (ItemStack itemstack1 : this.itemStacks()) {
+ if (itemstack1.getItem() == p_43914_.getItem() && ItemStack.isSameItemSameComponents(p_43914_, itemstack1)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+ // CraftBukkit end
return p_43914_.is(this.values);
}

Expand All @@ -72,7 +105,7 @@
@Override
public boolean equals(Object p_301003_) {
- return p_301003_ instanceof Ingredient ingredient ? Objects.equals(this.values, ingredient.values) : false;
+ return p_301003_ instanceof Ingredient ingredient ? java.util.Objects.equals(this.customIngredient, ingredient.customIngredient) && Objects.equals(this.values, ingredient.values) : false;
+ return p_301003_ instanceof Ingredient ingredient ? java.util.Objects.equals(this.customIngredient, ingredient.customIngredient) && Objects.equals(this.values, ingredient.values) && Objects.equals(this.itemStacks, ingredient.itemStacks) : false;
+ }
+
+ @Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
--- a/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java
+++ b/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java
@@ -53,6 +_,7 @@
@@ -53,19 +_,25 @@
public static final int NUM_DATA_VALUES = 4;
public static final int BURN_TIME_STANDARD = 200;
public static final int BURN_COOL_SPEED = 2;
+ private final RecipeType<? extends AbstractCookingRecipe> recipeType;
protected NonNullList<ItemStack> items = NonNullList.withSize(3, ItemStack.EMPTY);
int litTimeRemaining;
- int litTimeRemaining;
+ public int litTimeRemaining;
int litTotalTime;
@@ -63,9 +_,14 @@
- int cookingTimer;
+ public int cookingTimer;
public int cookingTotalTime;
protected final ContainerData dataAccess = new ContainerData() {
@Override
public int get(int p_58431_) {
switch (p_58431_) {
case 0:
Expand Down
108 changes: 95 additions & 13 deletions src/main/java/org/bukkit/craftbukkit/CraftArt.java
Original file line number Diff line number Diff line change
@@ -1,35 +1,31 @@
package org.bukkit.craftbukkit;

import com.google.common.base.Preconditions;
import java.util.Locale;
import net.minecraft.core.Holder;
import net.minecraft.core.registries.Registries;
import net.minecraft.world.entity.decoration.PaintingVariant;
import org.bukkit.Art;
import org.bukkit.NamespacedKey;
import org.bukkit.Registry;
import org.bukkit.craftbukkit.util.CraftNamespacedKey;
import org.bukkit.craftbukkit.util.Handleable;
import org.jetbrains.annotations.NotNull;

public class CraftArt {
public class CraftArt implements Art, Handleable<PaintingVariant> {

public static Art minecraftToBukkit(PaintingVariant minecraft) {
Preconditions.checkArgument(minecraft != null);

net.minecraft.core.Registry<PaintingVariant> registry = CraftRegistry.getMinecraftRegistry(Registries.PAINTING_VARIANT);
Art bukkit = Registry.ART.get(CraftNamespacedKey.fromMinecraft(registry.getResourceKey(minecraft).orElseThrow().location()));

Preconditions.checkArgument(bukkit != null);
private static int count = 0;

return bukkit;
public static Art minecraftToBukkit(PaintingVariant minecraft) {
return CraftRegistry.minecraftToBukkit(minecraft, Registries.PAINTING_VARIANT, Registry.ART);
}

public static Art minecraftHolderToBukkit(Holder<PaintingVariant> minecraft) {
return CraftArt.minecraftToBukkit(minecraft.value());
}

public static PaintingVariant bukkitToMinecraft(Art bukkit) {
Preconditions.checkArgument(bukkit != null);

return CraftRegistry.getMinecraftRegistry(Registries.PAINTING_VARIANT)
.getOptional(CraftNamespacedKey.toMinecraft(bukkit.getKey())).orElseThrow();
return CraftRegistry.bukkitToMinecraft(bukkit);
}

public static Holder<PaintingVariant> bukkitToMinecraftHolder(Art bukkit) {
Expand All @@ -44,4 +40,90 @@ public static Holder<PaintingVariant> bukkitToMinecraftHolder(Art bukkit) {
throw new IllegalArgumentException("No Reference holder found for " + bukkit
+ ", this can happen if a plugin creates its own painting variant with out properly registering it.");
}

private final NamespacedKey key;
private final PaintingVariant paintingVariant;
private final String name;
private final int ordinal;

public CraftArt(NamespacedKey key, PaintingVariant paintingVariant) {
this.key = key;
this.paintingVariant = paintingVariant;
// For backwards compatibility, minecraft values will stile return the uppercase name without the namespace,
// in case plugins use for example the name as key in a config file to receive art specific values.
// Custom arts will return the key with namespace. For a plugin this should look than like a new art
// (which can always be added in new minecraft versions and the plugin should therefore handle it accordingly).
if (NamespacedKey.MINECRAFT.equals(key.getNamespace())) {
this.name = key.getKey().toUpperCase(Locale.ROOT);
} else {
this.name = key.toString();
}
this.ordinal = count++;
}

@Override
public PaintingVariant getHandle() {
return paintingVariant;
}

@Override
public int getBlockWidth() {
return paintingVariant.width();
}

@Override
public int getBlockHeight() {
return paintingVariant.height();
}

@Override
public int getId() {
return CraftRegistry.getMinecraftRegistry(Registries.PAINTING_VARIANT).getId(paintingVariant);
}

@NotNull
@Override
public NamespacedKey getKey() {
return key;
}

@Override
public int compareTo(@NotNull Art art) {
return ordinal - art.ordinal();
}

@NotNull
@Override
public String name() {
return name;
}

@Override
public int ordinal() {
return ordinal;
}

@Override
public String toString() {
// For backwards compatibility
return name();
}

@Override
public boolean equals(Object other) {
if (this == other) {
return true;
}

if (!(other instanceof CraftArt otherArt)) {
return false;
}

return getKey().equals(otherArt.getKey());
}

@Override
public int hashCode() {
return getKey().hashCode();
}
}
Loading

0 comments on commit 40c6716

Please sign in to comment.