Compare commits
8 Commits
v0.1.0-bet
...
v0.1.0-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9da99576a6 | ||
|
|
dfbe1bcf8b | ||
|
|
ae29196221 | ||
|
|
f1eb61cc51 | ||
|
|
58c933938f | ||
|
|
1dc3cb5f14 | ||
|
|
2acfc6a68e | ||
|
|
c22538c364 |
@@ -24,7 +24,7 @@ dependencies {
|
|||||||
include "me.shedaniel.cloth:cloth-config-fabric:${rootProject.cloth_version}"
|
include "me.shedaniel.cloth:cloth-config-fabric:${rootProject.cloth_version}"
|
||||||
modImplementation "com.terraformersmc:modmenu:11.0.1"
|
modImplementation "com.terraformersmc:modmenu:11.0.1"
|
||||||
|
|
||||||
modImplementation fabricApiLibs.command.api.v2
|
modImplementation fabricApiLibs.fabric.api
|
||||||
include fabricApiLibs.command.api.v2
|
include fabricApiLibs.command.api.v2
|
||||||
include fabricApiLibs.base
|
include fabricApiLibs.base
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,9 @@ package ca.spottedleaf.moonrise.fabric;
|
|||||||
import ca.spottedleaf.moonrise.common.PlatformHooks;
|
import ca.spottedleaf.moonrise.common.PlatformHooks;
|
||||||
import ca.spottedleaf.moonrise.common.util.ConfigHolder;
|
import ca.spottedleaf.moonrise.common.util.ConfigHolder;
|
||||||
import ca.spottedleaf.moonrise.patches.chunk_system.scheduling.NewChunkHolder;
|
import ca.spottedleaf.moonrise.patches.chunk_system.scheduling.NewChunkHolder;
|
||||||
|
import net.fabricmc.fabric.api.event.Event;
|
||||||
|
import net.fabricmc.fabric.api.event.EventFactory;
|
||||||
|
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerChunkEvents;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.server.level.GenerationChunkHolder;
|
import net.minecraft.server.level.GenerationChunkHolder;
|
||||||
@@ -25,6 +28,19 @@ import java.util.function.Predicate;
|
|||||||
|
|
||||||
public final class FabricHooks implements PlatformHooks {
|
public final class FabricHooks implements PlatformHooks {
|
||||||
|
|
||||||
|
public interface OnExplosionDetonate {
|
||||||
|
void onExplosion(final Level world, final Explosion explosion, final List<Entity> possiblyAffecting, final double diameter);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final Event<OnExplosionDetonate> ON_EXPLOSION_DETONATE = EventFactory.createArrayBacked(
|
||||||
|
OnExplosionDetonate.class,
|
||||||
|
listeners -> (final Level world, final Explosion explosion, final List<Entity> possiblyAffecting, final double diameter) -> {
|
||||||
|
for (int i = 0; i < listeners.length; i++) {
|
||||||
|
listeners[i].onExplosion(world, explosion, possiblyAffecting, diameter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getBrand() {
|
public String getBrand() {
|
||||||
return "Moonrise";
|
return "Moonrise";
|
||||||
@@ -44,7 +60,7 @@ public final class FabricHooks implements PlatformHooks {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onExplosion(final Level world, final Explosion explosion, final List<Entity> possiblyAffecting, final double diameter) {
|
public void onExplosion(final Level world, final Explosion explosion, final List<Entity> possiblyAffecting, final double diameter) {
|
||||||
|
ON_EXPLOSION_DETONATE.invoker().onExplosion(world, explosion, possiblyAffecting, diameter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -69,7 +85,7 @@ public final class FabricHooks implements PlatformHooks {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void chunkFullStatusComplete(final LevelChunk newChunk, final ProtoChunk original) {
|
public void chunkFullStatusComplete(final LevelChunk newChunk, final ProtoChunk original) {
|
||||||
|
ServerChunkEvents.CHUNK_LOAD.invoker().onChunkLoad((ServerLevel) newChunk.getLevel(), newChunk);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -84,7 +100,7 @@ public final class FabricHooks implements PlatformHooks {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void chunkUnloadFromWorld(final LevelChunk chunk) {
|
public void chunkUnloadFromWorld(final LevelChunk chunk) {
|
||||||
|
ServerChunkEvents.CHUNK_UNLOAD.invoker().onChunkUnload((ServerLevel) chunk.getLevel(), chunk);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -12,6 +12,6 @@ concurrentutil_version=0.0.2-SNAPSHOT
|
|||||||
cloth_version=15.0.128
|
cloth_version=15.0.128
|
||||||
lithium_version=mc1.21.1-0.13.1
|
lithium_version=mc1.21.1-0.13.1
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version=0.1.0-beta.4
|
mod_version=0.1.0-beta.6
|
||||||
maven_group=ca.spottedleaf.moonrise
|
maven_group=ca.spottedleaf.moonrise
|
||||||
archives_base_name=moonrise
|
archives_base_name=moonrise
|
||||||
|
|||||||
@@ -35,40 +35,18 @@ abstract class PalettedContainerMixin<T> implements PaletteResize<T>, PalettedCo
|
|||||||
* @author Spottedleaf
|
* @author Spottedleaf
|
||||||
*/
|
*/
|
||||||
@Inject(
|
@Inject(
|
||||||
method = "<init>(Lnet/minecraft/core/IdMap;Ljava/lang/Object;Lnet/minecraft/world/level/chunk/PalettedContainer$Strategy;)V",
|
// cannot use `<init>*` due to https://github.com/FabricMC/tiny-remapper/issues/137
|
||||||
|
method = {
|
||||||
|
"<init>(Lnet/minecraft/core/IdMap;Lnet/minecraft/world/level/chunk/PalettedContainer$Strategy;Lnet/minecraft/world/level/chunk/PalettedContainer$Configuration;Lnet/minecraft/util/BitStorage;Ljava/util/List;)V",
|
||||||
|
"<init>(Lnet/minecraft/core/IdMap;Lnet/minecraft/world/level/chunk/PalettedContainer$Strategy;Lnet/minecraft/world/level/chunk/PalettedContainer$Data;)V",
|
||||||
|
"<init>(Lnet/minecraft/core/IdMap;Ljava/lang/Object;Lnet/minecraft/world/level/chunk/PalettedContainer$Strategy;)V"
|
||||||
|
},
|
||||||
at = @At(
|
at = @At(
|
||||||
value = "RETURN"
|
value = "RETURN"
|
||||||
)
|
),
|
||||||
|
require = 3 // Require matching all 3 constructors
|
||||||
)
|
)
|
||||||
private void constructorHook1(final CallbackInfo ci) {
|
private void constructorHook(final CallbackInfo ci) {
|
||||||
this.updateData(this.data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @reason Hook to update raw palette data on object construction
|
|
||||||
* @author Spottedleaf
|
|
||||||
*/
|
|
||||||
@Inject(
|
|
||||||
method = "<init>(Lnet/minecraft/core/IdMap;Lnet/minecraft/world/level/chunk/PalettedContainer$Strategy;Lnet/minecraft/world/level/chunk/PalettedContainer$Configuration;Lnet/minecraft/util/BitStorage;Ljava/util/List;)V",
|
|
||||||
at = @At(
|
|
||||||
value = "RETURN"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
private void constructorHook2(final CallbackInfo ci) {
|
|
||||||
this.updateData(this.data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @reason Hook to update raw palette data on object construction
|
|
||||||
* @author Spottedleaf
|
|
||||||
*/
|
|
||||||
@Inject(
|
|
||||||
method = "<init>(Lnet/minecraft/core/IdMap;Lnet/minecraft/world/level/chunk/PalettedContainer$Strategy;Lnet/minecraft/world/level/chunk/PalettedContainer$Data;)V",
|
|
||||||
at = @At(
|
|
||||||
value = "RETURN"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
private void constructorHook3(final CallbackInfo ci) {
|
|
||||||
this.updateData(this.data);
|
this.updateData(this.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,11 +17,17 @@ abstract class PalettedContainerMixin {
|
|||||||
* @author jpenilla
|
* @author jpenilla
|
||||||
*/
|
*/
|
||||||
@Redirect(
|
@Redirect(
|
||||||
method = "<init>*",
|
// cannot use `<init>*` due to https://github.com/FabricMC/tiny-remapper/issues/137
|
||||||
|
method = {
|
||||||
|
"<init>(Lnet/minecraft/core/IdMap;Lnet/minecraft/world/level/chunk/PalettedContainer$Strategy;Lnet/minecraft/world/level/chunk/PalettedContainer$Configuration;Lnet/minecraft/util/BitStorage;Ljava/util/List;)V",
|
||||||
|
"<init>(Lnet/minecraft/core/IdMap;Lnet/minecraft/world/level/chunk/PalettedContainer$Strategy;Lnet/minecraft/world/level/chunk/PalettedContainer$Data;)V",
|
||||||
|
"<init>(Lnet/minecraft/core/IdMap;Ljava/lang/Object;Lnet/minecraft/world/level/chunk/PalettedContainer$Strategy;)V"
|
||||||
|
},
|
||||||
at = @At(
|
at = @At(
|
||||||
value = "NEW",
|
value = "NEW",
|
||||||
target = "Lnet/minecraft/util/ThreadingDetector;"
|
target = "Lnet/minecraft/util/ThreadingDetector;"
|
||||||
)
|
),
|
||||||
|
require = 3 // Require matching all 3 constructors
|
||||||
)
|
)
|
||||||
private static ThreadingDetector threadingDetector(final String name) {
|
private static ThreadingDetector threadingDetector(final String name) {
|
||||||
return THREADING_DETECTOR;
|
return THREADING_DETECTOR;
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package ca.spottedleaf.moonrise.patches.profiler;
|
|||||||
|
|
||||||
import com.mojang.logging.LogUtils;
|
import com.mojang.logging.LogUtils;
|
||||||
import it.unimi.dsi.fastutil.ints.IntArrayFIFOQueue;
|
import it.unimi.dsi.fastutil.ints.IntArrayFIFOQueue;
|
||||||
|
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||||
|
import it.unimi.dsi.fastutil.ints.IntList;
|
||||||
import it.unimi.dsi.fastutil.longs.LongArrayFIFOQueue;
|
import it.unimi.dsi.fastutil.longs.LongArrayFIFOQueue;
|
||||||
import it.unimi.dsi.fastutil.objects.Reference2ReferenceOpenHashMap;
|
import it.unimi.dsi.fastutil.objects.Reference2ReferenceOpenHashMap;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@@ -169,6 +171,7 @@ public final class LeafProfiler {
|
|||||||
public final List<ProfileNode> children = new ArrayList<>();
|
public final List<ProfileNode> children = new ArrayList<>();
|
||||||
public long childrenTimingCount;
|
public long childrenTimingCount;
|
||||||
public int depth = -1;
|
public int depth = -1;
|
||||||
|
public boolean lastChild;
|
||||||
|
|
||||||
private ProfileNode(final ProfileNode parent, final int nodeId, final LProfilerRegistry.ProfilerEntry profiler,
|
private ProfileNode(final ProfileNode parent, final int nodeId, final LProfilerRegistry.ProfilerEntry profiler,
|
||||||
final long totalTime, final long totalCount) {
|
final long totalTime, final long totalCount) {
|
||||||
@@ -188,11 +191,6 @@ public final class LeafProfiler {
|
|||||||
long[] timers,
|
long[] timers,
|
||||||
long[] counters
|
long[] counters
|
||||||
) {
|
) {
|
||||||
private static final char[][] INDENT_PATTERNS = new char[][] {
|
|
||||||
"|---".toCharArray(),
|
|
||||||
"|+++".toCharArray(),
|
|
||||||
};
|
|
||||||
|
|
||||||
public List<String> dumpToString() {
|
public List<String> dumpToString() {
|
||||||
final List<LProfileGraph.GraphNode> graphDFS = this.graph.getDFS();
|
final List<LProfileGraph.GraphNode> graphDFS = this.graph.getDFS();
|
||||||
final Reference2ReferenceOpenHashMap<LProfileGraph.GraphNode, ProfileNode> nodeMap = new Reference2ReferenceOpenHashMap<>();
|
final Reference2ReferenceOpenHashMap<LProfileGraph.GraphNode, ProfileNode> nodeMap = new Reference2ReferenceOpenHashMap<>();
|
||||||
@@ -232,14 +230,10 @@ public final class LeafProfiler {
|
|||||||
totalTime += node.totalTime;
|
totalTime += node.totalTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProfileNode profileNode;
|
final ArrayDeque<ProfileNode> flatOrderedNodes = new ArrayDeque<>();
|
||||||
final StringBuilder builder = new StringBuilder();
|
|
||||||
while ((profileNode = orderedNodes.pollFirst()) != null) {
|
|
||||||
if (profileNode.nodeId != LProfileGraph.ROOT_NODE && profileNode.totalCount == 0L) {
|
|
||||||
// skip nodes not recorded
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
ProfileNode profileNode;
|
||||||
|
while ((profileNode = orderedNodes.pollFirst()) != null) {
|
||||||
final int depth = profileNode.depth;
|
final int depth = profileNode.depth;
|
||||||
profileNode.children.sort((final ProfileNode p1, final ProfileNode p2) -> {
|
profileNode.children.sort((final ProfileNode p1, final ProfileNode p2) -> {
|
||||||
final int typeCompare = p1.profiler.type().compareTo(p2.profiler.type());
|
final int typeCompare = p1.profiler.type().compareTo(p2.profiler.type());
|
||||||
@@ -257,12 +251,32 @@ public final class LeafProfiler {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
boolean first = true;
|
||||||
for (int i = profileNode.children.size() - 1; i >= 0; --i) {
|
for (int i = profileNode.children.size() - 1; i >= 0; --i) {
|
||||||
final ProfileNode child = profileNode.children.get(i);
|
final ProfileNode child = profileNode.children.get(i);
|
||||||
|
if (child.totalCount == 0L) {
|
||||||
|
// skip nodes not recorded
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (first) {
|
||||||
|
child.lastChild = true;
|
||||||
|
first = false;
|
||||||
|
}
|
||||||
child.depth = depth + 1;
|
child.depth = depth + 1;
|
||||||
orderedNodes.addFirst(child);
|
orderedNodes.addFirst(child);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
flatOrderedNodes.addLast(profileNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
final StringBuilder builder = new StringBuilder();
|
||||||
|
final IntList closed = new IntArrayList();
|
||||||
|
while ((profileNode = flatOrderedNodes.pollFirst()) != null) {
|
||||||
|
final int depth = profileNode.depth;
|
||||||
|
closed.removeIf((int d) -> d >= depth);
|
||||||
|
if (profileNode.lastChild) {
|
||||||
|
closed.add(depth);
|
||||||
|
}
|
||||||
if (profileNode.nodeId == LProfileGraph.ROOT_NODE) {
|
if (profileNode.nodeId == LProfileGraph.ROOT_NODE) {
|
||||||
// don't display root
|
// don't display root
|
||||||
continue;
|
continue;
|
||||||
@@ -280,9 +294,18 @@ public final class LeafProfiler {
|
|||||||
// <indent>#<name> avg X sum Y
|
// <indent>#<name> avg X sum Y
|
||||||
builder.setLength(0);
|
builder.setLength(0);
|
||||||
// prepare indent
|
// prepare indent
|
||||||
final char[] indent = INDENT_PATTERNS[ret.size() % INDENT_PATTERNS.length];
|
|
||||||
for (int i = 0; i < depth; ++i) {
|
for (int i = 0; i < depth; ++i) {
|
||||||
builder.append(indent);
|
if (i == depth - 1) {
|
||||||
|
if (flatOrderedNodes.peekFirst() == null || profileNode.lastChild) {
|
||||||
|
builder.append(" └─");
|
||||||
|
} else {
|
||||||
|
builder.append(" ├─");
|
||||||
|
}
|
||||||
|
} else if (!closed.contains(i + 1)) {
|
||||||
|
builder.append(" │ ");
|
||||||
|
} else {
|
||||||
|
builder.append(" ");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (profilerEntry.type()) {
|
switch (profilerEntry.type()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user