mirror of
https://github.com/FabricMC/fabric.git
synced 2025-04-21 11:20:55 -04:00
21w37a: Finish porting mixins + fix test mod, runs in prod now.
This commit is contained in:
parent
fb712d3a80
commit
d11c59e0d5
4 changed files with 36 additions and 22 deletions
build.gradle
fabric-renderer-api-v1/src/testmod/java/net/fabricmc/fabric/test/renderer/simple
fabric-rendering-data-attachment-v1/src/main/java/net/fabricmc/fabric/mixin/rendering/data/attachment/client
fabric-rendering-v1/src/main/java/net/fabricmc/fabric/mixin/client/rendering
|
@ -9,7 +9,7 @@ plugins {
|
|||
id "eclipse"
|
||||
id "idea"
|
||||
id "maven-publish"
|
||||
id "fabric-loom" version "0.10.13" apply false
|
||||
id "fabric-loom" version "0.10.14" apply false
|
||||
id "org.cadixdev.licenser" version "0.6.1"
|
||||
id "org.ajoberstar.grgit" version "3.1.0"
|
||||
id "com.matthewprenger.cursegradle" version "1.4.0"
|
||||
|
@ -21,7 +21,7 @@ def ENV = System.getenv()
|
|||
class Globals {
|
||||
static def baseVersion = "0.40.1"
|
||||
static def mcVersion = "21w37a"
|
||||
static def yarnVersion = "+build.8"
|
||||
static def yarnVersion = "+build.10"
|
||||
static def loaderVersion = "0.11.7"
|
||||
static def preRelease = true
|
||||
}
|
||||
|
@ -261,6 +261,11 @@ subprojects {
|
|||
loom.disableDeprecatedPomGeneration(publishing.publications.mavenJava)
|
||||
|
||||
javadoc.enabled = false
|
||||
|
||||
afterEvaluate {
|
||||
genSources.enabled = false
|
||||
unpickJar.enabled = false
|
||||
}
|
||||
}
|
||||
|
||||
task remapMavenJar(type: net.fabricmc.loom.task.RemapJarTask, dependsOn: jar) {
|
||||
|
|
|
@ -26,6 +26,7 @@ import net.minecraft.util.Identifier;
|
|||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.network.packet.s2c.play.BlockEntityUpdateS2CPacket;
|
||||
|
||||
import net.fabricmc.fabric.api.rendering.data.v1.RenderAttachmentBlockEntity;
|
||||
import net.fabricmc.fabric.api.util.NbtType;
|
||||
|
@ -85,4 +86,14 @@ public final class FrameBlockEntity extends BlockEntity implements RenderAttachm
|
|||
public Block getRenderAttachmentData() {
|
||||
return this.block;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntityUpdateS2CPacket method_38235() {
|
||||
return BlockEntityUpdateS2CPacket.method_38585(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NbtCompound toInitialChunkDataNbt() {
|
||||
return this.createNbt();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,14 +20,14 @@ import java.util.ConcurrentModificationException;
|
|||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.client.render.chunk.ChunkRendererRegion;
|
||||
|
@ -40,21 +40,15 @@ import net.fabricmc.fabric.api.rendering.data.v1.RenderAttachmentBlockEntity;
|
|||
|
||||
@Mixin(ChunkRendererRegion.class)
|
||||
public abstract class MixinChunkRendererRegion implements RenderAttachedBlockView {
|
||||
private Int2ObjectOpenHashMap<Object> fabric_renderDataObjects;
|
||||
|
||||
@Shadow
|
||||
protected abstract int getIndex(BlockPos pos);
|
||||
|
||||
@Shadow
|
||||
protected abstract int getIndex(int x, int y, int z);
|
||||
private Long2ObjectOpenHashMap<Object> fabric_renderDataObjects;
|
||||
|
||||
private static final AtomicInteger ERROR_COUNTER = new AtomicInteger();
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
@Inject(at = @At("RETURN"), method = "<init>")
|
||||
public void init(World world, int cxOff, int czOff, WorldChunk[][] chunks, BlockPos posFrom, BlockPos posTo, CallbackInfo info) {
|
||||
@Inject(at = @At("RETURN"), method = "create", locals = LocalCapture.CAPTURE_FAILHARD)
|
||||
private static void init(World world, BlockPos startPos, BlockPos endPos, int chunkRadius, CallbackInfoReturnable<ChunkRendererRegion> info, int i, int j, int k, int l, WorldChunk[][] chunks) {
|
||||
// instantiated lazily - avoids allocation for chunks without any data objects - which is most of them!
|
||||
Int2ObjectOpenHashMap<Object> map = null;
|
||||
Long2ObjectOpenHashMap<Object> map = null;
|
||||
|
||||
for (WorldChunk[] chunkOuter : chunks) {
|
||||
for (WorldChunk chunk : chunkOuter) {
|
||||
|
@ -66,7 +60,7 @@ public abstract class MixinChunkRendererRegion implements RenderAttachedBlockVie
|
|||
// We handle this simply by retrying until it works. Ugly but effective.
|
||||
for (;;) {
|
||||
try {
|
||||
map = mapChunk(chunk, posFrom, posTo, map);
|
||||
map = mapChunk(chunk, startPos, endPos, map);
|
||||
break;
|
||||
} catch (ConcurrentModificationException e) {
|
||||
final int count = ERROR_COUNTER.incrementAndGet();
|
||||
|
@ -83,10 +77,14 @@ public abstract class MixinChunkRendererRegion implements RenderAttachedBlockVie
|
|||
}
|
||||
}
|
||||
|
||||
this.fabric_renderDataObjects = map;
|
||||
ChunkRendererRegion rendererRegion = info.getReturnValue();
|
||||
|
||||
if (map != null && rendererRegion != null) {
|
||||
((MixinChunkRendererRegion) (Object) rendererRegion).fabric_renderDataObjects = map;
|
||||
}
|
||||
}
|
||||
|
||||
private Int2ObjectOpenHashMap<Object> mapChunk(WorldChunk chunk, BlockPos posFrom, BlockPos posTo, Int2ObjectOpenHashMap<Object> map) {
|
||||
private static Long2ObjectOpenHashMap<Object> mapChunk(WorldChunk chunk, BlockPos posFrom, BlockPos posTo, Long2ObjectOpenHashMap<Object> map) {
|
||||
final int xMin = posFrom.getX();
|
||||
final int xMax = posTo.getX();
|
||||
final int zMin = posFrom.getZ();
|
||||
|
@ -104,10 +102,10 @@ public abstract class MixinChunkRendererRegion implements RenderAttachedBlockVie
|
|||
|
||||
if (o != null) {
|
||||
if (map == null) {
|
||||
map = new Int2ObjectOpenHashMap<>();
|
||||
map = new Long2ObjectOpenHashMap<>();
|
||||
}
|
||||
|
||||
map.put(getIndex(entPos), o);
|
||||
map.put(entPos.asLong(), o);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -117,6 +115,6 @@ public abstract class MixinChunkRendererRegion implements RenderAttachedBlockVie
|
|||
|
||||
@Override
|
||||
public Object getBlockEntityRenderAttachment(BlockPos pos) {
|
||||
return fabric_renderDataObjects == null ? null : fabric_renderDataObjects.get(getIndex(pos));
|
||||
return fabric_renderDataObjects == null ? null : fabric_renderDataObjects.get(pos.asLong());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ public abstract class MixinWorldRenderer {
|
|||
}
|
||||
|
||||
@Inject(method = "setupTerrain", at = @At("RETURN"))
|
||||
private void afterTerrainSetup(Camera camera, Frustum frustum, boolean hasForcedFrustum, int frame, boolean spectator, CallbackInfo ci) {
|
||||
private void afterTerrainSetup(Camera camera, Frustum frustum, boolean hasForcedFrustum, boolean spectator, CallbackInfo ci) {
|
||||
context.setFrustum(frustum);
|
||||
WorldRenderEvents.AFTER_SETUP.invoker().afterSetup(context);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue