Skip to content

Commit

Permalink
Merge branch '1.21.x' into ToolActionRename
Browse files Browse the repository at this point in the history
  • Loading branch information
Matyrobbrt authored Jun 24, 2024
2 parents c6c0d00 + 28d0463 commit c3896d3
Show file tree
Hide file tree
Showing 70 changed files with 1,608 additions and 835 deletions.
22 changes: 15 additions & 7 deletions .github/workflows/build-prs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,31 @@ jobs:
run:
git switch -C pr-${{ github.event.pull_request.number }}-${{ github.event.pull_request.head.ref }}

- name: Validate wrapper
uses: gradle/actions/wrapper-validation@v3

- name: Setup JDK 21
uses: actions/setup-java@v2
with:
java-version: '21'
distribution: 'temurin'

- name: Setup with Gradle
uses: gradle/gradle-build-action@v2
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
with:
arguments: setup
cache-read-only: false

- name: Setup with Gradle
run: ./gradlew setup

- name: Build with Gradle
uses: gradle/gradle-build-action@v2
with:
arguments: assemble checkFormatting
cache-read-only: false
run: ./gradlew assemble checkFormatting

- name: Run JCC
run: ./gradlew checkJarCompatibility

- name: Upload JCC
uses: neoforged/action-jar-compatibility/upload@v1

- name: Publish artifacts
uses: neoforged/action-pr-publishing/upload@v1
48 changes: 48 additions & 0 deletions .github/workflows/check-local-changes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Check PR local changes

on:
pull_request:
types:
- synchronize
- opened
- ready_for_review
- reopened

jobs:
check-local-changes:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1000
fetch-tags: true

# GradleUtils will append the branch name to the version,
# but for that we need a properly checked out branch
- name: Create branch for commit
run:
git switch -C pr-${{ github.event.pull_request.number }}-${{ github.event.pull_request.head.ref }}

- name: Setup JDK 21
uses: actions/setup-java@v2
with:
java-version: '21'
distribution: 'temurin'

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
with:
cache-read-only: false

- name: Setup with Gradle
run: ./gradlew setup

- name: Run datagen with Gradle
run: ./gradlew :neoforge:runData :tests:runData

- name: Check no local changes are present
run: |
# Print status for easier debugging
git status
if [ -n "$(git status --porcelain)" ]; then exit 1; fi
20 changes: 20 additions & 0 deletions .github/workflows/publish-jcc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# File generated by the GradleUtils `setupGitHubActionsWorkflows` task, avoid modifying it directly
# The template can be found at https://github.com/neoforged/GradleUtils/blob/a65628b0c89dec60b357ce3f8f6bfa62934b8357/src/actionsTemplate/resources/.github/workflows/publish-jcc.yml

name: Publish PR JCC output

on:
workflow_run:
workflows: [Build PRs]
types:
- completed

jobs:
publish-jcc:
if: true
uses: neoforged/actions/.github/workflows/publish-jcc.yml@main
with:
beta_version_pattern: .*-beta.*
secrets:
JCC_GH_APP_ID: ${{ secrets.JCC_GH_APP_ID }}
JCC_GH_APP_KEY: ${{ secrets.JCC_GH_APP_KEY }}
18 changes: 7 additions & 11 deletions .github/workflows/test-prs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,19 @@ jobs:
java-version: '21'
distribution: 'temurin'

- name: Setup with Gradle
uses: gradle/gradle-build-action@v2
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
with:
arguments: setup
cache-read-only: false

- name: Setup with Gradle
run: ./gradlew setup

- name: Run game tests with Gradle
uses: gradle/gradle-build-action@v2
with:
arguments: :tests:runGameTestServer
cache-read-only: false
run: ./gradlew :tests:runGameTestServer

- name: Run JUnit tests with Gradle
uses: gradle/gradle-build-action@v2
with:
arguments: :tests:runUnitTests
cache-read-only: false
run: ./gradlew :tests:runUnitTests

- name: Store reports
if: failure()
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import java.util.regex.Matcher
import java.util.regex.Pattern

plugins {
id 'net.neoforged.gradleutils' version '3.0.0-alpha.10' apply false
id 'net.neoforged.gradleutils' version '3.0.0-alpha.13' apply false
id 'com.diffplug.spotless' version '6.22.0' apply false
id 'net.neoforged.licenser' version '0.7.2'
id 'neoforge.formatting-conventions'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
--- a/net/minecraft/advancements/critereon/ItemAttributeModifiersPredicate.java
+++ b/net/minecraft/advancements/critereon/ItemAttributeModifiersPredicate.java
@@ -40,6 +_,14 @@
return !this.modifiers.isPresent() || this.modifiers.get().test(p_341374_.modifiers());
}

