mojira.dev
MC-107941

Shooting, summoning or editing an arrow and reloading the world gives potion particles

The bug

I shot a regular arrow on the ground and reloaded my world, the arrow now has particles as if it's a tipped arrow, yet when I pick up the arrow it gives a regular arrow.

Code analysis

Based on 1.11.2 decompiled using MCP 9.35 rc1

The Color tag is only written if the arrow has a custom color. The problem is that the game calls the method net.minecraft.entity.projectile.EntityTippedArrow.refreshColor() when an arrow without Color tag is loaded. This method sets the color to the water color.
This could be fixed by always writing the Color tag to make sure tipped water arrows keep their particles as well. Additionally the check if the Color tag exists when reading the NBT data can be removed then.

Linked issues

MC-107969 No gravity arrows Resolved MC-111533 Arrow has water potion when summoned or updated Resolved MC-111730 Arrows turn into potion arrows with no effect when unloaded Resolved MC-111804 Normal arrows look into arrows of water breathing after relogging Resolved MC-112036 Arrows with NoAI tag gain a blue particle effect Resolved

Attachments

Comments 23

Simply summoning an arrow also gives it particules, and without having to reload the world.

Back in 16w50a. Possibly related to MC-108943.

Confirmed for 17w06a

Confirmed for 17w17a.

Editing the NBTdata of an arrow using /entitydata also triggeres this bug. (1.11.2)

13 more comments

Easy fix to summon arrow with no particles!!!
summon arrow ~ ~ ~ {Color:-1}
If you set the color value to -1 the particles are invisible, no worries anymore 😃

They can fix this bug by giving it that value as default

Can confirm for 1.13.2 release and 1.14 snapshot 18w43c.

Affects all 1.14 snapshots even without exiting the world first.

Daniel Burnett

There's a more specific bit of code at the root of this bug. (Basing this off the source of 1.12.2.) When writing an arrow entity to NBT (i.e. on save or when modifying the data), it only writes the color tag if its fixedColor property is true. This property is only set in the setFixedColor and refreshColor methods, the latter of which sets the color to the default blue. This means that for normal arrows, it's false by default, and will never be written to NBT data; so when it reloads, the color tag isn't there, and it's refreshed to blue.

 

The fix to this is quite simple, and requires only two small changes. In the tipped arrow entity's setPotionEffect method, instead of setting the color directly on the data manager, it should call setFixedColor to do this, which will then set the boolean flag properly and allow -1 to be written with the arrow's NBT, fixing the issue for bow-fired arrows.

The second change is to fix the issue for dispenser-fired arrows. In the registerDispenserBehaviors method of the Bootstrap class, when it registers the arrow behaviors for normal arrows, it just needs to call entitytippedarrow.setFixedColor(-1) somewhere between creating the entity and returning it. (The method is currently private, as is the flag, so this would need to actually call a new setter or just make the setFixedColor method public.)

Those small changes should fix this long-standing bug for good 🙂

Can confirm for all versions 1.14

JohnStar128

Erik Broes

Confirmed

(Unassigned)

arrow, potion, relog, water

Minecraft 16w39b, Minecraft 16w39c, Minecraft 16w50a, Minecraft 1.11.2, Minecraft 17w06a, ..., Minecraft 19w12b, Minecraft 19w13b, Minecraft 19w14a, Minecraft 19w14b, 1.14.4

Minecraft 16w40a, 19w35a

Retrieved