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

[1.20.5] Remove uses of Event.Result and update events to have their own Result classes #588

Merged
merged 30 commits into from
May 25, 2024

Conversation

Shadows-of-Fire
Copy link
Contributor

@Shadows-of-Fire Shadows-of-Fire commented Jan 29, 2024

What

This PR is a work-in-progress for removing all uses of Event.Result from existing events. Changes to an individual event will be grouped into a single commit until the first pass is completed.

Why

Uses of the abstracted Event.Result enum induces the following readability issues:

  1. Result Naming - Currently, all results are named ALLOW / DEFAULT / DENY for any result-based event, even when this is not a very descriptive name.
  2. Result Documentation - The effects of an event result should be located in the definition of that enum value. Currently, this documentation lives in the class body.
  3. Result-Based Nature - It is not obvious to a reader what the impact of the @HasResult annotation are, and it is unexpected that the getResult / setResult methods exist on all children of Event.
    a. This is the same reason why @Cancellable was removed in Replace @Cancelable by ICancellableEvent interface & related changes Bus#20

There are also technical challenges with continuing to support the annotation-based model, since it means we must run a transformer to inject real implementations of getResult / setResult based on the presence of the annotation.

Progress

The following events need to be updated:

  • MouseButtonPressed.Post
  • MouseButtonReleased.Post
  • LivingPackSizeEvent renamed to SpawnClusterSizeEvent
  • MobEffectEvent.Applicable (Fixed a bug where this wouldn't fire for withers)
  • MobSpawnEvent.SpawnPlacementCheck
  • MobSpawnEvent.PositionCheck (Fixed a bug where the BaseSpawner wasn't getting passed through when applicable)
  • MobSpawnEvent.AllowDespawn renamed to MobDespawnEvent
  • ZombieEvent.SummonAidEvent removed. Supplanted by other events.
  • CriticalHitEvent
  • SleepingLocationCheckEvent (This and the below event have been fused to CanContinueSleepingEvent)
  • SleepingTimeCheckEvent
  • EntityMobGriefingEvent
  • BlockEvent.CreateFluidSourceEvent
  • CropGrowEvent.Pre
  • SaplingGrowTreeEvent renamed to BlockGrowFeatureEvent

Notes

Depends on neoforged/Bus#30 - this PR will not build locally or in CI unless using a version of Bus with this PR merged.

@Shadows-of-Fire Shadows-of-Fire self-assigned this Jan 29, 2024
@neoforged-pr-publishing
Copy link

neoforged-pr-publishing bot commented Jan 29, 2024

  • Publish PR to GitHub Packages

Last commit published: 84838162c2031b1ddcd2fbb11504245e6b1e6518.

PR Publishing

The artifacts published by this PR:

Repository Declaration

In order to use the artifacts published by the PR, add the following repository to your buildscript:

repositories {
    maven {
        name 'Maven for PR #588' // https://github.com/neoforged/NeoForge/pull/588
        url 'https://prmaven.neoforged.net/NeoForge/pr588'
        content {
            includeModule('net.neoforged', 'testframework')
            includeModule('net.neoforged', 'neoforge')
        }
    }
}

MDK installation

In order to setup a MDK using the latest PR version, run the following commands in a terminal.
The script works on both *nix and Windows as long as you have the JDK bin folder on the path.
The script will clone the MDK in a folder named NeoForge-pr588.
On Powershell you will need to remove the -L flag from the curl invocation.

mkdir NeoForge-pr588
cd NeoForge-pr588
curl -L https://prmaven.neoforged.net/NeoForge/pr588/net/neoforged/neoforge/20.6.108-beta-pr-588-rem-result/mdk-pr588.zip -o mdk.zip
jar xf mdk.zip
rm mdk.zip || del mdk.zip

To test a production environment, you can download the installer from here.

@Shadows-of-Fire Shadows-of-Fire marked this pull request as draft January 29, 2024 06:19
@Shadows-of-Fire Shadows-of-Fire added 1.20 Targeted at Minecraft 1.20 cleanup Change that isn't an enhancement or a bug fix breaking change Breaks binary compatibility labels Jan 29, 2024
@Shadows-of-Fire Shadows-of-Fire added this to the 20.5 Stable release milestone Feb 19, 2024
@Shadows-of-Fire Shadows-of-Fire added 1.20.5 Targeted at Minecraft 1.20.5 and removed 1.20 Targeted at Minecraft 1.20 labels Mar 3, 2024
@Shadows-of-Fire Shadows-of-Fire changed the base branch from 1.20.x to port/1.20.5 April 17, 2024 05:56
@Shadows-of-Fire Shadows-of-Fire changed the title [1.20.5] Remove uses of Event.Result [1.20.5] Remove uses of Event.Result and update events to have their own Result classes Apr 17, 2024
@Technici4n Technici4n deleted the branch neoforged:1.20.x April 23, 2024 20:23
@Technici4n Technici4n closed this Apr 23, 2024
@Shadows-of-Fire Shadows-of-Fire changed the base branch from port/1.20.5 to 1.20.x April 23, 2024 20:38
@Shadows-of-Fire
Copy link
Contributor Author

Still 92 compile errors. My original list is missing a few entries.

@Shadows-of-Fire
Copy link
Contributor Author

Shadows-of-Fire commented May 2, 2024

Remaining events:

  • FillBucketEvent Deleted. This is a very old event (circa 1.2.5) that is fully superseded by PlayerInteractEvent.RightClickItem with an item == Items.BUCKET check. It also has been erroneously firing for non-empty buckets for many MC versions (since at least 1.16)
  • PlayerSpawnPhantomsEvent
  • RenderNameTagEvent

@Shadows-of-Fire Shadows-of-Fire marked this pull request as ready for review May 3, 2024 04:26
@Minecraftschurli Minecraftschurli added 1.20.6 Targeted at Minecraft 1.20.6 and removed 1.20.5 Targeted at Minecraft 1.20.5 labels May 3, 2024
@Shadows-of-Fire Shadows-of-Fire requested a review from a team May 21, 2024 07:21
@Technici4n Technici4n added the last call Planned to be resolved by the end of the week, awaiting any last-minute comments label May 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.20.6 Targeted at Minecraft 1.20.6 breaking change Breaks binary compatibility cleanup Change that isn't an enhancement or a bug fix last call Planned to be resolved by the end of the week, awaiting any last-minute comments
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants