Skip to content

Commit

Permalink
Merge branch '1.21.x' into 1.21-water-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
TelepathicGrunt authored Nov 11, 2024
2 parents 6ca62c5 + c71b646 commit ff12e90
Show file tree
Hide file tree
Showing 30 changed files with 495 additions and 346 deletions.
10 changes: 9 additions & 1 deletion patches/net/minecraft/client/color/item/ItemColors.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

public static ItemColors createDefault(BlockColors p_92684_) {
ItemColors itemcolors = new ItemColors();
@@ -101,17 +_,20 @@
@@ -101,17 +_,28 @@
(p_359075_, p_359076_) -> p_359076_ == 0 ? -1 : ARGB.opaque(p_359075_.getOrDefault(DataComponents.MAP_COLOR, MapItemColor.DEFAULT).rgb()),
Items.FILLED_MAP
);
Expand All @@ -24,6 +24,14 @@
return itemcolor == null ? -1 : itemcolor.getColor(p_92677_, p_92678_);
}

+ /**
+ * Neo: returns the color handler for the given {@code item}, or {@code null} if one isn't registered.
+ */
+ @org.jetbrains.annotations.Nullable
+ public ItemColor get(Item item) {
+ return itemColors.get(item);
+ }
+
+ /** @deprecated Register via {@link net.neoforged.neoforge.client.event.RegisterColorHandlersEvent.Item} */
+ @Deprecated
public void register(ItemColor p_92690_, ItemLike... p_92691_) {
Expand Down
44 changes: 40 additions & 4 deletions patches/net/minecraft/client/gui/Font.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,48 @@
private static final float EFFECT_DEPTH = 0.01F;
private static final Vector3f SHADOW_OFFSET = new Vector3f(0.0F, 0.0F, 0.03F);
public static final int ALPHA_CUTOFF = 8;
@@ -309,6 +_,8 @@
public StringSplitter getSplitter() {
@@ -42,6 +_,8 @@
private final Function<ResourceLocation, FontSet> fonts;
final boolean filterFishyGlyphs;
private final StringSplitter splitter;
+ /** Neo: enables linear filtering on text */
+ public boolean enableTextTextureLinearFiltering = false;

public Font(Function<ResourceLocation, FontSet> p_243253_, boolean p_243245_) {
this.fonts = p_243253_;
@@ -310,6 +_,8 @@
return this.splitter;
}
+
+ @Override public Font self() { return this; }

+ @Override public Font self() { return this; }
+
@OnlyIn(Dist.CLIENT)
public static enum DisplayMode {
NORMAL,
@@ -417,7 +_,7 @@
p_381032_ - 1.0F, this.y + 9.0F, this.x, this.y - 1.0F, this.getUnderTextEffectDepth(), this.backgroundColor
);
bakedglyph = Font.this.getFontSet(Style.DEFAULT_FONT).whiteGlyph();
- VertexConsumer vertexconsumer = this.bufferSource.getBuffer(bakedglyph.renderType(this.mode));
+ VertexConsumer vertexconsumer = this.bufferSource.getBuffer(bakedglyph.renderType(this.mode, Font.this.enableTextTextureLinearFiltering));
bakedglyph.renderEffect(bakedglyph$effect, this.pose, vertexconsumer, this.packedLightCoords);
}

@@ -427,7 +_,7 @@
bakedglyph = Font.this.getFontSet(Style.DEFAULT_FONT).whiteGlyph();
}

- VertexConsumer vertexconsumer1 = this.bufferSource.getBuffer(bakedglyph.renderType(this.mode));
+ VertexConsumer vertexconsumer1 = this.bufferSource.getBuffer(bakedglyph.renderType(this.mode, Font.this.enableTextTextureLinearFiltering));

for (BakedGlyph.Effect bakedglyph$effect1 : this.effects) {
bakedglyph.renderEffect(bakedglyph$effect1, this.pose, vertexconsumer1, this.packedLightCoords);
@@ -440,7 +_,7 @@
void renderCharacters() {
for (BakedGlyph.GlyphInstance bakedglyph$glyphinstance : this.glyphInstances) {
BakedGlyph bakedglyph = bakedglyph$glyphinstance.glyph();
- VertexConsumer vertexconsumer = this.bufferSource.getBuffer(bakedglyph.renderType(this.mode));
+ VertexConsumer vertexconsumer = this.bufferSource.getBuffer(bakedglyph.renderType(this.mode, Font.this.enableTextTextureLinearFiltering));
bakedglyph.renderChar(bakedglyph$glyphinstance, this.pose, vertexconsumer, this.packedLightCoords);
}
}
50 changes: 50 additions & 0 deletions patches/net/minecraft/client/gui/font/GlyphRenderTypes.java.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
--- a/net/minecraft/client/gui/font/GlyphRenderTypes.java
+++ b/net/minecraft/client/gui/font/GlyphRenderTypes.java
@@ -7,22 +_,42 @@
import net.neoforged.api.distmarker.OnlyIn;

@OnlyIn(Dist.CLIENT)
-public record GlyphRenderTypes(RenderType normal, RenderType seeThrough, RenderType polygonOffset) {
+public record GlyphRenderTypes(RenderType normal, RenderType seeThrough, RenderType polygonOffset, RenderType normalBlur, RenderType seeThroughBlur, RenderType polygonOffsetBlur) {
+ /** @deprecated Neo: Use {@link GlyphRenderTypes(RenderType,RenderType,RenderType,RenderType,RenderType,RenderType)} instead */
+ @Deprecated
+ public GlyphRenderTypes(RenderType normal, RenderType seeThrough, RenderType polygonOffset) {
+ this(normal, seeThrough, polygonOffset, normal, seeThrough, polygonOffset);
+ }
+
public static GlyphRenderTypes createForIntensityTexture(ResourceLocation p_285411_) {
return new GlyphRenderTypes(
RenderType.textIntensity(p_285411_), RenderType.textIntensitySeeThrough(p_285411_), RenderType.textIntensityPolygonOffset(p_285411_)
+ , net.neoforged.neoforge.client.NeoForgeRenderTypes.getTextIntensityFiltered(p_285411_),
+ net.neoforged.neoforge.client.NeoForgeRenderTypes.getTextIntensitySeeThroughFiltered(p_285411_),
+ net.neoforged.neoforge.client.NeoForgeRenderTypes.getTextIntensityPolygonOffsetFiltered(p_285411_)
);
}

public static GlyphRenderTypes createForColorTexture(ResourceLocation p_285486_) {
- return new GlyphRenderTypes(RenderType.text(p_285486_), RenderType.textSeeThrough(p_285486_), RenderType.textPolygonOffset(p_285486_));
+ return new GlyphRenderTypes(RenderType.text(p_285486_), RenderType.textSeeThrough(p_285486_), RenderType.textPolygonOffset(p_285486_),
+ net.neoforged.neoforge.client.NeoForgeRenderTypes.getTextFiltered(p_285486_),
+ net.neoforged.neoforge.client.NeoForgeRenderTypes.getTextSeeThroughFiltered(p_285486_),
+ net.neoforged.neoforge.client.NeoForgeRenderTypes.getTextPolygonOffsetFiltered(p_285486_)
+ );
}

public RenderType select(Font.DisplayMode p_285259_) {
+ return this.select(p_285259_, false);
+ }
+
+ /**
+ * Neo: returns the {@link RenderType} to use for the given {@link Font.DisplayMode} and blur setting
+ */
+ public RenderType select(Font.DisplayMode p_285259_, boolean blur) {
return switch (p_285259_) {
- case NORMAL -> this.normal;
- case SEE_THROUGH -> this.seeThrough;
- case POLYGON_OFFSET -> this.polygonOffset;
+ case NORMAL -> blur ? this.normalBlur : this.normal;
+ case SEE_THROUGH -> blur ? this.seeThroughBlur : this.seeThrough;
+ case POLYGON_OFFSET -> blur ? this.polygonOffsetBlur : this.polygonOffset;
};
}
}
18 changes: 18 additions & 0 deletions patches/net/minecraft/client/gui/font/glyphs/BakedGlyph.java.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
--- a/net/minecraft/client/gui/font/glyphs/BakedGlyph.java
+++ b/net/minecraft/client/gui/font/glyphs/BakedGlyph.java
@@ -75,6 +_,15 @@
p_95223_.addVertex(p_254370_, p_95221_.x0, p_95221_.y1, p_95221_.depth).setColor(p_95221_.color).setUv(this.u1, this.v0).setLight(p_95224_);
}

+ /**
+ * Neo: returns the {@link RenderType} to use for the given {@link Font.DisplayMode} and blur setting
+ */
+ public RenderType renderType(Font.DisplayMode p_181388_, boolean blur) {
+ return this.renderTypes.select(p_181388_, blur);
+ }
+
+ /** @deprecated Neo: Use {@link #renderType(Font.DisplayMode, boolean)} instead */
+ @Deprecated
public RenderType renderType(Font.DisplayMode p_181388_) {
return this.renderTypes.select(p_181388_);
}
49 changes: 3 additions & 46 deletions patches/net/minecraft/client/renderer/RenderType.java.patch
Original file line number Diff line number Diff line change
@@ -1,52 +1,9 @@
--- a/net/minecraft/client/renderer/RenderType.java
+++ b/net/minecraft/client/renderer/RenderType.java
@@ -1098,7 +_,7 @@
}