+ /**
+ * Neo: Override this method to reflect gameplay attribute modifiers instead of only NBT modifiers.
+ */
+ @Override
+ public boolean matches(ItemStack p_333958_) {
+ return matches(p_333958_, p_333958_.getAttributeModifiers());
+ }
+
public static record EntryPredicate(
Optional<HolderSet<Attribute>> attribute,
Optional<ResourceLocation> id,
53 changes: 48 additions & 5 deletions patches/net/minecraft/client/Camera.java.patch
Original file line number Diff line number Diff line change
@@ -1,6 +1,31 @@
--- a/net/minecraft/client/Camera.java
+++ b/net/minecraft/client/Camera.java
@@ -61,7 +_,7 @@
@@ -42,6 +_,7 @@
private float eyeHeightOld;
private float partialTickTime;
public static final float FOG_DISTANCE_SCALE = 0.083333336F;
+ private float roll;

public void setup(BlockGetter p_90576_, Entity p_90577_, boolean p_90578_, boolean p_90579_, float p_90580_) {
this.initialized = true;
@@ -49,7 +_,10 @@
this.entity = p_90577_;
this.detached = p_90578_;
this.partialTickTime = p_90580_;
- this.setRotation(p_90577_.getViewYRot(p_90580_), p_90577_.getViewXRot(p_90580_));
+ var cameraSetup = net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.client.event.ViewportEvent.ComputeCameraAngles(
+ this, p_90580_, p_90577_.getViewYRot(p_90580_), p_90577_.getViewXRot(p_90580_), 0)
+ );
+ this.setRotation(cameraSetup.getYaw(), cameraSetup.getPitch(), cameraSetup.getRoll());
this.setPosition(
Mth.lerp((double)p_90580_, p_90577_.xo, p_90577_.getX()),
Mth.lerp((double)p_90580_, p_90577_.yo, p_90577_.getY()) + (double)Mth.lerp(p_90580_, this.eyeHeightOld, this.eyeHeight),
@@ -57,11 +_,11 @@
);
if (p_90578_) {
if (p_90579_) {
- this.setRotation(this.yRot + 180.0F, -this.xRot);
+ this.setRotation(this.yRot + 180.0F, -this.xRot, -this.roll);
}

float f = p_90577_ instanceof LivingEntity livingentity ? livingentity.getScale() : 1.0F;
Expand All @@ -9,15 +34,33 @@
} else if (p_90577_ instanceof LivingEntity && ((LivingEntity)p_90577_).isSleeping()) {
Direction direction = ((LivingEntity)p_90577_).getBedOrientation();
this.setRotation(direction != null ? direction.toYRot() - 180.0F : 0.0F, 0.0F);
@@ -221,6 +_,18 @@
@@ -102,10 +_,17 @@
this.setPosition(new Vec3(this.position.x + (double)vector3f.x, this.position.y + (double)vector3f.y, this.position.z + (double)vector3f.z));
}

+ /** @deprecated Neo: call {@link #setRotation(float, float, float)} instead */
+ @Deprecated
protected void setRotation(float p_90573_, float p_90574_) {
+ setRotation(p_90573_, p_90574_, 0F);
+ }
+
+ protected void setRotation(float p_90573_, float p_90574_, float roll) {
this.xRot = p_90574_;
this.yRot = p_90573_;
- this.rotation.rotationYXZ((float) Math.PI - p_90573_ * (float) (Math.PI / 180.0), -p_90574_ * (float) (Math.PI / 180.0), 0.0F);
+ this.roll = roll;
+ this.rotation.rotationYXZ((float) Math.PI - p_90573_ * (float) (Math.PI / 180.0), -p_90574_ * (float) (Math.PI / 180.0), -roll * (float) (Math.PI / 180.0));
FORWARDS.rotate(this.rotation, this.forwards);
UP.rotate(this.rotation, this.up);
LEFT.rotate(this.rotation, this.left);
@@ -221,6 +_,17 @@

public float getPartialTickTime() {
return this.partialTickTime;
+ }
+
+ public void setAnglesInternal(float yaw, float pitch) {
+ this.yRot = yaw;
+ this.xRot = pitch;
+ public float getRoll() {
+ return this.roll;
+ }
+
+ public net.minecraft.world.level.block.state.BlockState getBlockAtCamera() {
Expand Down
10 changes: 5 additions & 5 deletions patches/net/minecraft/client/gui/Gui.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@
+
@OnlyIn(Dist.CLIENT)
public class Gui {
protected static final ResourceLocation CROSSHAIR_SPRITE = ResourceLocation.withDefaultNamespace("hud/crosshair");
private static final ResourceLocation CROSSHAIR_SPRITE = ResourceLocation.withDefaultNamespace("hud/crosshair");
@@ -158,9 +_,21 @@
protected long healthBlinkTime;
protected float autosaveIndicatorValue;
protected float lastAutosaveIndicatorValue;
private long healthBlinkTime;
private float autosaveIndicatorValue;
private float lastAutosaveIndicatorValue;
+ /** Neo: This is empty and unused, rendering goes through {@link #layerManager} instead. */
+ @Deprecated
private final LayeredDraw layers = new LayeredDraw();
+ private final net.neoforged.neoforge.client.gui.GuiLayerManager layerManager = new net.neoforged.neoforge.client.gui.GuiLayerManager();
protected float scopeScale;
private float scopeScale;

+ /**
+ * Neo: This variable controls the height of overlays on the left of the hotbar (e.g. health, armor).
Expand Down
8 changes: 0 additions & 8 deletions patches/net/minecraft/client/player/LocalPlayer.java.patch
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
--- a/net/minecraft/client/player/LocalPlayer.java
+++ b/net/minecraft/client/player/LocalPlayer.java
@@ -161,6 +_,7 @@

@Override
public boolean hurt(DamageSource p_108662_, float p_108663_) {
+ net.neoforged.neoforge.common.CommonHooks.onPlayerAttack(this, p_108662_, p_108663_);
return false;
}

@@ -297,6 +_,7 @@
ServerboundPlayerActionPacket.Action serverboundplayeractionpacket$action = p_108701_
? ServerboundPlayerActionPacket.Action.DROP_ALL_ITEMS
Expand Down
10 changes: 0 additions & 10 deletions patches/net/minecraft/client/player/RemotePlayer.java.patch

This file was deleted.

28 changes: 15 additions & 13 deletions patches/net/minecraft/client/renderer/GameRenderer.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -52,26 +52,28 @@
RenderSystem.applyModelViewMatrix();
Lighting.setupFor3DItems();
GuiGraphics guigraphics = new GuiGraphics(this.minecraft, this.renderBuffers.bufferSource());
@@ -1079,7 +_,7 @@
@@ -1070,7 +_,8 @@

if (this.minecraft.getOverlay() != null) {
try {
- this.minecraft.getOverlay().render(guigraphics, i, j, p_348648_.getRealtimeDeltaTicks());
+ // Neo: Fix https://bugs.mojang.com/browse/MC-273464
+ this.minecraft.getOverlay().render(guigraphics, i, j, p_348648_.getGameTimeDeltaPartialTick(false));
} catch (Throwable throwable2) {
CrashReport crashreport = CrashReport.forThrowable(throwable2, "Rendering overlay");
CrashReportCategory crashreportcategory = crashreport.addCategory("Overlay render details");
@@ -1079,7 +_,9 @@
}
} else if (flag && this.minecraft.screen != null) {
try {
- this.minecraft.screen.renderWithTooltip(guigraphics, i, j, p_348648_.getRealtimeDeltaTicks());
+ net.neoforged.neoforge.client.ClientHooks.drawScreen(this.minecraft.screen, guigraphics, i, j, this.minecraft.getTimer().getRealtimeDeltaTicks());
+ // Neo: Wrap Screen#render to allow for GUI Layers and ScreenEvent.Render.[Pre/Post]
+ // Also fixes https://bugs.mojang.com/browse/MC-273464
+ net.neoforged.neoforge.client.ClientHooks.drawScreen(this.minecraft.screen, guigraphics, i, j, p_348648_.getGameTimeDeltaPartialTick(false));
} catch (Throwable throwable1) {
CrashReport crashreport1 = CrashReport.forThrowable(throwable1, "Rendering screen");
CrashReportCategory crashreportcategory1 = crashreport1.addCategory("Screen render details");
@@ -1253,12 +_,18 @@
}

this.resetProjectionMatrix(matrix4f);
+ net.neoforged.neoforge.client.event.ViewportEvent.ComputeCameraAngles cameraSetup = net.neoforged.neoforge.client.ClientHooks.onCameraSetup(this, camera, f);
+ camera.setAnglesInternal(cameraSetup.getYaw(), cameraSetup.getPitch());
Quaternionf quaternionf = camera.rotation().conjugate(new Quaternionf());
Matrix4f matrix4f1 = new Matrix4f().rotation(quaternionf);
+ // Neo: Use matrix multiplication so roll is stacked on top of vanilla XY rotations
+ matrix4f1 = new Matrix4f().rotationZ(cameraSetup.getRoll() * (float) (Math.PI / 180.0)).mul(matrix4f1);
this.minecraft
@@ -1259,6 +_,8 @@
.levelRenderer
.prepareCullFrustum(camera.getPosition(), matrix4f1, this.getProjectionMatrix(Math.max(d0, (double)this.minecraft.options.fov().get().intValue())));
this.minecraft.levelRenderer.renderLevel(p_348589_, flag, camera, this, this.lightTexture, matrix4f1, matrix4f);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,28 @@
this.thirdPersonLeftHand = p_111798_;
this.thirdPersonRightHand = p_111799_;
this.firstPersonLeftHand = p_111800_;
@@ -64,6 +_,7 @@
@@ -64,9 +_,21 @@
this.gui = p_111803_;
this.ground = p_111804_;
this.fixed = p_111805_;
+ this.moddedTransforms = moddedTransforms;
}

public ItemTransform getTransform(ItemDisplayContext p_270619_) {
+ if (p_270619_.isModded()) {
+ ItemTransform moddedTransform = moddedTransforms.get(p_270619_);
+ if (moddedTransform != null) {
+ return moddedTransform;
+ }
+ ItemDisplayContext moddedFallback = p_270619_.fallback();
+ if (moddedFallback == null) {
+ return ItemTransform.NO_TRANSFORM;
+ }
+ p_270619_ = moddedFallback;
+ }
return switch (p_270619_) {
case THIRD_PERSON_LEFT_HAND -> this.thirdPersonLeftHand;
case THIRD_PERSON_RIGHT_HAND -> this.thirdPersonRightHand;
@@ -104,9 +_,23 @@
ItemTransform itemtransform5 = this.getTransform(p_111822_, jsonobject, ItemDisplayContext.GUI);
ItemTransform itemtransform6 = this.getTransform(p_111822_, jsonobject, ItemDisplayContext.GROUND);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
BlockPos p_112459_, BlockState p_112460_, PoseStack p_112461_, MultiBufferSource p_112462_, Level p_112463_, boolean p_112464_, int p_112465_
) {
+ if (true) {
+ net.neoforged.neoforge.client.ClientHooks.renderPistonMovedBlocks(p_112459_, p_112460_, p_112461_, p_112462_, p_112463_, p_112464_, p_112465_, blockRenderer == null ? blockRenderer = net.minecraft.client.Minecraft.getInstance().getBlockRenderer() : blockRenderer);
+ net.neoforged.neoforge.client.ClientHooks.renderPistonMovedBlocks(p_112459_, p_112460_, p_112461_, p_112462_, p_112463_, p_112464_, p_112465_, blockRenderer);
+ return;
+ }
RenderType rendertype = ItemBlockRenderTypes.getMovingBlockRenderType(p_112460_);
Expand Down
4 changes: 2 additions & 2 deletions patches/net/minecraft/core/Holder.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
+ return null;
+ }
+
public void bindTags(Collection<TagKey<T>> p_205770_) {
void bindTags(Collection<TagKey<T>> p_205770_) {
this.tags = Set.copyOf(p_205770_);
}
@@ -233,6 +_,28 @@
Expand Down Expand Up @@ -51,5 +51,5 @@
+
+ // Neo End

public static enum Type {
protected static enum Type {
STAND_ALONE,
2 changes: 1 addition & 1 deletion patches/net/minecraft/core/HolderSet.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
int size();
@@ -174,6 +_,9 @@

public void bind(List<Holder<T>> p_205836_) {
void bind(List<Holder<T>> p_205836_) {
this.contents = List.copyOf(p_205836_);
+ for (Runnable runnable : this.invalidationCallbacks) {
+ runnable.run(); // FORGE: invalidate listeners when tags rebind
Expand Down
Loading

0 comments on commit c3896d3

Please sign in to comment.