Merge branch 'dev' into shader-pipeline

This commit is contained in:
Jozsef 2021-07-02 13:23:02 -07:00
commit fa5d586f0a
7 changed files with 59 additions and 19 deletions

View File

@ -35,7 +35,7 @@ breaking changes, and I make no guarantees of backwards compatibility.
### Getting Started (For Developers)
Add the following repo to your `build.gradle`:
Add the following repo and dependency to your `build.gradle`:
```groovy
repositories {
@ -44,12 +44,18 @@ repositories {
url "https://maven.tterrag.com/"
}
}
```
Then add Flywheel as a dependency:
```groovy
dependencies {
implementation fg.deobf("com.jozufozu.flywheel:Flywheel:1.16-0.0.2.9")
implementation fg.deobf("com.jozufozu.flywheel:Flywheel:${flywheel_version}")
}
```
`${flywheel_version}` gets replaced by the version of Flywheel you want to use, eg. `0.0.3.18`
For a list of available Flywheel versions, you can check [the maven](https://maven.tterrag.com/com/jozufozu/flywheel/Flywheel/).
If you aren't using mixed mappings (or just want to be safe), add the following properties to your run configurations:
```groovy
property 'mixin.env.remapRefMap', 'true'
property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg"
```
This ensures that Flywheel's mixins get properly loaded in your dev env.

View File

@ -41,6 +41,7 @@ minecraft {
property 'forge.logging.markers', ''
property 'forge.logging.console.level', 'debug'
property 'fml.earlyprogresswindow', 'false'
arg "-mixin.config=flywheel.mixins.json"

View File

@ -50,8 +50,8 @@ import net.minecraftforge.fml.common.Mod;
@Mod.EventBusSubscriber(Dist.CLIENT)
public class InstancedRenderDispatcher {
private static final WorldAttached<EntityInstanceManager> entityInstanceManager = new WorldAttached<>(world -> new EntityInstanceManager(Contexts.WORLD.getMaterialManager(world)));
private static final WorldAttached<TileInstanceManager> tileInstanceManager = new WorldAttached<>(world -> new TileInstanceManager(Contexts.WORLD.getMaterialManager(world)));
private static final WorldAttached<InstanceManager<Entity>> entityInstanceManager = new WorldAttached<>(world -> new EntityInstanceManager(Contexts.WORLD.getMaterialManager(world)));
private static final WorldAttached<InstanceManager<TileEntity>> tileInstanceManager = new WorldAttached<>(world -> new TileInstanceManager(Contexts.WORLD.getMaterialManager(world)));
private static final LazyValue<Vector<CrumblingInstanceManager>> blockBreaking = new LazyValue<>(() -> {
Vector<CrumblingInstanceManager> renderers = new Vector<>(10);
@ -62,12 +62,12 @@ public class InstancedRenderDispatcher {
});
@Nonnull
public static TileInstanceManager getTiles(IWorld world) {
public static InstanceManager<TileEntity> getTiles(IWorld world) {
return tileInstanceManager.get(world);
}
@Nonnull
public static EntityInstanceManager getEntities(IWorld world) {
public static InstanceManager<Entity> getEntities(IWorld world) {
return entityInstanceManager.get(world);
}
@ -190,10 +190,10 @@ public class InstancedRenderDispatcher {
Contexts.WORLD.getMaterialManager(world)
.delete();
TileInstanceManager tiles = tileInstanceManager.replace(world);
InstanceManager<TileEntity> tiles = tileInstanceManager.replace(world);
world.loadedTileEntityList.forEach(tiles::add);
EntityInstanceManager entities = entityInstanceManager.replace(world);
InstanceManager<Entity> entities = entityInstanceManager.replace(world);
world.getAllEntities()
.forEach(entities::add);
}

View File

@ -10,6 +10,7 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import com.jozufozu.flywheel.backend.instancing.InstanceManager;
import com.jozufozu.flywheel.backend.instancing.InstancedRenderDispatcher;
import com.jozufozu.flywheel.backend.instancing.tile.TileInstanceManager;
@ -46,7 +47,7 @@ public class TileWorldHookMixin {
@Inject(at = @At(value = "INVOKE", target = "Ljava/util/Set;clear()V", ordinal = 0), method = "tickBlockEntities")
private void onChunkUnload(CallbackInfo ci) {
if (isRemote) {
TileInstanceManager kineticRenderer = InstancedRenderDispatcher.getTiles(self);
InstanceManager<TileEntity> kineticRenderer = InstancedRenderDispatcher.getTiles(self);
for (TileEntity tile : tileEntitiesToBeRemoved) {
kineticRenderer.remove(tile);
}

View File

@ -7,11 +7,17 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import com.jozufozu.flywheel.backend.instancing.InstanceManager;
import com.jozufozu.flywheel.backend.instancing.InstancedRenderDispatcher;
import com.jozufozu.flywheel.backend.instancing.entity.EntityInstanceManager;
import com.jozufozu.flywheel.backend.instancing.tile.TileInstanceManager;
import com.jozufozu.flywheel.light.LightUpdater;
import com.jozufozu.flywheel.util.ChunkUtil;
import net.minecraft.client.multiplayer.ClientChunkProvider;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.entity.Entity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.SectionPos;
import net.minecraft.world.LightType;
import net.minecraft.world.chunk.AbstractChunkProvider;
@ -38,17 +44,19 @@ public abstract class LightUpdateMixin extends AbstractChunkProvider {
int sectionY = pos.getSectionY();
if (chunk != null) {
if (ChunkUtil.isValidSection(chunk, sectionY)) {
InstanceManager<TileEntity> tiles = InstancedRenderDispatcher.getTiles(world);
InstanceManager<Entity> entities = InstancedRenderDispatcher.getEntities(world);
chunk.getTileEntityMap()
.entrySet()
.stream()
.filter(entry -> SectionPos.toChunk(entry.getKey()
.getY()) == sectionY)
.map(Map.Entry::getValue)
.forEach(InstancedRenderDispatcher.getTiles(world)::onLightUpdate);
.forEach(tiles::onLightUpdate);
if (sectionY >= 0) // TODO: 1.17
chunk.getEntityLists()[sectionY].forEach(InstancedRenderDispatcher.getEntities(world)::onLightUpdate);
chunk.getEntityLists()[sectionY].forEach(entities::onLightUpdate);
}
LightUpdater.getInstance()

View File

@ -8,13 +8,16 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import com.jozufozu.flywheel.backend.RenderWork;
import com.jozufozu.flywheel.backend.instancing.InstanceManager;
import com.jozufozu.flywheel.backend.instancing.InstancedRenderDispatcher;
import com.jozufozu.flywheel.light.LightUpdater;
import net.minecraft.client.Minecraft;
import net.minecraft.client.network.play.ClientPlayNetHandler;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.entity.Entity;
import net.minecraft.network.play.server.SUpdateLightPacket;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ClassInheritanceMultiMap;
import net.minecraft.world.chunk.Chunk;
@ -35,13 +38,16 @@ public class NetworkLightUpdateMixin {
.getChunk(chunkX, chunkZ, false);
if (chunk != null) {
InstanceManager<TileEntity> tiles = InstancedRenderDispatcher.getTiles(world);
InstanceManager<Entity> entities = InstancedRenderDispatcher.getEntities(world);
chunk.getTileEntityMap()
.values()
.forEach(InstancedRenderDispatcher.getTiles(world)::onLightUpdate);
.forEach(tiles::onLightUpdate);
Arrays.stream(chunk.getEntityLists())
.flatMap(ClassInheritanceMultiMap::stream)
.forEach(InstancedRenderDispatcher.getEntities(world)::onLightUpdate);
.forEach(entities::onLightUpdate);
}
LightUpdater.getInstance()

View File

@ -0,0 +1,18 @@
package com.jozufozu.flywheel.util;
import javax.annotation.Nullable;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.ChunkSection;
public class ChunkUtil {
public static boolean isValidSection(@Nullable Chunk chunk, int sectionY) {
if (chunk == null) return false;
// TODO: 1.17
ChunkSection[] sections = chunk.getSections();
return sectionY >= 0 && sectionY < sections.length;
}
}