public static RenderType text(ResourceLocation p_110498_) {
- return TEXT.apply(p_110498_);
+ return net.neoforged.neoforge.client.NeoForgeRenderTypes.getText(p_110498_);
}

public static RenderType textBackground() {
@@ -1106,19 +_,19 @@
}

public static RenderType textIntensity(ResourceLocation p_173238_) {
- return TEXT_INTENSITY.apply(p_173238_);
+ return net.neoforged.neoforge.client.NeoForgeRenderTypes.getTextIntensity(p_173238_);
}

public static RenderType textPolygonOffset(ResourceLocation p_181445_) {
- return TEXT_POLYGON_OFFSET.apply(p_181445_);
+ return net.neoforged.neoforge.client.NeoForgeRenderTypes.getTextPolygonOffset(p_181445_);
}

public static RenderType textIntensityPolygonOffset(ResourceLocation p_181447_) {
- return TEXT_INTENSITY_POLYGON_OFFSET.apply(p_181447_);
+ return net.neoforged.neoforge.client.NeoForgeRenderTypes.getTextIntensityPolygonOffset(p_181447_);
}

public static RenderType textSeeThrough(ResourceLocation p_110501_) {
- return TEXT_SEE_THROUGH.apply(p_110501_);
+ return net.neoforged.neoforge.client.NeoForgeRenderTypes.getTextSeeThrough(p_110501_);
}

public static RenderType textBackgroundSeeThrough() {
@@ -1126,7 +_,7 @@
}

public static RenderType textIntensitySeeThrough(ResourceLocation p_173241_) {
- return TEXT_INTENSITY_SEE_THROUGH.apply(p_173241_);
+ return net.neoforged.neoforge.client.NeoForgeRenderTypes.getTextIntensitySeeThrough(p_173241_);
}

