mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 23:38:25 +01:00
net.minecraft.world.item.alchemy
This commit is contained in:
parent
f60983ac06
commit
fe1744dfd1
3 changed files with 29 additions and 38 deletions
|
@ -1,14 +1,14 @@
|
||||||
--- a/net/minecraft/world/item/alchemy/PotionBrewing.java
|
--- a/net/minecraft/world/item/alchemy/PotionBrewing.java
|
||||||
+++ b/net/minecraft/world/item/alchemy/PotionBrewing.java
|
+++ b/net/minecraft/world/item/alchemy/PotionBrewing.java
|
||||||
@@ -19,6 +19,7 @@
|
@@ -19,6 +_,7 @@
|
||||||
private final List<Ingredient> containers;
|
private final List<Ingredient> containers;
|
||||||
private final List<PotionBrewing.Mix<Potion>> potionMixes;
|
private final List<PotionBrewing.Mix<Potion>> potionMixes;
|
||||||
private final List<PotionBrewing.Mix<Item>> containerMixes;
|
private final List<PotionBrewing.Mix<Item>> containerMixes;
|
||||||
+ private final it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap<org.bukkit.NamespacedKey, io.papermc.paper.potion.PaperPotionMix> customMixes = new it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap<>(); // Paper - Custom Potion Mixes
|
+ private final it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap<org.bukkit.NamespacedKey, io.papermc.paper.potion.PaperPotionMix> customMixes = new it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap<>(); // Paper - Custom Potion Mixes
|
||||||
|
|
||||||
PotionBrewing(List<Ingredient> potionTypes, List<PotionBrewing.Mix<Potion>> potionRecipes, List<PotionBrewing.Mix<Item>> itemRecipes) {
|
PotionBrewing(List<Ingredient> containers, List<PotionBrewing.Mix<Potion>> potionMixes, List<PotionBrewing.Mix<Item>> containerMixes) {
|
||||||
this.containers = potionTypes;
|
this.containers = containers;
|
||||||
@@ -27,7 +28,7 @@
|
@@ -27,7 +_,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isIngredient(ItemStack stack) {
|
public boolean isIngredient(ItemStack stack) {
|
||||||
|
@ -17,36 +17,37 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isContainer(ItemStack stack) {
|
private boolean isContainer(ItemStack stack) {
|
||||||
@@ -71,6 +72,11 @@
|
@@ -71,6 +_,11 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasMix(ItemStack input, ItemStack ingredient) {
|
public boolean hasMix(ItemStack reagent, ItemStack potionItem) {
|
||||||
+ // Paper start - Custom Potion Mixes
|
+ // Paper start - Custom Potion Mixes
|
||||||
+ if (this.hasCustomMix(input, ingredient)) {
|
+ if (this.hasCustomMix(reagent, potionItem)) {
|
||||||
+ return true;
|
+ return true;
|
||||||
+ }
|
+ }
|
||||||
+ // Paper end - Custom Potion Mixes
|
+ // Paper end - Custom Potion Mixes
|
||||||
return this.isContainer(input) && (this.hasContainerMix(input, ingredient) || this.hasPotionMix(input, ingredient));
|
return this.isContainer(reagent) && (this.hasContainerMix(reagent, potionItem) || this.hasPotionMix(reagent, potionItem));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,6 +109,13 @@
|
@@ -103,6 +_,13 @@
|
||||||
if (input.isEmpty()) {
|
if (potionItem.isEmpty()) {
|
||||||
return input;
|
return potionItem;
|
||||||
} else {
|
} else {
|
||||||
+ // Paper start - Custom Potion Mixes
|
+ // Paper start - Custom Potion Mixes
|
||||||
+ for (io.papermc.paper.potion.PaperPotionMix mix : this.customMixes.values()) {
|
+ for (io.papermc.paper.potion.PaperPotionMix mix : this.customMixes.values()) {
|
||||||
+ if (mix.input().test(input) && mix.ingredient().test(ingredient)) {
|
+ if (mix.input().test(potionItem) && mix.ingredient().test(potion)) {
|
||||||
+ return mix.result().copy();
|
+ return mix.result().copy();
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+ // Paper end - Custom Potion Mixes
|
+ // Paper end - Custom Potion Mixes
|
||||||
Optional<Holder<Potion>> optional = input.getOrDefault(DataComponents.POTION_CONTENTS, PotionContents.EMPTY).potion();
|
Optional<Holder<Potion>> optional = potionItem.getOrDefault(DataComponents.POTION_CONTENTS, PotionContents.EMPTY).potion();
|
||||||
if (optional.isEmpty()) {
|
if (optional.isEmpty()) {
|
||||||
return input;
|
return potionItem;
|
||||||
@@ -190,6 +203,50 @@
|
@@ -189,6 +_,50 @@
|
||||||
|
builder.addMix(Potions.AWKWARD, Items.PHANTOM_MEMBRANE, Potions.SLOW_FALLING);
|
||||||
builder.addMix(Potions.SLOW_FALLING, Items.REDSTONE, Potions.LONG_SLOW_FALLING);
|
builder.addMix(Potions.SLOW_FALLING, Items.REDSTONE, Potions.LONG_SLOW_FALLING);
|
||||||
}
|
}
|
||||||
|
+
|
||||||
+ // Paper start - Custom Potion Mixes
|
+ // Paper start - Custom Potion Mixes
|
||||||
+ public boolean isCustomIngredient(ItemStack stack) {
|
+ public boolean isCustomIngredient(ItemStack stack) {
|
||||||
+ for (io.papermc.paper.potion.PaperPotionMix mix : this.customMixes.values()) {
|
+ for (io.papermc.paper.potion.PaperPotionMix mix : this.customMixes.values()) {
|
||||||
|
@ -90,7 +91,6 @@
|
||||||
+ return bootstrap(flags);
|
+ return bootstrap(flags);
|
||||||
+ }
|
+ }
|
||||||
+ // Paper end - Custom Potion Mixes
|
+ // Paper end - Custom Potion Mixes
|
||||||
+
|
|
||||||
public static class Builder {
|
public static class Builder {
|
||||||
private final List<Ingredient> containers = new ArrayList<>();
|
private final List<Ingredient> containers = new ArrayList<>();
|
||||||
private final List<PotionBrewing.Mix<Potion>> potionMixes = new ArrayList<>();
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
--- a/net/minecraft/world/item/alchemy/PotionContents.java
|
||||||
|
+++ b/net/minecraft/world/item/alchemy/PotionContents.java
|
||||||
|
@@ -158,7 +_,7 @@
|
||||||
|
if (mobEffectInstance.getEffect().value().isInstantenous()) {
|
||||||
|
mobEffectInstance.getEffect().value().applyInstantenousEffect(serverLevel, player1, player1, entity, mobEffectInstance.getAmplifier(), 1.0);
|
||||||
|
} else {
|
||||||
|
- entity.addEffect(mobEffectInstance);
|
||||||
|
+ entity.addEffect(mobEffectInstance, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.POTION_DRINK); // CraftBukkit
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
|
@ -1,20 +0,0 @@
|
||||||
--- a/net/minecraft/world/item/alchemy/PotionContents.java
|
|
||||||
+++ b/net/minecraft/world/item/alchemy/PotionContents.java
|
|
||||||
@@ -93,7 +93,7 @@
|
|
||||||
}
|
|
||||||
|
|
||||||
public PotionContents withEffectAdded(MobEffectInstance customEffect) {
|
|
||||||
- return new PotionContents(this.potion, this.customColor, Util.copyAndAdd(this.customEffects, (Object) customEffect), this.customName);
|
|
||||||
+ return new PotionContents(this.potion, this.customColor, Util.copyAndAdd(this.customEffects, customEffect), this.customName); // CraftBukkit - decompile error
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getColor() {
|
|
||||||
@@ -172,7 +172,7 @@
|
|
||||||
if (((MobEffect) mobeffect.getEffect().value()).isInstantenous()) {
|
|
||||||
((MobEffect) mobeffect.getEffect().value()).applyInstantenousEffect(worldserver, entityhuman2, entityhuman2, user, mobeffect.getAmplifier(), 1.0D);
|
|
||||||
} else {
|
|
||||||
- user.addEffect(mobeffect);
|
|
||||||
+ user.addEffect(mobeffect, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.POTION_DRINK); // CraftBukkit
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
Loading…
Reference in a new issue