aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-vineflower/net/minecraft/world/entity/projectile/Arrow.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/entity/projectile/Arrow.java.patch')
-rw-r--r--patch-remap/mache-vineflower/net/minecraft/world/entity/projectile/Arrow.java.patch306
1 files changed, 306 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/entity/projectile/Arrow.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/entity/projectile/Arrow.java.patch
new file mode 100644
index 0000000000..4ee848deb3
--- /dev/null
+++ b/patch-remap/mache-vineflower/net/minecraft/world/entity/projectile/Arrow.java.patch
@@ -0,0 +1,306 @@
+--- a/net/minecraft/world/entity/projectile/Arrow.java
++++ b/net/minecraft/world/entity/projectile/Arrow.java
+@@ -2,6 +2,7 @@
+
+ import com.google.common.collect.Sets;
+ import java.util.Collection;
++import java.util.Iterator;
+ import java.util.Set;
+ import net.minecraft.core.particles.ParticleTypes;
+ import net.minecraft.core.registries.BuiltInRegistries;
+@@ -22,73 +23,89 @@
+ import net.minecraft.world.level.Level;
+
+ public class Arrow extends AbstractArrow {
++
+ private static final int EXPOSED_POTION_DECAY_TIME = 600;
+ private static final int NO_EFFECT_COLOR = -1;
+ private static final EntityDataAccessor<Integer> ID_EFFECT_COLOR = SynchedEntityData.defineId(Arrow.class, EntityDataSerializers.INT);
+ private static final byte EVENT_POTION_PUFF = 0;
+ private static final ItemStack DEFAULT_ARROW_STACK = new ItemStack(Items.ARROW);
+- private Potion potion = Potions.EMPTY;
+- private final Set<MobEffectInstance> effects = Sets.newHashSet();
++ public Potion potion;
++ public final Set<MobEffectInstance> effects;
+ private boolean fixedColor;
+
+ public Arrow(EntityType<? extends Arrow> entityType, Level level) {
+- super(entityType, level, DEFAULT_ARROW_STACK);
++ super(entityType, level, Arrow.DEFAULT_ARROW_STACK);
++ this.potion = Potions.EMPTY;
++ this.effects = Sets.newHashSet();
+ }
+
+- public Arrow(Level level, double d, double d1, double d2, ItemStack itemStack) {
+- super(EntityType.ARROW, d, d1, d2, level, itemStack);
++ public Arrow(Level world, double d0, double d1, double d2, ItemStack itemstack) {
++ super(EntityType.ARROW, d0, d1, d2, world, itemstack);
++ this.potion = Potions.EMPTY;
++ this.effects = Sets.newHashSet();
+ }
+
+- public Arrow(Level level, LivingEntity livingEntity, ItemStack itemStack) {
+- super(EntityType.ARROW, livingEntity, level, itemStack);
++ public Arrow(Level world, LivingEntity entityliving, ItemStack itemstack) {
++ super(EntityType.ARROW, entityliving, world, itemstack);
++ this.potion = Potions.EMPTY;
++ this.effects = Sets.newHashSet();
+ }
+
+ public void setEffectsFromItem(ItemStack stack) {
+ if (stack.is(Items.TIPPED_ARROW)) {
+ this.potion = PotionUtils.getPotion(stack);
+- Collection<MobEffectInstance> customEffects = PotionUtils.getCustomEffects(stack);
+- if (!customEffects.isEmpty()) {
+- for (MobEffectInstance mobEffectInstance : customEffects) {
+- this.effects.add(new MobEffectInstance(mobEffectInstance));
++ Collection<MobEffectInstance> collection = PotionUtils.getCustomEffects(stack);
++
++ if (!collection.isEmpty()) {
++ Iterator iterator = collection.iterator();
++
++ while (iterator.hasNext()) {
++ MobEffectInstance mobeffect = (MobEffectInstance) iterator.next();
++
++ this.effects.add(new MobEffectInstance(mobeffect));
+ }
+ }
+
+- int customColor = getCustomColor(stack);
+- if (customColor == -1) {
++ int i = getCustomColor(stack);
++
++ if (i == -1) {
+ this.updateColor();
+ } else {
+- this.setFixedColor(customColor);
++ this.setFixedColor(i);
+ }
+ } else if (stack.is(Items.ARROW)) {
+ this.potion = Potions.EMPTY;
+ this.effects.clear();
+- this.entityData.set(ID_EFFECT_COLOR, -1);
++ this.entityData.set(Arrow.ID_EFFECT_COLOR, -1);
+ }
++
+ }
+
+ public static int getCustomColor(ItemStack stack) {
+- CompoundTag tag = stack.getTag();
+- return tag != null && tag.contains("CustomPotionColor", 99) ? tag.getInt("CustomPotionColor") : -1;
++ CompoundTag nbttagcompound = stack.getTag();
++
++ return nbttagcompound != null && nbttagcompound.contains("CustomPotionColor", 99) ? nbttagcompound.getInt("CustomPotionColor") : -1;
+ }
+
+- private void updateColor() {
++ public void updateColor() {
+ this.fixedColor = false;
+ if (this.potion == Potions.EMPTY && this.effects.isEmpty()) {
+- this.entityData.set(ID_EFFECT_COLOR, -1);
++ this.entityData.set(Arrow.ID_EFFECT_COLOR, -1);
+ } else {
+- this.entityData.set(ID_EFFECT_COLOR, PotionUtils.getColor(PotionUtils.getAllEffects(this.potion, this.effects)));
++ this.entityData.set(Arrow.ID_EFFECT_COLOR, PotionUtils.getColor((Collection) PotionUtils.getAllEffects(this.potion, this.effects)));
+ }
++
+ }
+
+ public void addEffect(MobEffectInstance effectInstance) {
+ this.effects.add(effectInstance);
+- this.getEntityData().set(ID_EFFECT_COLOR, PotionUtils.getColor(PotionUtils.getAllEffects(this.potion, this.effects)));
++ this.getEntityData().set(Arrow.ID_EFFECT_COLOR, PotionUtils.getColor((Collection) PotionUtils.getAllEffects(this.potion, this.effects)));
+ }
+
+ @Override
+ protected void defineSynchedData() {
+ super.defineSynchedData();
+- this.entityData.define(ID_EFFECT_COLOR, -1);
++ this.entityData.define(Arrow.ID_EFFECT_COLOR, -1);
+ }
+
+ @Override
+@@ -103,33 +120,36 @@
+ this.makeParticle(2);
+ }
+ } else if (this.inGround && this.inGroundTime != 0 && !this.effects.isEmpty() && this.inGroundTime >= 600) {
+- this.level().broadcastEntityEvent(this, (byte)0);
++ this.level().broadcastEntityEvent(this, (byte) 0);
+ this.potion = Potions.EMPTY;
+ this.effects.clear();
+- this.entityData.set(ID_EFFECT_COLOR, -1);
++ this.entityData.set(Arrow.ID_EFFECT_COLOR, -1);
+ }
++
+ }
+
+ private void makeParticle(int particleAmount) {
+- int color = this.getColor();
+- if (color != -1 && particleAmount > 0) {
+- double d = (double)(color >> 16 & 0xFF) / 255.0;
+- double d1 = (double)(color >> 8 & 0xFF) / 255.0;
+- double d2 = (double)(color >> 0 & 0xFF) / 255.0;
++ int j = this.getColor();
+
+- for (int i = 0; i < particleAmount; i++) {
+- this.level().addParticle(ParticleTypes.ENTITY_EFFECT, this.getRandomX(0.5), this.getRandomY(), this.getRandomZ(0.5), d, d1, d2);
++ if (j != -1 && particleAmount > 0) {
++ double d0 = (double) (j >> 16 & 255) / 255.0D;
++ double d1 = (double) (j >> 8 & 255) / 255.0D;
++ double d2 = (double) (j >> 0 & 255) / 255.0D;
++
++ for (int k = 0; k < particleAmount; ++k) {
++ this.level().addParticle(ParticleTypes.ENTITY_EFFECT, this.getRandomX(0.5D), this.getRandomY(), this.getRandomZ(0.5D), d0, d1, d2);
+ }
++
+ }
+ }
+
+ public int getColor() {
+- return this.entityData.get(ID_EFFECT_COLOR);
++ return (Integer) this.entityData.get(Arrow.ID_EFFECT_COLOR);
+ }
+
+- private void setFixedColor(int fixedColor) {
++ public void setFixedColor(int fixedColor) {
+ this.fixedColor = true;
+- this.entityData.set(ID_EFFECT_COLOR, fixedColor);
++ this.entityData.set(Arrow.ID_EFFECT_COLOR, fixedColor);
+ }
+
+ @Override
+@@ -144,14 +164,18 @@
+ }
+
+ if (!this.effects.isEmpty()) {
+- ListTag list = new ListTag();
++ ListTag nbttaglist = new ListTag();
++ Iterator iterator = this.effects.iterator();
+
+- for (MobEffectInstance mobEffectInstance : this.effects) {
+- list.add(mobEffectInstance.save(new CompoundTag()));
++ while (iterator.hasNext()) {
++ MobEffectInstance mobeffect = (MobEffectInstance) iterator.next();
++
++ nbttaglist.add(mobeffect.save(new CompoundTag()));
+ }
+
+- compound.put("custom_potion_effects", list);
++ compound.put("custom_potion_effects", nbttaglist);
+ }
++
+ }
+
+ @Override
+@@ -161,8 +185,12 @@
+ this.potion = PotionUtils.getPotion(compound);
+ }
+
+- for (MobEffectInstance mobEffectInstance : PotionUtils.getCustomEffects(compound)) {
+- this.addEffect(mobEffectInstance);
++ Iterator iterator = PotionUtils.getCustomEffects(compound).iterator();
++
++ while (iterator.hasNext()) {
++ MobEffectInstance mobeffect = (MobEffectInstance) iterator.next();
++
++ this.addEffect(mobeffect);
+ }
+
+ if (compound.contains("Color", 99)) {
+@@ -170,64 +198,69 @@
+ } else {
+ this.updateColor();
+ }
++
+ }
+
+ @Override
+ protected void doPostHurtEffects(LivingEntity living) {
+ super.doPostHurtEffects(living);
+- Entity effectSource = this.getEffectSource();
++ Entity entity = this.getEffectSource();
++ Iterator iterator = this.potion.getEffects().iterator();
+
+- for (MobEffectInstance mobEffectInstance : this.potion.getEffects()) {
+- living.addEffect(
+- new MobEffectInstance(
+- mobEffectInstance.getEffect(),
+- Math.max(mobEffectInstance.mapDuration(i -> i / 8), 1),
+- mobEffectInstance.getAmplifier(),
+- mobEffectInstance.isAmbient(),
+- mobEffectInstance.isVisible()
+- ),
+- effectSource
+- );
++ MobEffectInstance mobeffect;
++
++ while (iterator.hasNext()) {
++ mobeffect = (MobEffectInstance) iterator.next();
++ living.addEffect(new MobEffectInstance(mobeffect.getEffect(), Math.max(mobeffect.mapDuration((i) -> {
++ return i / 8;
++ }), 1), mobeffect.getAmplifier(), mobeffect.isAmbient(), mobeffect.isVisible()), entity, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ARROW); // CraftBukkit
+ }
+
+ if (!this.effects.isEmpty()) {
+- for (MobEffectInstance mobEffectInstance : this.effects) {
+- living.addEffect(mobEffectInstance, effectSource);
++ iterator = this.effects.iterator();
++
++ while (iterator.hasNext()) {
++ mobeffect = (MobEffectInstance) iterator.next();
++ living.addEffect(mobeffect, entity, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ARROW); // CraftBukkit
+ }
+ }
++
+ }
+
+ @Override
+ protected ItemStack getPickupItem() {
+- ItemStack itemStack = super.getPickupItem();
++ ItemStack itemstack = super.getPickupItem();
++
+ if (this.effects.isEmpty() && this.potion == Potions.EMPTY) {
+- return itemStack;
++ return itemstack;
+ } else {
+- PotionUtils.setPotion(itemStack, this.potion);
+- PotionUtils.setCustomEffects(itemStack, this.effects);
++ PotionUtils.setPotion(itemstack, this.potion);
++ PotionUtils.setCustomEffects(itemstack, this.effects);
+ if (this.fixedColor) {
+- itemStack.getOrCreateTag().putInt("CustomPotionColor", this.getColor());
++ itemstack.getOrCreateTag().putInt("CustomPotionColor", this.getColor());
+ }
+
+- return itemStack;
++ return itemstack;
+ }
+ }
+
+ @Override
+ public void handleEntityEvent(byte id) {
+ if (id == 0) {
+- int color = this.getColor();
+- if (color != -1) {
+- double d = (double)(color >> 16 & 0xFF) / 255.0;
+- double d1 = (double)(color >> 8 & 0xFF) / 255.0;
+- double d2 = (double)(color >> 0 & 0xFF) / 255.0;
++ int i = this.getColor();
+
+- for (int i = 0; i < 20; i++) {
+- this.level().addParticle(ParticleTypes.ENTITY_EFFECT, this.getRandomX(0.5), this.getRandomY(), this.getRandomZ(0.5), d, d1, d2);
++ if (i != -1) {
++ double d0 = (double) (i >> 16 & 255) / 255.0D;
++ double d1 = (double) (i >> 8 & 255) / 255.0D;
++ double d2 = (double) (i >> 0 & 255) / 255.0D;
++
++ for (int j = 0; j < 20; ++j) {
++ this.level().addParticle(ParticleTypes.ENTITY_EFFECT, this.getRandomX(0.5D), this.getRandomY(), this.getRandomZ(0.5D), d0, d1, d2);
+ }
+ }
+ } else {
+ super.handleEntityEvent(id);
+ }
++
+ }
+ }