Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Give command's "Fake" Entity assigning is too late #1984

Open
Soaryn opened this issue Mar 1, 2025 · 1 comment
Open

Give command's "Fake" Entity assigning is too late #1984

Soaryn opened this issue Mar 1, 2025 · 1 comment
Labels
1.21.1 Targeted at Minecraft 1.21.1 1.21.2 Targeted at Minecraft 1.21.2 1.21.3 Targeted at Minecraft 1.21.3 1.21.4 Targeted at Minecraft 1.21.4 bug A bug or error vanilla bug A bug or error in the base Minecraft game

Comments

@Soaryn
Copy link
Contributor

Soaryn commented Mar 1, 2025

Minecraft Version: 1.21.4 (valid to at least 1.20.1)

NeoForge Version: 21.4.75-beta

Steps to Reproduce:

  1. Set a break point in GiveCommand around line 70
  2. In game /give @s cobblestone 128 This should give the player 2 stacks of cobble, but notice that the "fake" entity is being initialized at the break point.
  3. Because the construction, post of events, and handling of cancellations all happen before the entity is told it is fake, event consumers will misfire.

Description of issue:
Typical use of EntityJoinLevelEvent is to cut down on entity object churn when collecting items from say a mob farm. Canceling this event basically does just that; however, the give command creates "fake" entities when the player absorbs all of the command's items. We need a different way to either inform the consuming events that the entity is fake, or determine if the vanilla "fake item" for a single tick is a bug/feature.

Reference for problem:
Soaryn/XyCraftTracker#81

@Soaryn Soaryn added the triage Needs triaging and confirmation label Mar 1, 2025
@ChampionAsh5357 ChampionAsh5357 added bug A bug or error vanilla bug A bug or error in the base Minecraft game 1.21.1 Targeted at Minecraft 1.21.1 1.21.2 Targeted at Minecraft 1.21.2 1.21.3 Targeted at Minecraft 1.21.3 1.21.4 Targeted at Minecraft 1.21.4 and removed triage Needs triaging and confirmation labels Mar 2, 2025
@ChampionAsh5357
Copy link
Contributor

The main issue from what I can see is that the ItemEntity sets all of its 'fake' settings after the entity has already been added to the world. If it was set beforehand, it would be relatively simple to just check if the pickupDelay is 32767, assuming that mods don't want call setNeverPickUp at any other point. Though it wouldn't be difficult to add another field that holds the true value in case that assumption is violated.

As for setting the fake item after being added to the world, I don't really see a reason why it couldn't be marked beforehand as the entity wouldn't be ticked before the method was called. The only reason I can see of why its set afterward is because its using the common ServerPlayer#createItemStackToDrop to construct the stack.

How to necessarily do such a thing is a point of contention. Capturing the 'fakeness' is possible if we use a ThreadLocal due to chunk load async. Another method would be to patch in a new drop method take contains a boolean on whether it's fake or not, though it's use case is only limited to the give command.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.21.1 Targeted at Minecraft 1.21.1 1.21.2 Targeted at Minecraft 1.21.2 1.21.3 Targeted at Minecraft 1.21.3 1.21.4 Targeted at Minecraft 1.21.4 bug A bug or error vanilla bug A bug or error in the base Minecraft game
Projects
None yet
Development

No branches or pull requests

2 participants