Skip to content

Commit

Permalink
Update NeoForge
Browse files Browse the repository at this point in the history
  • Loading branch information
Mgazul committed Dec 22, 2024
1 parent c6acb3d commit 88311bf
Show file tree
Hide file tree
Showing 100 changed files with 1,552 additions and 928 deletions.
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
Progress
------

- [x] Rectify NeoForge([**00f3f80ef9**](https://github.com/neoforged/NeoForge/commit/00f3f80ef9))
- [x] Rectify NeoForge([**b71b520e69**](https://github.com/neoforged/NeoForge/commit/b71b520e69))
- [ ] Start patch
* [x] Bukkit([**3339db16**](https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/commits/3339db16))
* [ ] CraftBukkit([**665900b91**](https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/commits/665900b91))
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ neoform_version=20241203.161809
neoforge_snapshot_next_stable=21.5

# renovate: net.neoforged.jst:jst-cli-bundle
jst_version=1.0.45
jst_version=1.0.67
legacyinstaller_version=3.0.+
# renovate: net.neoforged:AutoRenamingTool
art_version=2.0.3
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--- a/net/minecraft/client/gui/components/LogoRenderer.java
+++ b/net/minecraft/client/gui/components/LogoRenderer.java
@@ -15,8 +_,8 @@
public static final ResourceLocation MINECRAFT_EDITION = ResourceLocation.withDefaultNamespace("textures/gui/title/edition.png");
public static final int LOGO_WIDTH = 256;
public static final int LOGO_HEIGHT = 44;
- private static final int LOGO_TEXTURE_WIDTH = 256;
- private static final int LOGO_TEXTURE_HEIGHT = 64;
+ public static final int LOGO_TEXTURE_WIDTH = 256;
+ public static final int LOGO_TEXTURE_HEIGHT = 64;
private static final int EDITION_WIDTH = 128;
private static final int EDITION_HEIGHT = 14;
private static final int EDITION_TEXTURE_WIDTH = 128;
Original file line number Diff line number Diff line change
@@ -1,14 +1,95 @@
--- a/net/minecraft/client/gui/screens/worldselection/ExperimentsScreen.java
+++ b/net/minecraft/client/gui/screens/worldselection/ExperimentsScreen.java
@@ -62,6 +_,11 @@
@@ -35,15 +_,15 @@

@Override
protected void init() {
+ if (net.minecraft.world.flag.FeatureFlags.REGISTRY.hasAnyModdedFlags()) {
+ this.minecraft.setScreen(new net.neoforged.neoforge.client.gui.ScrollableExperimentsScreen(this.parent, this.packRepository, this.output));
+ return;
@OnlyIn(Dist.CLIENT)
public class ExperimentsScreen extends Screen {
- protected static final Component TITLE = Component.translatable("selectWorld.experiments");
- protected static final Component INFO = Component.translatable("selectWorld.experiments.info").withStyle(ChatFormatting.RED);
- protected static final int MAIN_CONTENT_WIDTH = 310;
+ private static final Component TITLE = Component.translatable("selectWorld.experiments");
+ private static final Component INFO = Component.translatable("selectWorld.experiments.info").withStyle(ChatFormatting.RED);
+ private static final int MAIN_CONTENT_WIDTH = 310;
private static final int SCROLL_AREA_MIN_HEIGHT = 130;
- protected final HeaderAndFooterLayout layout = new HeaderAndFooterLayout(this);
+ private final HeaderAndFooterLayout layout = new HeaderAndFooterLayout(this);
private final Screen parent;
private final PackRepository packRepository;
private final Consumer<PackRepository> output;
- protected final Object2BooleanMap<Pack> packs = new Object2BooleanLinkedOpenHashMap<>();
+ private final Object2BooleanMap<Pack> packs = new Object2BooleanLinkedOpenHashMap<>();
@Nullable
private ExperimentsScreen.ScrollArea scrollArea;

@@ -87,7 +_,7 @@
this.repositionElements();
}

- protected static Component getHumanReadableTitle(Pack p_270861_) {
+ private static Component getHumanReadableTitle(Pack p_270861_) {
String s = "dataPack." + p_270861_.getId() + ".name";
return (Component)(I18n.exists(s) ? Component.translatable(s) : p_270861_.getTitle());
}
@@ -111,7 +_,7 @@
this.minecraft.setScreen(this.parent);
}

- protected void onDone() {
+ private void onDone() {
List<Pack> list = new ArrayList<>(this.packRepository.getSelectedPacks());
List<Pack> list1 = new ArrayList<>();
this.packs.forEach((p_270540_, p_270780_) -> {
@@ -156,6 +_,8 @@
p_387127_.pose().pushPose();
p_387127_.pose().translate(0.0, -this.scrollAmount(), 0.0);

+ // Neo: work around interaction "hitbox" of buttons not moving when scrolling
+ p_386932_ = (int) (p_386932_ + this.scrollAmount());
for (AbstractWidget abstractwidget : this.children) {
abstractwidget.render(p_387127_, p_388038_, p_386932_, p_388026_);
}
@@ -188,6 +_,44 @@
this.setScrollAmount(this.scrollAmount() + (double)j + 14.0);
}
}
+ }
+
+ // Neo: work around interaction "hitbox" of buttons not moving when scrolling
+ @Override
+ public java.util.Optional<GuiEventListener> getChildAt(double p_94730_, double p_94731_) {
+ return super.getChildAt(p_94730_, p_94731_ + this.scrollAmount());
+ }
+
this.layout.addTitleHeader(TITLE, this.font);
LinearLayout linearlayout = this.layout.addToContents(LinearLayout.vertical());
linearlayout.addChild(new MultiLineTextWidget(INFO, this.font).setMaxWidth(310), p_293611_ -> p_293611_.paddingBottom(15));
+ // Neo: work around interaction "hitbox" of buttons not moving when scrolling
+ @Override
+ public boolean mouseClicked(double p_313764_, double p_313832_, int p_313688_) {
+ java.util.Optional<GuiEventListener> optional = this.getChildAt(p_313764_, p_313832_);
+ if (optional.isEmpty()) {
+ return false;
+ } else {
+ GuiEventListener guieventlistener = optional.get();
+ if (guieventlistener.mouseClicked(p_313764_, p_313832_ + this.scrollAmount(), p_313688_)) {
+ this.setFocused(guieventlistener);
+ if (p_313688_ == 0) {
+ this.setDragging(true);
+ }
+ }
+
+ return true;
+ }
+ }
+
+ // Neo: work around interaction "hitbox" of buttons not moving when scrolling
+ @Override
+ public boolean mouseReleased(double p_313886_, double p_313935_, int p_313751_) {
+ if (p_313751_ == 0 && this.isDragging()) {
+ this.setDragging(false);
+ if (this.getFocused() != null) {
+ return this.getFocused().mouseReleased(p_313886_, p_313935_ + this.scrollAmount(), p_313751_);
+ }
+ }
+
+ return this.getChildAt(p_313886_, p_313935_).filter(p_94708_ -> p_94708_.mouseReleased(p_313886_, p_313935_ + this.scrollAmount(), p_313751_)).isPresent();
}

@Override
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
new ClientPacketListener(
this.minecraft,
this.connection,
@@ -136,12 +_,19 @@
@@ -136,12 +_,20 @@
this.serverCookies,
this.chatState,
this.customReportDetails,
Expand All @@ -41,6 +41,7 @@
)
)
);
+ net.neoforged.neoforge.common.NeoForge.EVENT_BUS.post(new net.neoforged.neoforge.event.TagsUpdatedEvent(registryaccess$frozen, true, this.connection.isMemoryConnection()));
+ // Packets can only be sent after the outbound protocol is set up again
+ if (!this.initializedConnection && this.connectionType.isOther()) {
+ // Neo: Fallback detection for servers with a delayed brand payload (BungeeCord)
Expand Down
10 changes: 10 additions & 0 deletions patches/net/minecraft/client/renderer/LevelRenderer.java.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
--- a/net/minecraft/client/renderer/LevelRenderer.java
+++ b/net/minecraft/client/renderer/LevelRenderer.java
@@ -473,6 +_,9 @@
this.targets.entityOutline = framegraphbuilder.importExternal("entity_outline", this.entityOutlineTarget);
}

+ var setupEvent = net.neoforged.neoforge.client.ClientHooks.fireFrameGraphSetup(framegraphbuilder, this.targets, rendertargetdescriptor, frustum, p_109604_, p_254120_, p_323920_, p_348530_, profilerfiller);
+ flag2 |= setupEvent.isOutlineProcessingEnabled();
+
FramePass framepass = framegraphbuilder.addPass("clear");
this.targets.main = framepass.readsAndWrites(this.targets.main);
framepass.executes(() -> {
@@ -480,7 +_,7 @@
RenderSystem.clear(16640);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@
.create();
private final List<BlockElement> elements;
@Nullable
@@ -49,7 +_,14 @@
@@ -49,7 +_,15 @@
private UnbakedModel parent;
@Nullable
private final ResourceLocation parentLocation;
+ @Nullable
+ private final com.mojang.math.Transformation transformation;
+ private final com.mojang.math.Transformation rootTransform;
+ private final net.neoforged.neoforge.client.RenderTypeGroup renderTypeGroup;
+ private final java.util.Map<String, Boolean> partVisibility;

+ /**
+ * @deprecated Neo: use {@link net.neoforged.neoforge.client.model.UnbakedModelParser#parse(Reader)} instead
Expand All @@ -34,11 +35,11 @@
public static BlockModel fromStream(Reader p_111462_) {
return GsonHelper.fromJson(GSON, p_111462_, BlockModel.class);
}
@@ -62,12 +_,27 @@
@@ -62,12 +_,29 @@
@Nullable UnbakedModel.GuiLight p_387948_,
@Nullable ItemTransforms p_273480_
) {
+ this(p_273263_, p_272668_, p_386899_, p_272676_, p_387948_, p_273480_, null, net.neoforged.neoforge.client.RenderTypeGroup.EMPTY);
+ this(p_273263_, p_272668_, p_386899_, p_272676_, p_387948_, p_273480_, null, net.neoforged.neoforge.client.RenderTypeGroup.EMPTY, java.util.Map.of());
+ }
+
+ public BlockModel(
Expand All @@ -48,17 +49,19 @@
+ @Nullable Boolean p_272676_,
+ @Nullable UnbakedModel.GuiLight p_387948_,
+ @Nullable ItemTransforms p_273480_,
+ @Nullable com.mojang.math.Transformation transformation,
+ net.neoforged.neoforge.client.RenderTypeGroup renderTypeGroup
+ @Nullable com.mojang.math.Transformation rootTransform,
+ net.neoforged.neoforge.client.RenderTypeGroup renderTypeGroup,
+ java.util.Map<String, Boolean> partVisibility
+ ) {
this.elements = p_272668_;
this.hasAmbientOcclusion = p_272676_;
this.guiLight = p_387948_;
this.textureSlots = p_386899_;
this.parentLocation = p_273263_;
this.transforms = p_273480_;
+ this.transformation = transformation;
+ this.rootTransform = rootTransform;
+ this.renderTypeGroup = renderTypeGroup;
+ this.partVisibility = partVisibility;
}

@Nullable
Expand All @@ -78,42 +81,31 @@
}

@Nullable
@@ -125,6 +_,16 @@
@@ -125,6 +_,13 @@
return this.parentLocation;
}

+ @Override
+ public void fillAdditionalProperties(net.minecraft.util.context.ContextMap.Builder propertiesBuilder) {
+ if (this.transformation != null) {
+ propertiesBuilder.withParameter(net.neoforged.neoforge.client.model.NeoForgeModelProperties.TRANSFORM, this.transformation);
+ }
+ if (!this.renderTypeGroup.isEmpty()) {
+ propertiesBuilder.withParameter(net.neoforged.neoforge.client.model.NeoForgeModelProperties.RENDER_TYPE, this.renderTypeGroup);
+ }
+ net.neoforged.neoforge.client.model.NeoForgeModelProperties.fillRootTransformProperty(propertiesBuilder, this.rootTransform);
+ net.neoforged.neoforge.client.model.NeoForgeModelProperties.fillRenderTypeProperty(propertiesBuilder, this.renderTypeGroup);
+ net.neoforged.neoforge.client.model.NeoForgeModelProperties.fillPartVisibilityProperty(propertiesBuilder, this.partVisibility);
+ }
+
@OnlyIn(Dist.CLIENT)
public static class Deserializer implements JsonDeserializer<BlockModel> {
public BlockModel deserialize(JsonElement p_111498_, Type p_111499_, JsonDeserializationContext p_111500_) throws JsonParseException {
@@ -145,7 +_,20 @@
@@ -145,7 +_,12 @@
}

ResourceLocation resourcelocation = s.isEmpty() ? null : ResourceLocation.parse(s);
- return new BlockModel(resourcelocation, list, textureslots$data, obool, unbakedmodel$guilight, itemtransforms);
+
+ com.mojang.math.Transformation rootTransform = null;
+ if (jsonobject.has("transform")) {
+ JsonElement transform = jsonobject.get("transform");
+ rootTransform = p_111500_.deserialize(transform, com.mojang.math.Transformation.class);
+ }
+ var rootTransform = net.neoforged.neoforge.client.model.NeoForgeModelProperties.deserializeRootTransform(jsonobject, p_111500_);
+ var renderTypeGroup = net.neoforged.neoforge.client.model.NeoForgeModelProperties.deserializeRenderType(jsonobject);
+ var partVisibility = net.neoforged.neoforge.client.model.NeoForgeModelProperties.deserializePartVisibility(jsonobject);
+
+ var renderTypeGroup = net.neoforged.neoforge.client.RenderTypeGroup.EMPTY;
+ if (jsonobject.has("render_type")) {
+ var renderTypeHintName = GsonHelper.getAsString(jsonobject, "render_type");
+ renderTypeGroup = net.neoforged.neoforge.client.NamedRenderTypeManager.get(ResourceLocation.parse(renderTypeHintName));
+ }
+
+ return new BlockModel(resourcelocation, list, textureslots$data, obool, unbakedmodel$guilight, itemtransforms, rootTransform, renderTypeGroup);
+ return new BlockModel(resourcelocation, list, textureslots$data, obool, unbakedmodel$guilight, itemtransforms, rootTransform, renderTypeGroup, partVisibility);
}

private TextureSlots.Data getTextureMap(JsonObject p_111510_) {
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
int p_371309_,
@Nullable ResourceLocation p_371639_
) {
+ p_371731_ = getArmorModelHook(p_371670_, p_387484_, p_371731_);
+ net.neoforged.neoforge.client.extensions.common.IClientItemExtensions extensions = net.neoforged.neoforge.client.extensions.common.IClientItemExtensions.of(p_371670_);
+ p_371731_ = extensions.getGenericArmorModel(p_371670_, p_387484_, p_371731_);
List<EquipmentClientInfo.Layer> list = this.equipmentAssets.get(p_387603_).getLayers(p_387484_);
if (!list.isEmpty()) {
- int i = p_371670_.is(ItemTags.DYEABLE) ? DyedItemColor.getOrDefault(p_371670_, 0) : 0;
+ net.neoforged.neoforge.client.extensions.common.IClientItemExtensions extensions = net.neoforged.neoforge.client.extensions.common.IClientItemExtensions.of(p_371670_);
+ int i = extensions.getDefaultDyeColor(p_371670_);
boolean flag = p_371670_.hasFoil();

Expand All @@ -29,17 +29,3 @@
}

ArmorTrim armortrim = p_371670_.get(DataComponents.TRIM);
@@ -100,6 +_,13 @@
} else {
return -1;
}
+ }
+
+ /**
+ * Hook to allow item-sensitive armor model. for HumanoidArmorLayer.
+ */
+ protected net.minecraft.client.model.Model getArmorModelHook(ItemStack itemStack, EquipmentClientInfo.LayerType layerType, Model model) {
+ return net.neoforged.neoforge.client.ClientHooks.getArmorModel(itemStack, layerType, model);
}

@OnlyIn(Dist.CLIENT)
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
+ int[] aint = itemstackrenderstate$layerrenderstate.prepareTintLayers(tints.length);
+ System.arraycopy(tints, 0, aint, 0, tints.length);
+
+ itemstackrenderstate$layerrenderstate.setupBlockModel(this.model, pass.getRenderType(p_386443_));
+ itemstackrenderstate$layerrenderstate.setupBlockModel(pass, pass.getRenderType(p_386443_));
+ });
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
void render(PoseStack p_387607_, MultiBufferSource p_386763_, int p_387589_, int p_388775_) {
p_387607_.pushPose();
+ if (model != null)
+ net.neoforged.neoforge.client.ClientHooks.handleCameraTransforms(p_387607_, model, displayContext, ItemStackRenderState.this.isLeftHand);
+ model.applyTransform(displayContext, p_387607_, ItemStackRenderState.this.isLeftHand);
+ else
this.transform().apply(ItemStackRenderState.this.isLeftHand, p_387607_);
p_387607_.translate(-0.5F, -0.5F, -0.5F);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,12 @@
}

public static Map<Block, SpecialModelRenderer<?>> createBlockRenderers(EntityModelSet p_387779_) {
@@ -179,6 +_,8 @@
map.put(Blocks.CHEST, GIFT_CHEST);
map.put(Blocks.TRAPPED_CHEST, GIFT_CHEST);
}
+
+ net.neoforged.fml.ModLoader.postEvent(new net.neoforged.neoforge.client.event.RegisterSpecialBlockModelRendererEvent(map));

Builder<Block, SpecialModelRenderer<?>> builder = ImmutableMap.builder();
map.forEach((p_386808_, p_388898_) -> {
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
+ }
+
+ @Override
+ public BakedModel applyTransform(net.minecraft.world.item.ItemDisplayContext transformType, com.mojang.blaze3d.vertex.PoseStack poseStack, boolean applyLeftHandTransform) {
+ return this.parent.applyTransform(transformType, poseStack, applyLeftHandTransform);
+ public void applyTransform(net.minecraft.world.item.ItemDisplayContext transformType, com.mojang.blaze3d.vertex.PoseStack poseStack, boolean applyLeftHandTransform) {
+ this.parent.applyTransform(transformType, poseStack, applyLeftHandTransform);
+ }
+
+ @Override
Expand Down
Loading

0 comments on commit 88311bf

Please sign in to comment.