mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2025-01-11 23:06:09 +01:00
A bit of backporting
- Backport general changes from 1.19 - Fix Javadoc of PartialModel - Remove default Model#getType implementation - Increment version to 0.6.8 - Update Parchment
This commit is contained in:
parent
edd6c736cf
commit
b76e8b1a89
23 changed files with 111 additions and 111 deletions
|
@ -13,6 +13,17 @@ insert_final_newline = true
|
|||
[*.json]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
max_line_length = 500
|
||||
ij_json_keep_blank_lines_in_code = 0
|
||||
ij_json_keep_indents_on_empty_lines = false
|
||||
ij_json_keep_line_breaks = true
|
||||
ij_json_space_after_colon = true
|
||||
ij_json_space_after_comma = true
|
||||
ij_json_space_before_colon = true
|
||||
ij_json_space_before_comma = false
|
||||
ij_json_spaces_within_braces = true
|
||||
ij_json_spaces_within_brackets = false
|
||||
ij_json_wrap_long_lines = false
|
||||
|
||||
[*.java]
|
||||
indent_style = tab
|
||||
|
|
1
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
1
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
|
@ -59,6 +59,7 @@ body:
|
|||
label: Mod Version
|
||||
description: The version of the mod you were using when the bug occured
|
||||
options:
|
||||
- "0.6.8"
|
||||
- "0.6.7"
|
||||
- "0.6.6"
|
||||
- "0.6.5"
|
||||
|
|
|
@ -44,6 +44,7 @@ minecraft {
|
|||
property 'mixin.debug.export', 'true'
|
||||
property 'mixin.env.remapRefMap', 'true'
|
||||
property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg"
|
||||
property 'flw.loadRenderDoc', 'true'
|
||||
|
||||
arg '-mixin.config=flywheel.mixins.json'
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ org.gradle.jvmargs = -Xmx3G
|
|||
org.gradle.daemon = false
|
||||
|
||||
# mod version info
|
||||
mod_version = 0.6.6
|
||||
mod_version = 0.6.8
|
||||
artifact_minecraft_version = 1.18.2
|
||||
|
||||
minecraft_version = 1.18.2
|
||||
|
@ -14,7 +14,7 @@ mixingradle_version = 0.7-SNAPSHOT
|
|||
mixin_version = 0.8.5
|
||||
librarian_version = 1.+
|
||||
cursegradle_version = 1.4.0
|
||||
parchment_version = 2022.07.10
|
||||
parchment_version = 2022.11.06
|
||||
|
||||
# curseforge info
|
||||
projectId = 486392
|
||||
|
|
|
@ -39,7 +39,7 @@ public class MappedBuffer extends VecBuffer implements AutoCloseable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void close() throws Exception {
|
||||
public void close() {
|
||||
flush();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.jozufozu.flywheel.backend.instancing;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
@ -359,4 +360,14 @@ public abstract class InstanceManager<T> implements InstancingEngine.OriginShift
|
|||
LightUpdater.get(value.world).removeListener(value);
|
||||
}
|
||||
}
|
||||
|
||||
public void queueAddAll(Collection<? extends T> objects) {
|
||||
if (!Backend.isOn() || objects.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
synchronized (queuedAdditions) {
|
||||
queuedAdditions.addAll(objects);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.jozufozu.flywheel.backend.model;
|
||||
|
||||
import com.jozufozu.flywheel.core.Formats;
|
||||
import com.jozufozu.flywheel.core.model.Model;
|
||||
|
||||
public enum FallbackAllocator implements ModelAllocator {
|
||||
|
@ -7,7 +8,7 @@ public enum FallbackAllocator implements ModelAllocator {
|
|||
|
||||
@Override
|
||||
public BufferedModel alloc(Model model, Callback allocationCallback) {
|
||||
IndexedModel out = new IndexedModel(model);
|
||||
IndexedModel out = new IndexedModel(model, Formats.POS_TEX_NORMAL);
|
||||
allocationCallback.onAlloc(out);
|
||||
return out;
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ import com.jozufozu.flywheel.core.model.Model;
|
|||
*/
|
||||
public class IndexedModel implements BufferedModel {
|
||||
|
||||
protected final VertexType type;
|
||||
protected final Model model;
|
||||
protected final GlPrimitive primitiveMode;
|
||||
protected ElementBuffer ebo;
|
||||
|
@ -27,6 +28,11 @@ public class IndexedModel implements BufferedModel {
|
|||
protected boolean deleted;
|
||||
|
||||
public IndexedModel(Model model) {
|
||||
this(model, model.getType());
|
||||
}
|
||||
|
||||
public IndexedModel(Model model, VertexType type) {
|
||||
this.type = type;
|
||||
this.model = model;
|
||||
this.primitiveMode = GlPrimitive.TRIANGLES;
|
||||
|
||||
|
@ -38,7 +44,8 @@ public class IndexedModel implements BufferedModel {
|
|||
|
||||
// mirror it in system memory, so we can write to it, and upload our model.
|
||||
try (MappedBuffer buffer = vbo.getBuffer()) {
|
||||
model.writeInto(buffer.unwrap());
|
||||
type.createWriter(buffer.unwrap())
|
||||
.writeVertexList(model.getReader());
|
||||
} catch (Exception e) {
|
||||
Flywheel.LOGGER.error(String.format("Error uploading model '%s':", model.name()), e);
|
||||
}
|
||||
|
@ -80,7 +87,7 @@ public class IndexedModel implements BufferedModel {
|
|||
|
||||
@Override
|
||||
public VertexType getType() {
|
||||
return model.getType();
|
||||
return type;
|
||||
}
|
||||
|
||||
public int getVertexCount() {
|
||||
|
|
|
@ -14,12 +14,12 @@ import net.minecraftforge.client.model.ForgeModelBakery;
|
|||
* A helper class for loading and accessing json models.
|
||||
* <br>
|
||||
* Creating a PartialModel will make the associated modelLocation automatically load.
|
||||
* PartialModels must be initialized during {@link net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent FMLClientSetupEvent}.
|
||||
* PartialModels must be initialized the mod class constructor.
|
||||
* <br>
|
||||
* Once {@link ModelBakeEvent} finishes, all PartialModels (with valid modelLocations)
|
||||
* will have their bakedModel fields populated.
|
||||
* <br>
|
||||
* Attempting to create a PartialModel after ModelRegistryEvent will cause an error.
|
||||
* Attempting to create a PartialModel after {@link ModelRegistryEvent} will cause an error.
|
||||
*/
|
||||
public class PartialModel {
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.jozufozu.flywheel.core.hardcoded;
|
|||
import java.util.List;
|
||||
|
||||
import com.jozufozu.flywheel.api.vertex.VertexList;
|
||||
import com.jozufozu.flywheel.api.vertex.VertexType;
|
||||
import com.jozufozu.flywheel.core.Formats;
|
||||
import com.jozufozu.flywheel.core.model.Model;
|
||||
import com.jozufozu.flywheel.core.vertex.PosTexNormalWriterUnsafe;
|
||||
|
@ -52,6 +53,11 @@ public class ModelPart implements Model {
|
|||
return reader;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VertexType getType() {
|
||||
return Formats.POS_TEX_NORMAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete() {
|
||||
if (reader instanceof AutoCloseable closeable) {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.jozufozu.flywheel.core.model;
|
||||
|
||||
import com.jozufozu.flywheel.api.vertex.VertexList;
|
||||
import com.jozufozu.flywheel.api.vertex.VertexType;
|
||||
import com.jozufozu.flywheel.core.Formats;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
|
||||
|
@ -12,10 +13,8 @@ import net.minecraft.world.level.block.state.BlockState;
|
|||
* A model of a single block.
|
||||
*/
|
||||
public class BlockModel implements Model {
|
||||
private static final PoseStack IDENTITY = new PoseStack();
|
||||
|
||||
private final VertexList reader;
|
||||
|
||||
private final String name;
|
||||
|
||||
public BlockModel(BlockState state) {
|
||||
|
@ -25,12 +24,21 @@ public class BlockModel implements Model {
|
|||
}
|
||||
|
||||
public BlockModel(BakedModel model, BlockState referenceState) {
|
||||
this(model, referenceState, IDENTITY);
|
||||
this(new BakedModelBuilder(model).withReferenceState(referenceState), referenceState.toString());
|
||||
}
|
||||
|
||||
public BlockModel(BakedModel model, BlockState referenceState, PoseStack ms) {
|
||||
reader = Formats.BLOCK.createReader(ModelUtil.getBufferBuilder(model, referenceState, ms));
|
||||
name = referenceState.toString();
|
||||
this(new BakedModelBuilder(model).withReferenceState(referenceState)
|
||||
.withPoseStack(ms), referenceState.toString());
|
||||
}
|
||||
|
||||
public BlockModel(Bufferable bufferable, String name) {
|
||||
this(bufferable.build(), name);
|
||||
}
|
||||
|
||||
public BlockModel(ShadeSeparatedBufferBuilder bufferBuilder, String name) {
|
||||
this.name = name;
|
||||
reader = Formats.BLOCK.createReader(bufferBuilder);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -48,6 +56,11 @@ public class BlockModel implements Model {
|
|||
return reader;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VertexType getType() {
|
||||
return Formats.BLOCK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete() {
|
||||
if (reader instanceof AutoCloseable closeable) {
|
||||
|
|
|
@ -5,7 +5,6 @@ import java.nio.ByteBuffer;
|
|||
import com.jozufozu.flywheel.api.vertex.VertexList;
|
||||
import com.jozufozu.flywheel.api.vertex.VertexType;
|
||||
import com.jozufozu.flywheel.backend.model.ElementBuffer;
|
||||
import com.jozufozu.flywheel.core.Formats;
|
||||
import com.jozufozu.flywheel.core.QuadConverter;
|
||||
|
||||
/**
|
||||
|
@ -42,9 +41,7 @@ public interface Model {
|
|||
*/
|
||||
int vertexCount();
|
||||
|
||||
default VertexType getType() {
|
||||
return Formats.POS_TEX_NORMAL;
|
||||
}
|
||||
VertexType getType();
|
||||
|
||||
// XXX Since this is public API (technically) we cannot make assumptions about what GL state this method can use or modify unless a contract is established.
|
||||
/**
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
package com.jozufozu.flywheel.core.model;
|
||||
|
||||
import com.jozufozu.flywheel.api.vertex.VertexList;
|
||||
import com.jozufozu.flywheel.api.vertex.VertexType;
|
||||
import com.jozufozu.flywheel.core.Formats;
|
||||
import com.mojang.blaze3d.vertex.BufferBuilder;
|
||||
|
||||
public class WorldModel implements Model {
|
||||
|
||||
private final VertexList reader;
|
||||
private final String name;
|
||||
|
||||
public WorldModel(BufferBuilder bufferBuilder, String name) {
|
||||
this.reader = Formats.BLOCK.createReader(bufferBuilder);
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String name() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VertexType getType() {
|
||||
return Formats.BLOCK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int vertexCount() {
|
||||
return reader.getVertexCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public VertexList getReader() {
|
||||
return reader;
|
||||
}
|
||||
}
|
|
@ -80,7 +80,7 @@ public final class WorldModelBuilder implements Bufferable {
|
|||
return this;
|
||||
}
|
||||
|
||||
public WorldModel intoMesh(String name) {
|
||||
return new WorldModel(ModelUtil.getBufferBuilder(this), name);
|
||||
public BlockModel intoMesh(String name) {
|
||||
return new BlockModel(ModelUtil.getBufferBuilder(this), name);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@ import org.lwjgl.system.MemoryUtil;
|
|||
|
||||
import com.jozufozu.flywheel.api.vertex.VertexList;
|
||||
import com.mojang.blaze3d.platform.MemoryTracker;
|
||||
import com.mojang.blaze3d.vertex.BufferBuilder;
|
||||
|
||||
public abstract class AbstractVertexList implements VertexList, AutoCloseable {
|
||||
|
||||
|
@ -22,15 +21,6 @@ public abstract class AbstractVertexList implements VertexList, AutoCloseable {
|
|||
init(copyFrom);
|
||||
}
|
||||
|
||||
public AbstractVertexList(BufferBuilder builder) {
|
||||
var pair = builder.popNextBuffer();
|
||||
ByteBuffer copyFrom = pair.getSecond();
|
||||
this.contents = MemoryTracker.create(copyFrom.capacity());
|
||||
this.vertexCount = pair.getFirst().vertexCount();
|
||||
this.base = MemoryUtil.memAddress(this.contents);
|
||||
init(copyFrom);
|
||||
}
|
||||
|
||||
private void init(ByteBuffer copyFrom) {
|
||||
this.contents.order(copyFrom.order());
|
||||
this.contents.put(copyFrom);
|
||||
|
|
|
@ -1,18 +1,17 @@
|
|||
package com.jozufozu.flywheel.core.vertex;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import com.jozufozu.flywheel.api.vertex.ShadedVertexList;
|
||||
import com.jozufozu.flywheel.core.model.ShadeSeparatedBufferBuilder;
|
||||
import com.jozufozu.flywheel.util.RenderMath;
|
||||
import com.mojang.blaze3d.vertex.BufferBuilder;
|
||||
|
||||
public class BlockVertexList extends AbstractVertexList {
|
||||
|
||||
private final int stride;
|
||||
|
||||
public BlockVertexList(BufferBuilder builder) {
|
||||
super(builder);
|
||||
this.stride = builder.getVertexFormat()
|
||||
.getVertexSize();
|
||||
public BlockVertexList(ByteBuffer copyFrom, int vertexCount, int stride) {
|
||||
super(copyFrom, vertexCount);
|
||||
this.stride = stride;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -93,9 +92,9 @@ public class BlockVertexList extends AbstractVertexList {
|
|||
|
||||
private final int unshadedStartVertex;
|
||||
|
||||
public Shaded(ShadeSeparatedBufferBuilder builder) {
|
||||
super(builder);
|
||||
unshadedStartVertex = builder.getUnshadedStartVertex();
|
||||
public Shaded(ByteBuffer copyFrom, int vertexCount, int stride, int unshadedStartVertex) {
|
||||
super(copyFrom, vertexCount, stride);
|
||||
this.unshadedStartVertex = unshadedStartVertex;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -18,9 +18,7 @@ public class ForgeEvents {
|
|||
|
||||
@SubscribeEvent
|
||||
public static void addToDebugScreen(RenderGameOverlayEvent.Text event) {
|
||||
|
||||
if (Minecraft.getInstance().options.renderDebug) {
|
||||
|
||||
InstancedRenderDispatcher.getDebugString(event.getRight());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
package com.jozufozu.flywheel.mixin;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import net.minecraft.client.main.Main;
|
||||
|
||||
@Mixin(Main.class)
|
||||
public class ClientMainMixin {
|
||||
|
||||
@Inject(method = "main", at = @At("HEAD"))
|
||||
private static void injectRenderDoc(CallbackInfo ci) {
|
||||
// Only try to load RenderDoc if a system property is set.
|
||||
if (System.getProperty("flw.loadRenderDoc") == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
System.loadLibrary("renderdoc");
|
||||
} catch (Throwable ignored) {
|
||||
// Oh well, we tried.
|
||||
// On Windows, RenderDoc installs to "C:\Program Files\RenderDoc\"
|
||||
System.err.println("Is RenderDoc in your PATH?");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,9 +3,7 @@ package com.jozufozu.flywheel.mixin;
|
|||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Group;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
|
@ -48,33 +46,8 @@ public class LevelRendererMixin {
|
|||
MinecraftForge.EVENT_BUS.post(new BeginFrameEvent(level, camera, frustum));
|
||||
}
|
||||
|
||||
@Unique
|
||||
private boolean flywheel$LayerRendered;
|
||||
|
||||
/**
|
||||
* This only gets injected if renderChunkLayer is not Overwritten
|
||||
*/
|
||||
@Group(name = "flywheel$renderLayer", min = 1, max = 2)
|
||||
@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/util/profiling/ProfilerFiller;pop()V", ordinal = 1), method = "renderChunkLayer")
|
||||
private void renderLayer(RenderType type, PoseStack stack, double camX, double camY, double camZ, Matrix4f p_172999_, CallbackInfo ci) {
|
||||
flywheel$renderLayer(type, stack, camX, camY, camZ);
|
||||
flywheel$LayerRendered = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* This always gets injected.
|
||||
*/
|
||||
@Group(name = "flywheel$renderLayer")
|
||||
@Inject(at = @At("TAIL"), method = "renderChunkLayer")
|
||||
private void renderLayerSodium(RenderType type, PoseStack stack, double camX, double camY, double camZ, Matrix4f p_172999_, CallbackInfo ci) {
|
||||
if (!flywheel$LayerRendered) {
|
||||
flywheel$renderLayer(type, stack, camX, camY, camZ);
|
||||
}
|
||||
flywheel$LayerRendered = false;
|
||||
}
|
||||
|
||||
@Unique
|
||||
private void flywheel$renderLayer(RenderType type, PoseStack stack, double camX, double camY, double camZ) {
|
||||
private void renderLayer(RenderType type, PoseStack stack, double camX, double camY, double camZ, Matrix4f projection, CallbackInfo ci) {
|
||||
MinecraftForge.EVENT_BUS.post(new RenderLayerEvent(level, type, stack, renderBuffers, camX, camY, camZ));
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package com.jozufozu.flywheel.mixin;
|
||||
package com.jozufozu.flywheel.mixin.instancemanage;
|
||||
|
||||
import java.util.Set;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.jozufozu.flywheel.mixin;
|
||||
package com.jozufozu.flywheel.mixin.instancemanage;
|
||||
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
|
@ -1,4 +1,4 @@
|
|||
package com.jozufozu.flywheel.mixin;
|
||||
package com.jozufozu.flywheel.mixin.instancemanage;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
|
@ -10,13 +10,11 @@
|
|||
"BufferBuilderMixin",
|
||||
"CameraMixin",
|
||||
"ClientLevelMixin",
|
||||
"ChunkRebuildHooksMixin",
|
||||
"ClientMainMixin",
|
||||
"EntityTypeMixin",
|
||||
"FixFabulousDepthMixin",
|
||||
"FrustumMixin",
|
||||
"GlStateManagerMixin",
|
||||
"InstanceAddMixin",
|
||||
"InstanceRemoveMixin",
|
||||
"LevelRendererAccessor",
|
||||
"LevelRendererMixin",
|
||||
"PausedPartialTickAccessor",
|
||||
|
@ -24,6 +22,9 @@
|
|||
"RenderTypeMixin",
|
||||
"atlas.AtlasDataMixin",
|
||||
"atlas.SheetDataAccessor",
|
||||
"instancemanage.ChunkRebuildHooksMixin",
|
||||
"instancemanage.InstanceAddMixin",
|
||||
"instancemanage.InstanceRemoveMixin",
|
||||
"light.LightUpdateMixin",
|
||||
"light.NetworkLightUpdateMixin",
|
||||
"matrix.Matrix3fMixin",
|
||||
|
|
Loading…
Reference in a new issue