public static RenderType lightning() {
@@ -1622,5 +_,17 @@
public String toString() {
@@ -1623,4 +_,16 @@
return this.name;
}
+ }
}
+
+ // Neo: Assign internal IDs for RenderType to be used in rendering
+ private int chunkLayerId = -1;
Expand All @@ -58,5 +15,5 @@
+ int i = 0;
+ for (var layer : chunkBufferLayers())
+ layer.chunkLayerId = i++;
}
+ }
}
57 changes: 17 additions & 40 deletions patches/net/minecraft/server/Main.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,22 @@
} catch (NbtException | ReportedNbtException | IOException ioexception) {
LOGGER.error("Failed to load world data from {}", levelstoragesource$leveldirectory.oldDataFile(), ioexception);
LOGGER.error(
@@ -173,6 +_,15 @@

PackRepository packrepository = ServerPacksSource.createPackRepository(levelstoragesource$levelstorageaccess);

+ if (gametestEnabled) {
+ net.neoforged.neoforge.gametest.GameTestHooks.registerGametests();
+ net.minecraft.core.BlockPos spawnPos = optionset.valueOf(spawnPosOpt);
+ MinecraftServer.spin(thread -> net.minecraft.gametest.framework.GameTestServer.create(thread, levelstoragesource$levelstorageaccess, packrepository, net.minecraft.gametest.framework.GameTestRegistry.getAllTestFunctions(), spawnPos));
+ // If we're running a gametest server we don't need to load the resources normally (GameTestServer#create does it using a flat world)
+ // or create a shutdown thread as the gametest server will always exit itself
+ return;
+ }
+
WorldStem worldstem;
try {
WorldLoader.InitConfig worldloader$initconfig = loadOrCreateConfig(dedicatedserversettings.getProperties(), dynamic1, flag, packrepository);
@@ -214,6 +_,9 @@
worlddimensions = dedicatedserverproperties.createDimensions(p_359487_.datapackWorldgen());
}
Expand All @@ -95,48 +111,9 @@
WorldDimensions.Complete worlddimensions$complete = worlddimensions.bake(registry);
Lifecycle lifecycle = worlddimensions$complete.lifecycle().add(p_359487_.datapackWorldgen().allRegistriesLifecycle());
return new WorldLoader.DataLoadOutput<>(
@@ -246,24 +_,22 @@

WorldData worlddata = worldstem.worldData();
levelstoragesource$levelstorageaccess.saveDataTag(registryaccess$frozen, worlddata);
- final DedicatedServer dedicatedserver = MinecraftServer.spin(
+ final MinecraftServer dedicatedserver = MinecraftServer.spin(
p_293760_ -> {
- DedicatedServer dedicatedserver1 = new DedicatedServer(
- p_293760_,
- levelstoragesource$levelstorageaccess,
- packrepository,
- worldstem,
- dedicatedserversettings,
- DataFixers.getDataFixer(),
- services,
- LoggerChunkProgressListener::createFromGameruleRadius
- );
+ MinecraftServer dedicatedserver1;
+ if (gametestEnabled) {
+ net.neoforged.neoforge.gametest.GameTestHooks.registerGametests();
+ net.minecraft.core.BlockPos spawnPos = optionset.valueOf(spawnPosOpt);
+ dedicatedserver1 = net.minecraft.gametest.framework.GameTestServer.create(p_293760_, levelstoragesource$levelstorageaccess, packrepository, net.minecraft.gametest.framework.GameTestRegistry.getAllTestFunctions(), spawnPos);
+ } else {
+ dedicatedserver1 = new DedicatedServer(p_293760_, levelstoragesource$levelstorageaccess, packrepository, worldstem, dedicatedserversettings, DataFixers.getDataFixer(), services, LoggerChunkProgressListener::createFromGameruleRadius);
+ }
dedicatedserver1.setPort(optionset.valueOf(optionspec11));
dedicatedserver1.setDemo(optionset.has(optionspec2));
dedicatedserver1.setId(optionset.valueOf(optionspec12));
boolean flag2 = !optionset.has(optionspec) && !optionset.valuesOf(optionspec15).contains("nogui");
- if (flag2 && !GraphicsEnvironment.isHeadless()) {
- dedicatedserver1.showGui();
+ if (dedicatedserver1 instanceof DedicatedServer dedicatedServer && flag2 && !GraphicsEnvironment.isHeadless()) {
+ dedicatedServer.showGui();
}

return dedicatedserver1;
@@ -272,7 +_,10 @@
Thread thread = new Thread("Server Shutdown Thread") {
@@ -273,6 +_,7 @@
@Override
public void run() {
+ // FORGE: Halting as GameTestServer will cause issues as it always calls System#exit on both crash and normal exit, so skip it
+ if (!(dedicatedserver instanceof net.minecraft.gametest.framework.GameTestServer))
dedicatedserver.halt(true);
+ org.apache.logging.log4j.LogManager.shutdown(); // we're manually managing the logging shutdown on the server. Make sure we do it here at the end.
}
Expand Down
9 changes: 9 additions & 0 deletions patches/net/minecraft/world/entity/LivingEntity.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,15 @@
itemstack = itemstack1.copy();
itemstack1.shrink(1);
break;
@@ -1309,7 +_,7 @@
}

ItemStack itemstack = this.getItemBlockingWith();
- if (!p_21276_.is(DamageTypeTags.BYPASSES_SHIELD) && itemstack != null && itemstack.getItem() instanceof ShieldItem && !flag) {
+ if (!p_21276_.is(DamageTypeTags.BYPASSES_SHIELD) && itemstack != null && !flag) {
Vec3 vec3 = p_21276_.getSourcePosition();
if (vec3 != null) {
Vec3 vec31 = this.calculateViewVector(0.0F, this.getYHeadRot());
@@ -1343,6 +_,7 @@
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,13 @@
blockpos = blockhitresult.getBlockPos();
flag1 = true;
}
@@ -236,6 +_,9 @@
}

this.setDeltaMovement(this.getDeltaMovement().scale(0.98));
+ if (isAlive() && block instanceof net.neoforged.neoforge.common.extensions.IFallableExtension feblock) {
+ feblock.fallingTick(level(), blockPosition(), this);
+ }
}
}

Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
--- a/net/minecraft/world/inventory/FurnaceResultSlot.java
+++ b/net/minecraft/world/inventory/FurnaceResultSlot.java
@@ -49,5 +_,6 @@
@@ -48,6 +_,9 @@
abstractfurnaceblockentity.awardUsedRecipesAndPopExperience(serverplayer);
}

+ if (this.removeCount != 0) {
+ net.neoforged.neoforge.event.EventHooks.firePlayerSmeltedEvent(this.player, p_39558_, this.removeCount);
+ }
this.removeCount = 0;
+ net.neoforged.neoforge.event.EventHooks.firePlayerSmeltedEvent(this.player, p_39558_);
}
}
Loading

0 comments on commit ff12e90

Please sign in to comment.