mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2024-12-27 23:47:09 +01:00
It renders stuff
- The lightmap moved - Begin to move away from access transformers - .textureManager -> .getTextureManager() - RIP cutout, saw that coming
This commit is contained in:
parent
5784cb975d
commit
d53c9b0a32
14 changed files with 71 additions and 144 deletions
|
@ -41,6 +41,7 @@ minecraft {
|
|||
property 'forge.logging.markers', ''
|
||||
property 'forge.logging.console.level', 'debug'
|
||||
property 'fml.earlyprogresswindow', 'false'
|
||||
property 'mixin.debug.export', 'true'
|
||||
|
||||
arg "-mixin.config=flywheel.mixins.json"
|
||||
|
||||
|
@ -100,7 +101,7 @@ dependencies {
|
|||
|
||||
//implementation "org.joml:joml:1.10.1"
|
||||
|
||||
//annotationProcessor 'org.spongepowered:mixin:0.8.4:processor'
|
||||
annotationProcessor 'org.spongepowered:mixin:0.8.4:processor'
|
||||
}
|
||||
|
||||
// Example for how to get properties into the manifest for reading by the runtime..
|
||||
|
|
|
@ -8,9 +8,11 @@ import com.jozufozu.flywheel.core.Contexts;
|
|||
import com.jozufozu.flywheel.core.shader.WorldProgram;
|
||||
import com.jozufozu.flywheel.event.BeginFrameEvent;
|
||||
import com.jozufozu.flywheel.event.RenderLayerEvent;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.client.renderer.ShaderInstance;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
|
||||
|
@ -99,6 +101,10 @@ public class InstanceWorld {
|
|||
public void renderLayer(RenderLayerEvent event) {
|
||||
event.type.setupRenderState();
|
||||
|
||||
ShaderInstance shader = RenderSystem.getShader();
|
||||
if (shader != null)
|
||||
shader.apply();
|
||||
|
||||
materialManager.render(event.layer, event.viewProjection, event.camX, event.camY, event.camZ);
|
||||
|
||||
event.type.clearRenderState();
|
||||
|
|
|
@ -34,7 +34,7 @@ public class TextureRenderState implements IRenderState {
|
|||
@Override
|
||||
public void bind() {
|
||||
unit.makeActive();
|
||||
Minecraft.getInstance().textureManager.bindForSetup(location);
|
||||
Minecraft.getInstance().getTextureManager().bindForSetup(location);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -16,7 +16,7 @@ public class AtlasInfo {
|
|||
private static final Map<ResourceLocation, SheetData> sheetData = new HashMap<>();
|
||||
|
||||
public static TextureAtlas getAtlas(ResourceLocation name) {
|
||||
AbstractTexture texture = Minecraft.getInstance().textureManager.getTexture(name);
|
||||
AbstractTexture texture = Minecraft.getInstance().getTextureManager().getTexture(name);
|
||||
|
||||
if (texture instanceof TextureAtlas)
|
||||
return (TextureAtlas) texture;
|
||||
|
|
|
@ -14,6 +14,7 @@ import com.jozufozu.flywheel.backend.material.MaterialManagerImpl;
|
|||
import com.jozufozu.flywheel.backend.state.RenderLayer;
|
||||
import com.jozufozu.flywheel.core.Contexts;
|
||||
import com.jozufozu.flywheel.event.ReloadRenderersEvent;
|
||||
import com.jozufozu.flywheel.mixin.LevelRendererAccessor;
|
||||
import com.jozufozu.flywheel.util.Lazy;
|
||||
import com.jozufozu.flywheel.util.Pair;
|
||||
|
||||
|
@ -66,7 +67,7 @@ public class CrumblingRenderer {
|
|||
|
||||
InstanceManager<BlockEntity> renderer = state.instanceManager;
|
||||
|
||||
TextureManager textureManager = Minecraft.getInstance().textureManager;
|
||||
TextureManager textureManager = Minecraft.getInstance().getTextureManager();
|
||||
Camera info = Minecraft.getInstance().gameRenderer.getMainCamera();
|
||||
|
||||
MaterialManagerImpl<CrumblingProgram> materials = state.materialManager;
|
||||
|
@ -102,11 +103,11 @@ public class CrumblingRenderer {
|
|||
* Associate each breaking stage with a list of all tile entities at that stage.
|
||||
*/
|
||||
private static Int2ObjectMap<List<BlockEntity>> getActiveStageTiles(ClientLevel world) {
|
||||
Long2ObjectMap<SortedSet<BlockDestructionProgress>> breakingProgressions = Minecraft.getInstance().levelRenderer.destructionProgress;
|
||||
|
||||
Int2ObjectMap<List<BlockEntity>> breakingEntities = new Int2ObjectArrayMap<>();
|
||||
|
||||
for (Long2ObjectMap.Entry<SortedSet<BlockDestructionProgress>> entry : breakingProgressions.long2ObjectEntrySet()) {
|
||||
for (Long2ObjectMap.Entry<SortedSet<BlockDestructionProgress>> entry : ((LevelRendererAccessor) Minecraft.getInstance().levelRenderer).getDestructionProgress()
|
||||
.long2ObjectEntrySet()) {
|
||||
BlockPos breakingPos = BlockPos.of(entry.getLongKey());
|
||||
|
||||
SortedSet<BlockDestructionProgress> progresses = entry.getValue();
|
||||
|
|
|
@ -33,7 +33,7 @@ public class WorldProgram extends ExtensibleGlProgram {
|
|||
|
||||
protected void registerSamplers() {
|
||||
uBlockAtlas = setSamplerBinding("uBlockAtlas", 0);
|
||||
uLightMap = setSamplerBinding("uLightMap", 2);
|
||||
uLightMap = setSamplerBinding("uLightMap", 1);
|
||||
}
|
||||
|
||||
public void uploadViewProjection(Matrix4f viewProjection) {
|
||||
|
|
|
@ -20,6 +20,7 @@ import net.minecraft.util.ClassInstanceMultiMap;
|
|||
@Mixin(LevelRenderer.class)
|
||||
public class CancelEntityRenderMixin {
|
||||
|
||||
// TODO: Don't use redirect
|
||||
@Group(name = "entityFilter", min = 1, max = 1)
|
||||
@Redirect(method = "renderLevel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/ClientLevel;entitiesForRendering()Ljava/lang/Iterable;"))
|
||||
private Iterable<Entity> filterEntities(ClientLevel world) {
|
||||
|
@ -37,19 +38,19 @@ public class CancelEntityRenderMixin {
|
|||
return entities;
|
||||
}
|
||||
|
||||
@Group(name = "entityFilter")
|
||||
@Redirect(method = "renderLevel", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/ClassInstanceMultiMap;iterator()Ljava/util/Iterator;"))
|
||||
private Iterator<Entity> filterEntitiesOF(ClassInstanceMultiMap<Entity> classInheritanceMultiMap) {
|
||||
if (Backend.getInstance()
|
||||
.canUseInstancing()) {
|
||||
|
||||
ArrayList<Entity> filtered = Lists.newArrayList(classInheritanceMultiMap);
|
||||
|
||||
InstancedRenderRegistry r = InstancedRenderRegistry.getInstance();
|
||||
filtered.removeIf(r::shouldSkipRender);
|
||||
|
||||
return filtered.iterator();
|
||||
}
|
||||
return classInheritanceMultiMap.iterator();
|
||||
}
|
||||
// @Group(name = "entityFilter")
|
||||
// @Redirect(method = "renderLevel", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/ClassInstanceMultiMap;iterator()Ljava/util/Iterator;"))
|
||||
// private Iterator<Entity> filterEntitiesOF(ClassInstanceMultiMap<Entity> classInheritanceMultiMap) {
|
||||
// if (Backend.getInstance()
|
||||
// .canUseInstancing()) {
|
||||
//
|
||||
// ArrayList<Entity> filtered = Lists.newArrayList(classInheritanceMultiMap);
|
||||
//
|
||||
// InstancedRenderRegistry r = InstancedRenderRegistry.getInstance();
|
||||
// filtered.removeIf(r::shouldSkipRender);
|
||||
//
|
||||
// return filtered.iterator();
|
||||
// }
|
||||
// return classInheritanceMultiMap.iterator();
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -12,10 +12,7 @@ import com.jozufozu.flywheel.backend.instancing.InstancedRenderRegistry;
|
|||
|
||||
import net.minecraft.client.renderer.chunk.ChunkRenderDispatcher;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@Mixin(ChunkRenderDispatcher.CompiledChunk.class)
|
||||
public class CancelTileEntityRenderMixin {
|
||||
|
||||
|
|
|
@ -1,94 +0,0 @@
|
|||
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.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import com.jozufozu.flywheel.backend.Backend;
|
||||
|
||||
import net.minecraft.client.multiplayer.ClientChunkCache;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.world.level.chunk.ChunkBiomeContainer;
|
||||
import net.minecraft.world.level.chunk.ChunkSource;
|
||||
import net.minecraft.world.level.chunk.LevelChunk;
|
||||
import net.minecraft.world.level.chunk.ChunkStatus;
|
||||
import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
|
||||
import java.util.BitSet;
|
||||
|
||||
@Mixin(ClientChunkCache.class)
|
||||
public abstract class FastChunkProviderMixin extends ChunkSource {
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
private ClientLevel level;
|
||||
@Unique
|
||||
private int lastX;
|
||||
@Unique
|
||||
private int lastZ;
|
||||
|
||||
@Unique
|
||||
private ChunkAccess lastChunk;
|
||||
|
||||
@Inject(method = "getChunk",
|
||||
at = @At("HEAD"),
|
||||
cancellable = true)
|
||||
public void returnCachedChunk(int x, int z, ChunkStatus status, boolean create, CallbackInfoReturnable<ChunkAccess> cir) {
|
||||
if (Backend.getInstance().chunkCachingEnabled && status.isOrAfter(ChunkStatus.FULL)) {
|
||||
synchronized (level) {
|
||||
if (lastChunk != null && x == lastX && z == lastZ) {
|
||||
cir.setReturnValue(lastChunk);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "getChunk",
|
||||
at = @At("RETURN"))
|
||||
public void cacheChunk(int x, int z, ChunkStatus status, boolean create, CallbackInfoReturnable<ChunkAccess> cir) {
|
||||
if (Backend.getInstance().chunkCachingEnabled && status.isOrAfter(ChunkStatus.FULL)) {
|
||||
synchronized (level) {
|
||||
lastChunk = cir.getReturnValue();
|
||||
lastX = x;
|
||||
lastZ = z;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "drop", at = @At("HEAD"))
|
||||
public void invalidateOnDrop(int x, int z, CallbackInfo ci) {
|
||||
if (Backend.getInstance().chunkCachingEnabled) {
|
||||
synchronized (level) {
|
||||
if (x == lastX && z == lastZ) lastChunk = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "replaceWithPacketData", at = @At("HEAD"))
|
||||
public void invalidateOnPacket(int x, int z, ChunkBiomeContainer p_171618_, FriendlyByteBuf p_171619_, CompoundTag p_171620_, BitSet p_171621_, CallbackInfoReturnable<LevelChunk> cir) {
|
||||
if (Backend.getInstance().chunkCachingEnabled) {
|
||||
synchronized (level) {
|
||||
if (x == lastX && z == lastZ) lastChunk = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Redirect(method = "isTickingChunk", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/ClientChunkProvider;hasChunk(II)Z"))
|
||||
public boolean redirectTicking(ClientChunkCache clientChunkProvider, int x, int z) {
|
||||
if (Backend.getInstance().chunkCachingEnabled) {
|
||||
synchronized (level) {
|
||||
if (lastChunk != null && x == lastX && z == lastZ) return true;
|
||||
}
|
||||
}
|
||||
|
||||
return clientChunkProvider.hasChunk(x, z);
|
||||
}
|
||||
}
|
|
@ -9,26 +9,24 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|||
|
||||
import com.jozufozu.flywheel.backend.instancing.InstancedRenderDispatcher;
|
||||
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.chunk.LevelChunk;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@Mixin(value = LevelChunk.class, priority = 1100) // this and create.mixins.json have high priority to load after Performant
|
||||
public class TileWorldHookMixin {
|
||||
@Mixin(LevelChunk.class)
|
||||
public class InstanceAddMixin {
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
Level level;
|
||||
|
||||
@Inject(at = @At(value = "INVOKE_ASSIGN", target = "Lnet/minecraft/world/level/block/entity/BlockEntity;clearRemoved()V"),
|
||||
method = "setBlockEntity")
|
||||
private void onAddTile(BlockEntity te, CallbackInfo ci) {
|
||||
if (level.isClientSide) {
|
||||
InstancedRenderDispatcher.getTiles(level)
|
||||
.queueAdd(te);
|
||||
}
|
||||
@Inject(method = "setBlockEntity",
|
||||
at = @At(value = "INVOKE_ASSIGN", target = "Ljava/util/Map;put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"))
|
||||
private void tileAdded(BlockEntity be, CallbackInfo ci) {
|
||||
if (level.isClientSide) InstancedRenderDispatcher.getTiles(this.level)
|
||||
.add(be);
|
||||
}
|
||||
}
|
|
@ -15,15 +15,25 @@ import net.minecraft.world.level.block.entity.BlockEntity;
|
|||
import net.minecraft.world.level.Level;
|
||||
|
||||
@Mixin(BlockEntity.class)
|
||||
public class TileRemoveMixin {
|
||||
public class InstanceRemoveMixin {
|
||||
|
||||
@Shadow
|
||||
@Nullable
|
||||
protected Level level;
|
||||
|
||||
@Inject(at = @At("TAIL"), method = "setRemoved")
|
||||
private void onRemove(CallbackInfo ci) {
|
||||
private void removeInstance(CallbackInfo ci) {
|
||||
if (level instanceof ClientLevel) InstancedRenderDispatcher.getTiles(this.level)
|
||||
.remove((BlockEntity) (Object) this);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Don't do this.
|
||||
// * It can cause infinite loops if an instance class tries to access another tile entity in its constructor.
|
||||
// */
|
||||
// @Inject(at = @At("TAIL"), method = "clearRemoved")
|
||||
// private void addInstance(CallbackInfo ci) {
|
||||
// if (level.isClientSide) InstancedRenderDispatcher.getTiles(this.level)
|
||||
// .add((BlockEntity) (Object) this);
|
||||
// }
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package com.jozufozu.flywheel.mixin;
|
||||
|
||||
import java.util.SortedSet;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
|
||||
import net.minecraft.client.renderer.LevelRenderer;
|
||||
import net.minecraft.server.level.BlockDestructionProgress;
|
||||
|
||||
@Mixin(LevelRenderer.class)
|
||||
public interface LevelRendererAccessor {
|
||||
@Accessor
|
||||
Long2ObjectMap<SortedSet<BlockDestructionProgress>> getDestructionProgress();
|
||||
}
|
|
@ -2,12 +2,6 @@
|
|||
# Don't jitter when game is paused
|
||||
public net.minecraft.client.Minecraft f_91013_ #renderPartialTicksPaused
|
||||
|
||||
# Expose fog state for use in flywheel shaders
|
||||
public com.mojang.blaze3d.platform.GlStateManager$FogState
|
||||
public com.mojang.blaze3d.platform.GlStateManager f_84068_ #FOG
|
||||
public com.mojang.blaze3d.platform.GlStateManager$BooleanState
|
||||
public com.mojang.blaze3d.platform.GlStateManager$BooleanState f_84586_ #field_179201_b
|
||||
|
||||
# For uploading matrices as vertex attributes.
|
||||
public com.mojang.math.Matrix3f f_8134_ #a00
|
||||
public com.mojang.math.Matrix3f f_8135_ #a01
|
||||
|
@ -35,6 +29,3 @@ public com.mojang.math.Matrix4f f_27615_ #a30
|
|||
public com.mojang.math.Matrix4f f_27616_ #a31
|
||||
public com.mojang.math.Matrix4f f_27617_ #a32
|
||||
public com.mojang.math.Matrix4f f_27618_ #a33
|
||||
|
||||
# For fancy breaking overlay rendering
|
||||
public net.minecraft.client.renderer.LevelRenderer f_109409_ #blockBreakingProgressions
|
|
@ -10,15 +10,15 @@
|
|||
"FixFabulousDepthMixin",
|
||||
"RenderHooksMixin",
|
||||
"ShaderCloseMixin",
|
||||
"TileRemoveMixin",
|
||||
"TileWorldHookMixin",
|
||||
"atlas.AtlasDataMixin",
|
||||
"atlas.SheetDataAccessor",
|
||||
"light.LightUpdateMixin",
|
||||
"light.NetworkLightUpdateMixin",
|
||||
"FastChunkProviderMixin"
|
||||
"LevelRendererAccessor",
|
||||
"InstanceAddMixin",
|
||||
"InstanceRemoveMixin"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 0
|
||||
"defaultRequire": 1
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue