Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
revert: reverted some formattings and auto-imports
  • Loading branch information
RealRONiN committed Oct 10, 2022
commit be7325528cc06cd8458ec0d74ffdb93f8dd99814
147 changes: 56 additions & 91 deletions patches/server/0309-Cure-effects-food-property.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ Subject: [PATCH] Cure effects food property


diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index 9dca0d694aa8fa7f8bec0d2504986085e0cc6fe9..c3db4c71da1c8bfd5cb099a7af72ca07b8dfbd9d 100644
index 9dca0d694aa8fa7f8bec0d2504986085e0cc6fe9..16c722acbbb0e7cd66d035919649ef623fc81ece 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -4374,6 +4374,7 @@ public abstract class LivingEntity extends Entity {
if (stack.isEdible()) {
world.playSound((net.minecraft.world.entity.player.Player) null, this.getX(), this.getY(), this.getZ(), this.getEatingSound(stack), SoundSource.NEUTRAL, 1.0F, 1.0F + (world.random.nextFloat() - world.random.nextFloat()) * 0.4F);
this.addEatEffect(stack, world, this);
+ this.removeEatEffect(stack, world, this);
+ this.removeEatEffect(stack, world, this); //Purpur
if (!(this instanceof net.minecraft.world.entity.player.Player) || !((net.minecraft.world.entity.player.Player) this).getAbilities().instabuild) {
stack.shrink(1);
}
Expand All @@ -25,10 +25,11 @@ index 9dca0d694aa8fa7f8bec0d2504986085e0cc6fe9..c3db4c71da1c8bfd5cb099a7af72ca07
Iterator iterator = list.iterator();

while (iterator.hasNext()) {
@@ -4402,6 +4403,22 @@ public abstract class LivingEntity extends Entity {
@@ -4402,6 +4403,23 @@ public abstract class LivingEntity extends Entity {

}

+ //Purpur start
+ private void removeEatEffect(ItemStack stack, Level world, LivingEntity targetEntity) {
+ Item item = stack.getItem();
+ List<MobEffect> list = item.getFoodProperties().getEffectsToCure();
Expand All @@ -42,46 +43,41 @@ index 9dca0d694aa8fa7f8bec0d2504986085e0cc6fe9..c3db4c71da1c8bfd5cb099a7af72ca07
+ }
+ }
+ }
+
+ }
+ //Purpur end
+
private static byte entityEventForEquipmentBreak(EquipmentSlot slot) {
switch (slot) {
case MAINHAND:
@@ -4511,4 +4528,4 @@ public abstract class LivingEntity extends Entity {
public static record Fallsounds(SoundEvent small, SoundEvent big) {

}
-}
+}
\ No newline at end of file
diff --git a/src/main/java/net/minecraft/world/food/FoodProperties.java b/src/main/java/net/minecraft/world/food/FoodProperties.java
index 6c945ae8fe8b1517e312c688f829fab41f12d9f4..770e17097c72e5e7359e5df147f855a6c947a9f5 100644
index 6c945ae8fe8b1517e312c688f829fab41f12d9f4..246d689eb2a5f321ec25d4332f53feb12c858ec7 100644
--- a/src/main/java/net/minecraft/world/food/FoodProperties.java
+++ b/src/main/java/net/minecraft/world/food/FoodProperties.java
@@ -5,6 +5,8 @@ import com.mojang.datafixers.util.Pair;
@@ -2,10 +2,8 @@ package net.minecraft.world.food;

import com.google.common.collect.Lists;
import com.mojang.datafixers.util.Pair;
-
import java.util.ArrayList;
import java.util.List;
+
+import net.minecraft.world.effect.MobEffect;
import net.minecraft.world.effect.MobEffectInstance;
-import net.minecraft.world.effect.MobEffectInstance;

public class FoodProperties {
@@ -15,18 +17,20 @@ public class FoodProperties {
// Purpur start
@@ -15,18 +13,20 @@ public class FoodProperties {
private boolean canAlwaysEat; public void setCanAlwaysEat(boolean canAlwaysEat) { this.canAlwaysEat = canAlwaysEat; }
private boolean fastFood; public void setFastFood(boolean isFastFood) { this.fastFood = isFastFood; }
public FoodProperties copy() {
- return new FoodProperties(this.nutrition, this.saturationModifier, this.isMeat, this.canAlwaysEat, this.fastFood, new ArrayList<>(this.effects));
+ return new FoodProperties(this.nutrition, this.saturationModifier, this.isMeat, this.canAlwaysEat, this.fastFood, new ArrayList<>(this.effectsToAdd), effectsToCure);
}
+ private final List<net.minecraft.world.effect.MobEffect> effectsToCure;
+ private final List<Pair<net.minecraft.world.effect.MobEffectInstance, Float>> effectsToAdd;
// Purpur end
- private final List<Pair<MobEffectInstance, Float>> effects;
+ private final List<Pair<MobEffectInstance, Float>> effectsToAdd;
+ private final List<MobEffect> effectsToCure;

- FoodProperties(int hunger, float saturationModifier, boolean meat, boolean alwaysEdible, boolean snack, List<Pair<MobEffectInstance, Float>> statusEffects) {
+ FoodProperties(int hunger, float saturationModifier, boolean meat, boolean alwaysEdible, boolean snack, List<Pair<MobEffectInstance, Float>> statusEffects, List<MobEffect> effectsToCure) {
+ FoodProperties(int hunger, float saturationModifier, boolean meat, boolean alwaysEdible, boolean snack, List<Pair<net.minecraft.world.effect.MobEffectInstance, Float>> statusEffects, List<net.minecraft.world.effect.MobEffect> effectsToCure) {
this.nutrition = hunger;
this.saturationModifier = saturationModifier;
this.isMeat = meat;
Expand All @@ -93,57 +89,59 @@ index 6c945ae8fe8b1517e312c688f829fab41f12d9f4..770e17097c72e5e7359e5df147f855a6
}

public int getNutrition() {
@@ -49,8 +53,12 @@ public class FoodProperties {
@@ -49,9 +49,14 @@ public class FoodProperties {
return this.fastFood;
}

- public List<Pair<MobEffectInstance, Float>> getEffects() {
- return this.effects;
+ public List<Pair<MobEffectInstance, Float>> getEffectsToAdd() {
+ public List<Pair<net.minecraft.world.effect.MobEffectInstance, Float>> getEffectsToAdd() {
+ return this.effectsToAdd;
+ }
+
+ public List<MobEffect> getEffectsToCure() {
+ //Purpur start
+ public List<net.minecraft.world.effect.MobEffect> getEffectsToCure() {
+ return this.effectsToCure;
}
+ //Purpur end

public static class Builder {
@@ -59,7 +67,8 @@ public class FoodProperties {
private int nutrition;
@@ -59,7 +64,8 @@ public class FoodProperties {
private boolean isMeat;
private boolean canAlwaysEat;
private boolean fastFood;
- private final List<Pair<MobEffectInstance, Float>> effects = Lists.newArrayList();
+ private final List<Pair<MobEffectInstance, Float>> effectsToAdd = Lists.newArrayList();
+ private final List<MobEffect> effectsToCure = new ArrayList<>();
+ private final List<Pair<net.minecraft.world.effect.MobEffectInstance, Float>> effectsToAdd = Lists.newArrayList();
+ private final List<net.minecraft.world.effect.MobEffect> effectsToCure = new ArrayList<>(); //Purpur

public FoodProperties.Builder nutrition(int hunger) {
this.nutrition = hunger;
@@ -86,13 +95,18 @@ public class FoodProperties {
@@ -86,13 +92,20 @@ public class FoodProperties {
return this;
}

- public FoodProperties.Builder effect(MobEffectInstance effect, float chance) {
- this.effects.add(Pair.of(effect, chance));
+ public FoodProperties.Builder effectToAdd(MobEffectInstance effect, float chance) {
+ //Purpur start
+ public FoodProperties.Builder effectToAdd(net.minecraft.world.effect.MobEffectInstance effect, float chance) {
+ this.effectsToAdd.add(Pair.of(effect, chance));
+ return this;
+ }
+
+ public FoodProperties.Builder effectToCure(MobEffect effect) {
+ public FoodProperties.Builder effectToCure(net.minecraft.world.effect.MobEffect effect) {
+ this.effectsToCure.add(effect);
return this;
}
+ //Purpur end

public FoodProperties build() {
- return new FoodProperties(this.nutrition, this.saturationModifier, this.isMeat, this.canAlwaysEat, this.fastFood, this.effects);
+ return new FoodProperties(this.nutrition, this.saturationModifier, this.isMeat, this.canAlwaysEat, this.fastFood, this.effectsToAdd, this.effectsToCure);
}
}
-}
+}
\ No newline at end of file
}
diff --git a/src/main/java/net/minecraft/world/food/Foods.java b/src/main/java/net/minecraft/world/food/Foods.java
index 71beab673f04cd051c46ea37f8c847316885d38d..93b103866af9cf0c57e51f22a794869762c468d3 100644
index 71beab673f04cd051c46ea37f8c847316885d38d..85de0e91b7472efc49cb85f0ae77ee4734ca7892 100644
--- a/src/main/java/net/minecraft/world/food/Foods.java
+++ b/src/main/java/net/minecraft/world/food/Foods.java
@@ -14,7 +14,7 @@ public class Foods {
Expand All @@ -165,7 +163,7 @@ index 71beab673f04cd051c46ea37f8c847316885d38d..93b103866af9cf0c57e51f22a7948697
+ public static final FoodProperties GOLDEN_APPLE = (new FoodProperties.Builder()).nutrition(4).saturationMod(1.2F).effectToAdd(new MobEffectInstance(MobEffects.REGENERATION, 100, 1), 1.0F).effectToAdd(new MobEffectInstance(MobEffects.ABSORPTION, 2400, 0), 1.0F).alwaysEat().build();
public static final FoodProperties GOLDEN_CARROT = (new FoodProperties.Builder()).nutrition(6).saturationMod(1.2F).build();
- public static final FoodProperties HONEY_BOTTLE = (new FoodProperties.Builder()).nutrition(6).saturationMod(0.1F).build();
+ public static final FoodProperties HONEY_BOTTLE = (new FoodProperties.Builder()).nutrition(6).saturationMod(0.1F).effectToCure(MobEffects.POISON).build();
+ public static final FoodProperties HONEY_BOTTLE = (new FoodProperties.Builder()).nutrition(6).saturationMod(0.1F).effectToCure(MobEffects.POISON).build(); //Purpur
public static final FoodProperties MELON_SLICE = (new FoodProperties.Builder()).nutrition(2).saturationMod(0.3F).build();
public static final FoodProperties MUSHROOM_STEW = stew(6).build();
public static final FoodProperties MUTTON = (new FoodProperties.Builder()).nutrition(2).saturationMod(0.3F).meat().build();
Expand All @@ -186,15 +184,8 @@ index 71beab673f04cd051c46ea37f8c847316885d38d..93b103866af9cf0c57e51f22a7948697
public static final FoodProperties SUSPICIOUS_STEW = stew(6).alwaysEat().build();
public static final FoodProperties SWEET_BERRIES = (new FoodProperties.Builder()).nutrition(2).saturationMod(0.1F).build();
public static final FoodProperties GLOW_BERRIES = (new FoodProperties.Builder()).nutrition(2).saturationMod(0.1F).build();
@@ -51,4 +51,4 @@ public class Foods {
private static FoodProperties.Builder stew(int hunger) {
return (new FoodProperties.Builder()).nutrition(hunger).saturationMod(0.6F);
}
-}
+}
\ No newline at end of file
diff --git a/src/main/java/net/minecraft/world/item/HoneyBottleItem.java b/src/main/java/net/minecraft/world/item/HoneyBottleItem.java
index c8d6b5e60b6c8c612fa8580c63a32c4a8f8b0a7b..4729a3506ad3a70c6a511d8fe68c7c027f3f4890 100644
index c8d6b5e60b6c8c612fa8580c63a32c4a8f8b0a7b..47fd71af71003ab0f8d16cac039f955fcb461f19 100644
--- a/src/main/java/net/minecraft/world/item/HoneyBottleItem.java
+++ b/src/main/java/net/minecraft/world/item/HoneyBottleItem.java
@@ -7,7 +7,6 @@ import net.minecraft.sounds.SoundEvents;
Expand All @@ -205,29 +196,34 @@ index c8d6b5e60b6c8c612fa8580c63a32c4a8f8b0a7b..4729a3506ad3a70c6a511d8fe68c7c02
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
@@ -27,10 +26,6 @@ public class HoneyBottleItem extends Item {
@@ -27,9 +26,11 @@ public class HoneyBottleItem extends Item {
serverPlayer.awardStat(Stats.ITEM_USED.get(this));
}

- if (!world.isClientSide) {
- user.removeEffect(MobEffects.POISON, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.FOOD); // Paper
- }
-
+ //Purpur start - moved this in defualt food properties.
+// if (!world.isClientSide) {
+// user.removeEffect(MobEffects.POISON, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.FOOD); // Paper
+// }
+ //Purpur end

if (stack.isEmpty()) {
return new ItemStack(Items.GLASS_BOTTLE);
} else {
@@ -70,4 +65,4 @@ public class HoneyBottleItem extends Item {
public InteractionResultHolder<ItemStack> use(Level world, Player user, InteractionHand hand) {
return ItemUtils.startUsingInstantly(world, user, hand);
}
-}
+}
\ No newline at end of file
diff --git a/src/main/java/org/purpurmc/purpur/PurpurConfig.java b/src/main/java/org/purpurmc/purpur/PurpurConfig.java
index 3cfbb4300e82cce409a7a0b53ef98987f166143c..c1d2dcb43d24ea631e8aa51c0410297bbb58ff17 100644
index 3cfbb4300e82cce409a7a0b53ef98987f166143c..dd6e3c74e89860d63813f5ca65de623928be9f96 100644
--- a/src/main/java/org/purpurmc/purpur/PurpurConfig.java
+++ b/src/main/java/org/purpurmc/purpur/PurpurConfig.java
@@ -535,10 +535,10 @@ public class PurpurConfig {
@@ -24,7 +24,6 @@ import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;
import org.purpurmc.purpur.command.PurpurCommand;
import org.purpurmc.purpur.task.TPSBarTask;
-
import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
@@ -535,10 +534,10 @@ public class PurpurConfig {
food.setIsMeat(properties.getBoolean(foodKey + ".is-meat", foodDefaults.isMeat()));
food.setCanAlwaysEat(properties.getBoolean(foodKey + ".can-always-eat", foodDefaults.canAlwaysEat()));
food.setFastFood(properties.getBoolean(foodKey + ".fast-food", foodDefaults.isFastFood()));
Expand All @@ -241,7 +237,7 @@ index 3cfbb4300e82cce409a7a0b53ef98987f166143c..c1d2dcb43d24ea631e8aa51c0410297b
effectDefaults.put("chance", pair.getSecond());
MobEffectInstance effect = pair.getFirst();
effectDefaults.put("duration", effect.getDuration());
@@ -547,25 +547,37 @@ public class PurpurConfig {
@@ -547,25 +546,37 @@ public class PurpurConfig {
effectDefaults.put("visible", effect.isVisible());
effectDefaults.put("show-icon", effect.showIcon());
});
Expand Down Expand Up @@ -288,51 +284,20 @@ index 3cfbb4300e82cce409a7a0b53ef98987f166143c..c1d2dcb43d24ea631e8aa51c0410297b
});
}

@@ -634,4 +646,4 @@ public class PurpurConfig {
block.fallDistanceMultiplier = fallDistanceMultiplier.floatValue();
});
}
-}
+}
\ No newline at end of file
diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
index a6356d19f0fc664be523f19c2ea1704191a7a73a..8eae296926522c5e0b7e0c10da15b1b266ae70d2 100644
index a6356d19f0fc664be523f19c2ea1704191a7a73a..1912bc126767928a9cf51ca638f9be340b0dd327 100644
--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
@@ -13,15 +13,16 @@ import net.minecraft.world.level.Explosion;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.properties.Tilt;
+import org.apache.commons.lang.BooleanUtils;
+import org.bukkit.ChatColor;
+import org.bukkit.World;
+import org.bukkit.configuration.ConfigurationSection;
import org.purpurmc.purpur.entity.GlowSquidColor;
import org.purpurmc.purpur.tool.Strippable;
import org.purpurmc.purpur.tool.Tillable;
import org.purpurmc.purpur.tool.Waxable;
import org.purpurmc.purpur.tool.Weatherable;
-import org.apache.commons.lang.BooleanUtils;
-import org.bukkit.ChatColor;
-import org.bukkit.World;
-import org.bukkit.configuration.ConfigurationSection;
+
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -29,6 +30,7 @@ import java.util.Locale;
@@ -29,6 +29,7 @@ import java.util.Locale;
import java.util.Map;
import java.util.function.Predicate;
import java.util.logging.Level;
+
import static org.purpurmc.purpur.PurpurConfig.log;

@SuppressWarnings("unused")
@@ -3131,5 +3133,4 @@ public class PurpurWorldConfig {
cauldronDripstoneWaterFillChance = (float) getDouble("blocks.cauldron.fill-chances.dripstone-water", cauldronDripstoneWaterFillChance);
@@ -3132,4 +3133,3 @@ public class PurpurWorldConfig {
cauldronDripstoneLavaFillChance = (float) getDouble("blocks.cauldron.fill-chances.dripstone-lava", cauldronDripstoneLavaFillChance);
}
-}
}
-
+}
\ No newline at end of file