Skip to content

Commit cd38a77

Browse files
committed
build: 25w31a
1 parent 34d313d commit cd38a77

File tree

20 files changed

+296
-125
lines changed

20 files changed

+296
-125
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
4747
- name: upload to modrinth and curseforge
4848
run: ./gradlew modrinth curseforge
49-
if: github.ref == 'refs/heads/dev/1.21.8'
49+
if: github.ref == 'refs/heads/dev/1.21.9'
5050
env:
5151
MODRINTH_TOKEN: ${{ secrets.MODRINTH_UPLOAD_TOKEN }}
5252
CURSEFORGE_TOKEN: ${{ secrets.CURSEFORGE_API_TOKEN }}

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
plugins {
22
id 'java-library'
3-
id 'fabric-loom' version '1.10-SNAPSHOT' apply false
3+
id 'fabric-loom' version '1.11-SNAPSHOT' apply false
44
id "me.champeau.jmh" version "0.7.2"
55
id 'com.modrinth.minotaur' version '2.+' apply false
66
id 'com.matthewprenger.cursegradle' version '1.4.0' apply false

c2me-base/src/main/java/com/ishland/c2me/base/mixin/access/IThreadedAnvilChunkStorage.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import it.unimi.dsi.fastutil.longs.Long2LongMap;
44
import it.unimi.dsi.fastutil.longs.Long2ObjectLinkedOpenHashMap;
55
import net.minecraft.nbt.NbtCompound;
6-
import net.minecraft.server.WorldGenerationProgressListener;
76
import net.minecraft.server.world.ChunkHolder;
87
import net.minecraft.server.world.ChunkLevelType;
98
import net.minecraft.server.world.ServerChunkLoadingManager;
@@ -47,12 +46,6 @@ public interface IThreadedAnvilChunkStorage {
4746
@Invoker
4847
void invokeSendToPlayers(ChunkHolder chunkHolder, WorldChunk chunk);
4948

50-
@Accessor
51-
WorldGenerationProgressListener getWorldGenerationProgressListener();
52-
53-
@Accessor
54-
AtomicInteger getTotalChunksLoadedCount();
55-
5649
@Invoker
5750
ChunkHolder invokeGetChunkHolder(long pos);
5851

c2me-base/src/main/resources/c2me-base.accesswidener

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ accessible class net/minecraft/world/gen/densityfunction/DensityFunctionTy
4848
accessible class net/minecraft/world/gen/densityfunction/DensityFunctionTypes$RangeChoice
4949
accessible class net/minecraft/world/gen/densityfunction/DensityFunctionTypes$WeirdScaledSampler
5050
accessible class net/minecraft/world/gen/densityfunction/DensityFunctionTypes$Offset
51+
accessible class net/minecraft/world/gen/densityfunction/DensityFunctionTypes$FindTopSurface
5152
accessible class net/minecraft/world/gen/chunk/ChunkNoiseSampler$FlatCache
5253
accessible class net/minecraft/world/gen/chunk/ChunkNoiseSampler$Cache2D
5354
accessible class net/minecraft/world/gen/chunk/ChunkNoiseSampler$CacheOnce

c2me-notickvd/src/main/java/com/ishland/c2me/notickvd/common/PlayerNoTickLoader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public class PlayerNoTickLoader {
3333
private static final Logger LOGGER = LogUtils.getLogger();
3434

3535
public static final ItemTicket.TicketType TICKET_TYPE = new ItemTicket.TicketType("c2me:notickvd");
36-
public static final ChunkTicketType VANILLA_TICKET_TYPE = new ChunkTicketType(0, false, ChunkTicketType.Use.LOADING);
36+
public static final ChunkTicketType VANILLA_TICKET_TYPE = new ChunkTicketType(0, 2); // loading
3737

3838
private final ServerChunkLoadingManager tacs;
3939
private final NoTickSystem noTickSystem;

c2me-notickvd/src/main/java/com/ishland/c2me/notickvd/mixin/client/MixinIntegratedServer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package com.ishland.c2me.notickvd.mixin.client;
22

33
import com.mojang.datafixers.DataFixer;
4+
import net.minecraft.class_11545;
45
import net.minecraft.resource.ResourcePackManager;
56
import net.minecraft.server.MinecraftServer;
67
import net.minecraft.server.SaveLoader;
7-
import net.minecraft.server.WorldGenerationProgressListenerFactory;
88
import net.minecraft.server.integrated.IntegratedServer;
99
import net.minecraft.server.network.ServerPlayerEntity;
1010
import net.minecraft.util.ApiServices;
@@ -19,7 +19,7 @@
1919
@Mixin(IntegratedServer.class)
2020
public abstract class MixinIntegratedServer extends MinecraftServer {
2121

22-
public MixinIntegratedServer(Thread serverThread, LevelStorage.Session session, ResourcePackManager dataPackManager, SaveLoader saveLoader, Proxy proxy, DataFixer dataFixer, ApiServices apiServices, WorldGenerationProgressListenerFactory worldGenerationProgressListenerFactory) {
22+
public MixinIntegratedServer(Thread serverThread, LevelStorage.Session session, ResourcePackManager dataPackManager, SaveLoader saveLoader, Proxy proxy, DataFixer dataFixer, ApiServices apiServices, class_11545 worldGenerationProgressListenerFactory) {
2323
super(serverThread, session, dataPackManager, saveLoader, proxy, dataFixer, apiServices, worldGenerationProgressListenerFactory);
2424
}
2525

c2me-notickvd/src/test/java/com/ishland/c2me/notickvd/common/iterators/TestIterators.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import net.minecraft.Bootstrap;
66
import net.minecraft.SharedConstants;
77
import net.minecraft.block.entity.SkullBlockEntity;
8+
import net.minecraft.component.type.ProfileComponent;
89
import net.minecraft.util.Util;
910
import net.minecraft.util.math.ChunkPos;
1011
import org.junit.jupiter.api.AfterAll;
@@ -47,7 +48,7 @@ public void testSpiral() {
4748
@AfterAll
4849
public static void teardown() {
4950
Util.shutdownExecutors();
50-
SkullBlockEntity.clearServices();
51+
ProfileComponent.method_72521();
5152
}
5253

5354
}

c2me-opts-dfc/src/main/java/com/ishland/c2me/opts/dfc/common/ast/McToAst.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.ishland.c2me.opts.dfc.common.ast;
22

33
import com.ishland.c2me.opts.dfc.common.ast.binary.AddNode;
4+
import com.ishland.c2me.opts.dfc.common.ast.binary.DivNode;
45
import com.ishland.c2me.opts.dfc.common.ast.binary.MaxNode;
56
import com.ishland.c2me.opts.dfc.common.ast.binary.MaxShortNode;
67
import com.ishland.c2me.opts.dfc.common.ast.binary.MinNode;
@@ -9,6 +10,7 @@
910
import com.ishland.c2me.opts.dfc.common.ast.misc.CacheLikeNode;
1011
import com.ishland.c2me.opts.dfc.common.ast.misc.ConstantNode;
1112
import com.ishland.c2me.opts.dfc.common.ast.misc.DelegateNode;
13+
import com.ishland.c2me.opts.dfc.common.ast.misc.FindTopSurfaceNode;
1214
import com.ishland.c2me.opts.dfc.common.ast.misc.RangeChoiceNode;
1315
import com.ishland.c2me.opts.dfc.common.ast.misc.YClampedGradientNode;
1416
import com.ishland.c2me.opts.dfc.common.ast.noise.DFTNoiseNode;
@@ -77,6 +79,7 @@ public static AstNode toAst(DensityFunction df) {
7779
case CUBE -> new CubeNode(toAst(f.input()));
7880
case HALF_NEGATIVE -> new NegMulNode(toAst(f.input()), 0.5);
7981
case QUARTER_NEGATIVE -> new NegMulNode(toAst(f.input()), 0.25);
82+
case INVERT -> new DivNode(new ConstantNode(1.0), toAst(f.input()));
8083
case SQUEEZE -> new SqueezeNode(toAst(f.input()));
8184
};
8285
case DensityFunctionTypes.RangeChoice f -> new RangeChoiceNode(toAst(f.input()), f.minInclusive(), f.maxExclusive(), toAst(f.whenInRange()), toAst(f.whenOutOfRange()));
@@ -97,6 +100,7 @@ public static AstNode toAst(DensityFunction df) {
97100
case DensityFunctionTypes.YClampedGradient f -> new YClampedGradientNode(f.fromY(), f.toY(), f.fromValue(), f.toValue());
98101
case DensityFunctionTypes.WeirdScaledSampler f -> new DFTWeirdScaledSamplerNode(toAst(f.input()), f.noise(), f.rarityValueMapper());
99102
case DensityFunctionTypes.Spline f -> new SplineAstNode(f.spline());
103+
case DensityFunctionTypes.FindTopSurface f -> new FindTopSurfaceNode(toAst(f.density()), toAst(f.upperBound()), new ConstantNode(f.lowerBound()), f.cellHeight());
100104

101105
default -> {
102106
// delegateStatistics.computeIfAbsent(df.getClass(), unused -> new LongAdder()).increment();;
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package com.ishland.c2me.opts.dfc.common.ast.binary;
2+
3+
import com.ishland.c2me.opts.dfc.common.ast.AstNode;
4+
import com.ishland.c2me.opts.dfc.common.ast.EvalType;
5+
import com.ishland.c2me.opts.dfc.common.gen.BytecodeGen;
6+
import org.objectweb.asm.Type;
7+
import org.objectweb.asm.commons.InstructionAdapter;
8+
9+
public class DivNode extends AbstractBinaryNode {
10+
11+
public DivNode(AstNode left, AstNode right) {
12+
super(left, right);
13+
}
14+
15+
@Override
16+
protected AstNode newInstance(AstNode left, AstNode right) {
17+
return new DivNode(left, right);
18+
}
19+
20+
@Override
21+
public double evalSingle(int x, int y, int z, EvalType type) {
22+
return this.left.evalSingle(x, y, z, type) / this.right.evalSingle(x, y, z, type);
23+
}
24+
25+
@Override
26+
public void evalMulti(double[] res, int[] x, int[] y, int[] z, EvalType type) {
27+
double[] res1 = new double[res.length];
28+
this.left.evalMulti(res, x, y, z, type);
29+
this.right.evalMulti(res1, x, y, z, type);
30+
for (int i = 0; i < res1.length; i++) {
31+
res[i] /= res1[i];
32+
}
33+
}
34+
35+
@Override
36+
public void doBytecodeGenSingle(BytecodeGen.Context context, InstructionAdapter m, BytecodeGen.Context.LocalVarConsumer localVarConsumer) {
37+
super.doBytecodeGenSingle(context, m, localVarConsumer);
38+
m.div(Type.DOUBLE_TYPE);
39+
m.areturn(Type.DOUBLE_TYPE);
40+
}
41+
42+
@Override
43+
protected void bytecodeGenMultiBody(InstructionAdapter m, int idx, int res1) {
44+
m.load(1, InstructionAdapter.OBJECT_TYPE);
45+
m.load(idx, Type.INT_TYPE);
46+
m.dup2();
47+
m.aload(Type.DOUBLE_TYPE);
48+
m.load(res1, InstructionAdapter.OBJECT_TYPE);
49+
m.load(idx, Type.INT_TYPE);
50+
m.aload(Type.DOUBLE_TYPE);
51+
m.div(Type.DOUBLE_TYPE);
52+
m.astore(Type.DOUBLE_TYPE);
53+
}
54+
}
Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
package com.ishland.c2me.opts.dfc.common.ast.misc;
2+
3+
import com.ishland.c2me.opts.dfc.common.ast.AstNode;
4+
import com.ishland.c2me.opts.dfc.common.ast.AstTransformer;
5+
import com.ishland.c2me.opts.dfc.common.ast.EvalType;
6+
import com.ishland.c2me.opts.dfc.common.gen.BytecodeGen;
7+
import net.fabricmc.loader.api.FabricLoader;
8+
import net.minecraft.util.math.MathHelper;
9+
import org.objectweb.asm.Label;
10+
import org.objectweb.asm.Type;
11+
import org.objectweb.asm.commons.InstructionAdapter;
12+
13+
import java.util.Objects;
14+
15+
public class FindTopSurfaceNode implements AstNode {
16+
17+
private final AstNode density;
18+
private final AstNode upperBound;
19+
private final AstNode lowerBound;
20+
private final int cellHeight;
21+
22+
public FindTopSurfaceNode(AstNode density, AstNode upperBound, AstNode lowerBound, int cellHeight) {
23+
this.density = Objects.requireNonNull(density);
24+
this.upperBound = Objects.requireNonNull(upperBound);
25+
this.lowerBound = Objects.requireNonNull(lowerBound);
26+
this.cellHeight = cellHeight;
27+
}
28+
29+
@Override
30+
public double evalSingle(int x, int y, int z, EvalType type) {
31+
int topCellBlockY = MathHelper.floor(this.upperBound.evalSingle(x, y, z, type) / this.cellHeight) * this.cellHeight;
32+
int lowerBoundEval = (int) this.lowerBound.evalSingle(x, y, z, type);
33+
for (int y1 = topCellBlockY; y1 > lowerBoundEval; y1 -= this.cellHeight) {
34+
if (this.density.evalSingle(x, y1, z, EvalType.NORMAL) > 0.0) {
35+
return y1;
36+
}
37+
}
38+
return lowerBoundEval;
39+
}
40+
41+
@Override
42+
public void evalMulti(double[] res, int[] x, int[] y, int[] z, EvalType type) {
43+
this.upperBound.evalMulti(res, x, y, z, type);
44+
int[] topCellBlockY = new int[res.length];
45+
for (int i = 0; i < res.length; i++) {
46+
topCellBlockY[i] = MathHelper.floor(res[i] / this.cellHeight) * this.cellHeight;
47+
}
48+
this.lowerBound.evalMulti(res, x, y, z, type);
49+
int[] lowerBoundEval = new int[res.length];
50+
for (int i = 0; i < res.length; i++) {
51+
lowerBoundEval[i] = (int) res[i];
52+
}
53+
for (int i = 0; i < res.length; i ++) {
54+
res[i] = lowerBoundEval[i]; // default to lower bound
55+
for (int y1 = topCellBlockY[i]; y1 > lowerBoundEval[i]; y1 -= this.cellHeight) {
56+
if (this.density.evalSingle(x[i], y1, z[i], type) > 0.0) {
57+
res[i] = y1;
58+
break;
59+
}
60+
}
61+
}
62+
}
63+
64+
@Override
65+
public AstNode[] getChildren() {
66+
return new AstNode[] {this.density, this.upperBound, this.lowerBound};
67+
}
68+
69+
@Override
70+
public AstNode transform(AstTransformer transformer) {
71+
AstNode density = this.density.transform(transformer);
72+
AstNode upperBound = this.upperBound.transform(transformer);
73+
AstNode lowerBound = this.lowerBound.transform(transformer);
74+
if (density == this.density && upperBound == this.upperBound && lowerBound == this.lowerBound) {
75+
return transformer.transform(this);
76+
} else {
77+
return transformer.transform(new FindTopSurfaceNode(density, upperBound, lowerBound, this.cellHeight));
78+
}
79+
}
80+
81+
@Override
82+
public void doBytecodeGenSingle(BytecodeGen.Context ctx, InstructionAdapter m, BytecodeGen.Context.LocalVarConsumer localVarConsumer) {
83+
String densityMethod = ctx.newSingleMethod(this.density);
84+
String upperBoundMethod = ctx.newSingleMethod(this.upperBound);
85+
String lowerBoundMethod = ctx.newSingleMethod(this.lowerBound);
86+
87+
int topCellBlockY = localVarConsumer.createLocalVariable("topCellBlockY", Type.INT_TYPE.getDescriptor());
88+
int lowerBoundEval = localVarConsumer.createLocalVariable("lowerBoundEval", Type.INT_TYPE.getDescriptor());
89+
ctx.callDelegateSingle(m, upperBoundMethod);
90+
m.dconst(this.cellHeight);
91+
m.div(Type.DOUBLE_TYPE);
92+
m.invokestatic(
93+
Type.getInternalName(MathHelper.class),
94+
FabricLoader.getInstance().getMappingResolver().mapMethodName("intermediary", "net.minecraft.class_3532", "method_15357", "(D)I"),
95+
"(D)I",
96+
false
97+
);
98+
m.iconst(this.cellHeight);
99+
m.mul(Type.INT_TYPE);
100+
m.store(topCellBlockY, Type.INT_TYPE);
101+
102+
ctx.callDelegateSingle(m, lowerBoundMethod);
103+
m.cast(Type.DOUBLE_TYPE, Type.INT_TYPE);
104+
m.store(lowerBoundEval, Type.INT_TYPE);
105+
106+
Label loopStart = new Label();
107+
Label loopEnd = new Label();
108+
109+
int y1 = localVarConsumer.createLocalVariable("y1", Type.INT_TYPE.getDescriptor());
110+
m.load(topCellBlockY, Type.INT_TYPE);
111+
m.store(y1, Type.INT_TYPE);
112+
113+
m.visitLabel(loopStart);
114+
115+
m.load(y1, Type.INT_TYPE);
116+
m.load(lowerBoundEval, Type.INT_TYPE);
117+
m.ificmple(loopEnd);
118+
m.load(0, InstructionAdapter.OBJECT_TYPE);
119+
m.load(1, Type.INT_TYPE);
120+
m.load(y1, Type.INT_TYPE);
121+
m.load(3, Type.INT_TYPE);
122+
m.getstatic(
123+
Type.getInternalName(EvalType.class),
124+
"NORMAL",
125+
Type.getDescriptor(EvalType.class)
126+
);
127+
m.invokevirtual(ctx.className, densityMethod, BytecodeGen.Context.SINGLE_DESC, false);
128+
m.dconst(0.0);
129+
m.cmpl(Type.DOUBLE_TYPE);
130+
131+
Label notSatisfied = new Label();
132+
m.ifle(notSatisfied);
133+
m.load(y1, Type.INT_TYPE);
134+
m.cast(Type.INT_TYPE, Type.DOUBLE_TYPE);
135+
m.areturn(Type.DOUBLE_TYPE);
136+
m.visitLabel(notSatisfied);
137+
138+
m.load(y1, Type.INT_TYPE);
139+
m.iconst(this.cellHeight);
140+
m.sub(Type.INT_TYPE);
141+
m.store(y1, Type.INT_TYPE);
142+
m.goTo(loopStart);
143+
144+
m.visitLabel(loopEnd);
145+
146+
m.load(lowerBoundEval, Type.INT_TYPE);
147+
m.cast(Type.INT_TYPE, Type.DOUBLE_TYPE);
148+
m.areturn(Type.DOUBLE_TYPE);
149+
}
150+
151+
@Override
152+
public void doBytecodeGenMulti(BytecodeGen.Context ctx, InstructionAdapter m, BytecodeGen.Context.LocalVarConsumer localVarConsumer) {
153+
ctx.delegateToSingle(m, localVarConsumer, this);
154+
m.areturn(Type.VOID_TYPE);
155+
}
156+
157+
@Override
158+
public boolean equals(Object o) {
159+
if (o == null || getClass() != o.getClass()) return false;
160+
FindTopSurfaceNode that = (FindTopSurfaceNode) o;
161+
return cellHeight == that.cellHeight && Objects.equals(density, that.density) && Objects.equals(upperBound, that.upperBound) && Objects.equals(lowerBound, that.lowerBound);
162+
}
163+
164+
@Override
165+
public int hashCode() {
166+
int result = 1;
167+
168+
result = 31 * result + this.getClass().hashCode();
169+
result = 31 * result + this.density.hashCode();
170+
result = 31 * result + this.upperBound.hashCode();
171+
result = 31 * result + this.lowerBound.hashCode();
172+
result = 31 * result + Integer.hashCode(cellHeight);
173+
174+
return result;
175+
}
176+
177+
@Override
178+
public boolean relaxedEquals(AstNode o) {
179+
if (o == null || getClass() != o.getClass()) return false;
180+
FindTopSurfaceNode that = (FindTopSurfaceNode) o;
181+
return cellHeight == that.cellHeight && this.density.relaxedEquals(that.density) && this.upperBound.relaxedEquals(that.upperBound) && this.lowerBound.relaxedEquals(that.lowerBound);
182+
}
183+
184+
@Override
185+
public int relaxedHashCode() {
186+
int result = 1;
187+
188+
result = 31 * result + this.getClass().hashCode();
189+
result = 31 * result + this.density.relaxedHashCode();
190+
result = 31 * result + this.upperBound.relaxedHashCode();
191+
result = 31 * result + this.lowerBound.relaxedHashCode();
192+
result = 31 * result + Integer.hashCode(cellHeight);
193+
194+
return result;
195+
}
196+
}

0 commit comments

Comments
 (0)