forked from FabricMC/fabric
19w45a
This commit is contained in:
parent
b7f9825dbb
commit
12515ed9ee
32 changed files with 100 additions and 97 deletions
|
@ -12,9 +12,9 @@ plugins {
|
||||||
def ENV = System.getenv()
|
def ENV = System.getenv()
|
||||||
|
|
||||||
class Globals {
|
class Globals {
|
||||||
static def baseVersion = "0.4.9"
|
static def baseVersion = "0.4.10"
|
||||||
static def mcVersion = "19w44a"
|
static def mcVersion = "19w45a"
|
||||||
static def yarnVersion = "+build.2"
|
static def yarnVersion = "+build.1"
|
||||||
}
|
}
|
||||||
|
|
||||||
import org.apache.commons.codec.digest.DigestUtils
|
import org.apache.commons.codec.digest.DigestUtils
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
archivesBaseName = "fabric-blockrenderlayer-v1"
|
archivesBaseName = "fabric-blockrenderlayer-v1"
|
||||||
version = getSubprojectVersion(project, "1.1.2")
|
version = getSubprojectVersion(project, "1.1.3")
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile project(path: ':fabric-api-base', configuration: 'dev')
|
compile project(path: ':fabric-api-base', configuration: 'dev')
|
||||||
|
|
|
@ -65,7 +65,10 @@ public class BlockRenderLayerMapImpl implements BlockRenderLayerMap {
|
||||||
private static BiConsumer<Item, RenderLayer> itemHandler = (i, l) -> itemRenderLayerMap.put(i, l);
|
private static BiConsumer<Item, RenderLayer> itemHandler = (i, l) -> itemRenderLayerMap.put(i, l);
|
||||||
private static BiConsumer<Fluid, RenderLayer> fluidHandler = (f, b) -> fluidRenderLayerMap.put(f, b);
|
private static BiConsumer<Fluid, RenderLayer> fluidHandler = (f, b) -> fluidRenderLayerMap.put(f, b);
|
||||||
|
|
||||||
public static void initialize(BiConsumer<Block, RenderLayer> blockHandlerIn, BiConsumer<Item, RenderLayer> itemHandlerIn, BiConsumer<Fluid, RenderLayer> fluidHandlerIn) {
|
public static void initialize(BiConsumer<Block, RenderLayer> blockHandlerIn, BiConsumer<Fluid, RenderLayer> fluidHandlerIn) {
|
||||||
|
//Done to handle backwards compat, in previous snapshots Items had their own map for render layers, now the BlockItem is used.
|
||||||
|
BiConsumer<Item, RenderLayer> itemHandlerIn = (item, renderLayer) -> blockHandlerIn.accept(Block.getBlockFromItem(item), renderLayer);
|
||||||
|
|
||||||
//Add all the pre existing render layers
|
//Add all the pre existing render layers
|
||||||
blockRenderLayerMap.forEach(blockHandlerIn);
|
blockRenderLayerMap.forEach(blockHandlerIn);
|
||||||
itemRenderLayerMap.forEach(itemHandlerIn);
|
itemRenderLayerMap.forEach(itemHandlerIn);
|
||||||
|
|
|
@ -35,11 +35,10 @@ import net.fabricmc.fabric.impl.blockrenderlayer.BlockRenderLayerMapImpl;
|
||||||
@Mixin(RenderLayers.class)
|
@Mixin(RenderLayers.class)
|
||||||
public class MixinBlockRenderLayer {
|
public class MixinBlockRenderLayer {
|
||||||
@Shadow private static Map<Block, RenderLayer> BLOCKS;
|
@Shadow private static Map<Block, RenderLayer> BLOCKS;
|
||||||
@Shadow private static Map<Item, RenderLayer> ITEMS;
|
|
||||||
@Shadow private static Map<Fluid, RenderLayer> FLUIDS;
|
@Shadow private static Map<Fluid, RenderLayer> FLUIDS;
|
||||||
|
|
||||||
@Inject(method = "<clinit>*", at = @At("RETURN"))
|
@Inject(method = "<clinit>*", at = @At("RETURN"))
|
||||||
private static void onInitialize(CallbackInfo info) {
|
private static void onInitialize(CallbackInfo info) {
|
||||||
BlockRenderLayerMapImpl.initialize(BLOCKS::put, ITEMS::put, FLUIDS::put);
|
BlockRenderLayerMapImpl.initialize(BLOCKS::put, FLUIDS::put);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
archivesBaseName = "fabric-events-interaction-v0"
|
archivesBaseName = "fabric-events-interaction-v0"
|
||||||
version = getSubprojectVersion(project, "0.2.5")
|
version = getSubprojectVersion(project, "0.2.6")
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile project(path: ':fabric-api-base', configuration: 'dev')
|
compile project(path: ':fabric-api-base', configuration: 'dev')
|
||||||
|
|
|
@ -44,7 +44,7 @@ public abstract class MixinMinecraftClient {
|
||||||
private ItemStack fabric_emulateOldPick() {
|
private ItemStack fabric_emulateOldPick() {
|
||||||
MinecraftClient client = (MinecraftClient) (Object) this;
|
MinecraftClient client = (MinecraftClient) (Object) this;
|
||||||
ClientPickBlockCallback.Container ctr = new ClientPickBlockCallback.Container(ItemStack.EMPTY);
|
ClientPickBlockCallback.Container ctr = new ClientPickBlockCallback.Container(ItemStack.EMPTY);
|
||||||
ClientPickBlockCallback.EVENT.invoker().pick(client.player, client.hitResult, ctr);
|
ClientPickBlockCallback.EVENT.invoker().pick(client.player, client.crosshairTarget, ctr);
|
||||||
return ctr.getStack();
|
return ctr.getStack();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ public abstract class MixinMinecraftClient {
|
||||||
MinecraftClient client = (MinecraftClient) (Object) this;
|
MinecraftClient client = (MinecraftClient) (Object) this;
|
||||||
|
|
||||||
// Do a "best effort" emulation of the old events.
|
// Do a "best effort" emulation of the old events.
|
||||||
ItemStack stack = ClientPickBlockGatherCallback.EVENT.invoker().pick(client.player, client.hitResult);
|
ItemStack stack = ClientPickBlockGatherCallback.EVENT.invoker().pick(client.player, client.crosshairTarget);
|
||||||
|
|
||||||
// TODO: Remove in 0.3.0
|
// TODO: Remove in 0.3.0
|
||||||
if (stack.isEmpty()) {
|
if (stack.isEmpty()) {
|
||||||
|
@ -68,15 +68,15 @@ public abstract class MixinMinecraftClient {
|
||||||
// I don't like that we clone vanilla logic here, but it's our best bet for now.
|
// I don't like that we clone vanilla logic here, but it's our best bet for now.
|
||||||
PlayerInventory playerInventory = client.player.inventory;
|
PlayerInventory playerInventory = client.player.inventory;
|
||||||
|
|
||||||
if (client.player.abilities.creativeMode && Screen.hasControlDown() && client.hitResult.getType() == HitResult.Type.BLOCK) {
|
if (client.player.abilities.creativeMode && Screen.hasControlDown() && client.crosshairTarget.getType() == HitResult.Type.BLOCK) {
|
||||||
BlockEntity be = client.world.getBlockEntity(((BlockHitResult) client.hitResult).getBlockPos());
|
BlockEntity be = client.world.getBlockEntity(((BlockHitResult) client.crosshairTarget).getBlockPos());
|
||||||
|
|
||||||
if (be != null) {
|
if (be != null) {
|
||||||
stack = addBlockEntityNbt(stack, be);
|
stack = addBlockEntityNbt(stack, be);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stack = ClientPickBlockApplyCallback.EVENT.invoker().pick(client.player, client.hitResult, stack);
|
stack = ClientPickBlockApplyCallback.EVENT.invoker().pick(client.player, client.crosshairTarget, stack);
|
||||||
|
|
||||||
if (stack.isEmpty()) {
|
if (stack.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
|
@ -108,7 +108,7 @@ public abstract class MixinMinecraftClient {
|
||||||
@ModifyVariable(at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerInventory;getSlotWithStack(Lnet/minecraft/item/ItemStack;)I"), method = "doItemPick", ordinal = 0)
|
@ModifyVariable(at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerInventory;getSlotWithStack(Lnet/minecraft/item/ItemStack;)I"), method = "doItemPick", ordinal = 0)
|
||||||
public ItemStack modifyItemPick(ItemStack stack) {
|
public ItemStack modifyItemPick(ItemStack stack) {
|
||||||
MinecraftClient client = (MinecraftClient) (Object) this;
|
MinecraftClient client = (MinecraftClient) (Object) this;
|
||||||
ItemStack result = ClientPickBlockApplyCallback.EVENT.invoker().pick(client.player, client.hitResult, stack);
|
ItemStack result = ClientPickBlockApplyCallback.EVENT.invoker().pick(client.player, client.crosshairTarget, stack);
|
||||||
fabric_itemPickCancelled = result.isEmpty();
|
fabric_itemPickCancelled = result.isEmpty();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
archivesBaseName = "fabric-networking-v0"
|
archivesBaseName = "fabric-networking-v0"
|
||||||
version = getSubprojectVersion(project, "0.1.6")
|
version = getSubprojectVersion(project, "0.1.7")
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile project(path: ':fabric-api-base', configuration: 'dev')
|
compile project(path: ':fabric-api-base', configuration: 'dev')
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
package net.fabricmc.fabric.api.network;
|
package net.fabricmc.fabric.api.network;
|
||||||
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.util.ThreadExecutor;
|
import net.minecraft.util.thread.ThreadExecutor;
|
||||||
|
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.network.Packet;
|
import net.minecraft.network.Packet;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.PacketByteBuf;
|
import net.minecraft.util.PacketByteBuf;
|
||||||
import net.minecraft.util.ThreadExecutor;
|
import net.minecraft.util.thread.ThreadExecutor;
|
||||||
|
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.fabric.api.network.ClientSidePacketRegistry;
|
import net.fabricmc.fabric.api.network.ClientSidePacketRegistry;
|
||||||
|
|
|
@ -28,7 +28,7 @@ import net.minecraft.server.network.ServerPlayNetworkHandler;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
import net.minecraft.server.network.packet.CustomPayloadC2SPacket;
|
import net.minecraft.server.network.packet.CustomPayloadC2SPacket;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.ThreadExecutor;
|
import net.minecraft.util.thread.ThreadExecutor;
|
||||||
|
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.fabric.api.network.PacketContext;
|
import net.fabricmc.fabric.api.network.PacketContext;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
archivesBaseName = "fabric-registry-sync-v0"
|
archivesBaseName = "fabric-registry-sync-v0"
|
||||||
version = getSubprojectVersion(project, "0.2.4")
|
version = getSubprojectVersion(project, "0.2.5")
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile project(path: ':fabric-api-base', configuration: 'dev')
|
compile project(path: ':fabric-api-base', configuration: 'dev')
|
||||||
|
|
|
@ -69,7 +69,7 @@ public final class RegistrySyncManager {
|
||||||
|
|
||||||
if (accept) {
|
if (accept) {
|
||||||
try {
|
try {
|
||||||
context.getTaskQueue().supply(() -> {
|
context.getTaskQueue().submit(() -> {
|
||||||
if (compound == null) {
|
if (compound == null) {
|
||||||
errorHandler.accept(new RemapException("Received null compound tag in sync packet!"));
|
errorHandler.accept(new RemapException("Received null compound tag in sync packet!"));
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
archivesBaseName = "fabric-renderer-api-v1"
|
archivesBaseName = "fabric-renderer-api-v1"
|
||||||
version = getSubprojectVersion(project, "0.2.5")
|
version = getSubprojectVersion(project, "0.2.6")
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile project(path: ':fabric-api-base', configuration: 'dev')
|
compile project(path: ':fabric-api-base', configuration: 'dev')
|
||||||
|
|
|
@ -33,7 +33,7 @@ import net.fabricmc.fabric.api.renderer.v1.material.RenderMaterial;
|
||||||
*/
|
*/
|
||||||
public interface QuadView {
|
public interface QuadView {
|
||||||
/** Count of integers in a conventional (un-modded) block or item vertex. */
|
/** Count of integers in a conventional (un-modded) block or item vertex. */
|
||||||
int VANILLA_VERTEX_STRIDE = VertexFormats.POSITION_COLOR_UV_NORMAL.getVertexSizeInteger();
|
int VANILLA_VERTEX_STRIDE = VertexFormats.POSITION_COLOR_TEXTURE_LIGHT_NORMAL.getVertexSizeInteger();
|
||||||
|
|
||||||
/** Count of integers in a conventional (un-modded) block or item quad. */
|
/** Count of integers in a conventional (un-modded) block or item quad. */
|
||||||
int VANILLA_QUAD_STRIDE = VANILLA_VERTEX_STRIDE * 4;
|
int VANILLA_QUAD_STRIDE = VANILLA_VERTEX_STRIDE * 4;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
archivesBaseName = "fabric-renderer-indigo"
|
archivesBaseName = "fabric-renderer-indigo"
|
||||||
version = getSubprojectVersion(project, "0.2.10")
|
version = getSubprojectVersion(project, "0.2.11")
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile project(path: ':fabric-api-base', configuration: 'dev')
|
compile project(path: ':fabric-api-base', configuration: 'dev')
|
||||||
|
|
|
@ -24,7 +24,7 @@ import static net.minecraft.util.math.Direction.SOUTH;
|
||||||
import static net.minecraft.util.math.Direction.UP;
|
import static net.minecraft.util.math.Direction.UP;
|
||||||
import static net.minecraft.util.math.Direction.WEST;
|
import static net.minecraft.util.math.Direction.WEST;
|
||||||
|
|
||||||
import net.minecraft.util.SystemUtil;
|
import net.minecraft.util.Util;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.util.math.Direction;
|
||||||
|
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
|
@ -95,7 +95,7 @@ enum AoFace {
|
||||||
this.weightFunc = weightFunc;
|
this.weightFunc = weightFunc;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final AoFace[] values = SystemUtil.consume(new AoFace[6], (neighborData) -> {
|
private static final AoFace[] values = Util.create(new AoFace[6], (neighborData) -> {
|
||||||
neighborData[DOWN.getId()] = AOF_DOWN;
|
neighborData[DOWN.getId()] = AOF_DOWN;
|
||||||
neighborData[UP.getId()] = AOF_UP;
|
neighborData[UP.getId()] = AOF_UP;
|
||||||
neighborData[NORTH.getId()] = AOF_NORTH;
|
neighborData[NORTH.getId()] = AOF_NORTH;
|
||||||
|
|
|
@ -56,7 +56,7 @@ public abstract class EncodingFormat {
|
||||||
public static final int TOTAL_STRIDE;
|
public static final int TOTAL_STRIDE;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
final VertexFormat format = VertexFormats.POSITION_COLOR_UV_NORMAL;
|
final VertexFormat format = VertexFormats.POSITION_COLOR_TEXTURE_LIGHT_NORMAL;
|
||||||
VERTEX_X = HEADER_STRIDE + 0;
|
VERTEX_X = HEADER_STRIDE + 0;
|
||||||
VERTEX_Y = HEADER_STRIDE + 1;
|
VERTEX_Y = HEADER_STRIDE + 1;
|
||||||
VERTEX_Z = HEADER_STRIDE + 2;
|
VERTEX_Z = HEADER_STRIDE + 2;
|
||||||
|
|
|
@ -24,6 +24,7 @@ import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.client.render.RenderLayer;
|
import net.minecraft.client.render.RenderLayer;
|
||||||
import net.minecraft.client.render.VertexConsumer;
|
import net.minecraft.client.render.VertexConsumer;
|
||||||
|
import net.minecraft.client.render.WorldRenderer;
|
||||||
import net.minecraft.client.util.math.Matrix4f;
|
import net.minecraft.client.util.math.Matrix4f;
|
||||||
import net.minecraft.client.util.math.Vector3f;
|
import net.minecraft.client.util.math.Vector3f;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
@ -96,7 +97,7 @@ public abstract class AbstractQuadRenderer {
|
||||||
final int color = quad.spriteColor(i, 0);
|
final int color = quad.spriteColor(i, 0);
|
||||||
buff.color(color & 0xFF, (color >> 8) & 0xFF, (color >> 16) & 0xFF, (color >> 24) & 0xFF);
|
buff.color(color & 0xFF, (color >> 8) & 0xFF, (color >> 16) & 0xFF, (color >> 24) & 0xFF);
|
||||||
buff.texture(quad.spriteU(i, 0), quad.spriteV(i, 0));
|
buff.texture(quad.spriteU(i, 0), quad.spriteV(i, 0));
|
||||||
buff.defaultOverlay(overlay);
|
buff.overlay(overlay);
|
||||||
buff.light(quad.lightmap(i));
|
buff.light(quad.lightmap(i));
|
||||||
|
|
||||||
if (useNormals) {
|
if (useNormals) {
|
||||||
|
@ -172,6 +173,6 @@ public abstract class AbstractQuadRenderer {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unfortunately cannot use brightness cache here unless we implement one specifically for flat lighting. See #329
|
// Unfortunately cannot use brightness cache here unless we implement one specifically for flat lighting. See #329
|
||||||
return blockInfo.blockView.getLightmapCoordinates(blockState, mpos);
|
return WorldRenderer.method_23793(blockInfo.blockView, blockState, mpos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ import java.util.function.Function;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.client.render.RenderLayer;
|
import net.minecraft.client.render.RenderLayer;
|
||||||
import net.minecraft.client.render.VertexConsumer;
|
import net.minecraft.client.render.VertexConsumer;
|
||||||
|
import net.minecraft.client.render.WorldRenderer;
|
||||||
import net.minecraft.client.render.block.BlockModelRenderer;
|
import net.minecraft.client.render.block.BlockModelRenderer;
|
||||||
import net.minecraft.client.render.model.BakedModel;
|
import net.minecraft.client.render.model.BakedModel;
|
||||||
import net.minecraft.client.util.math.Matrix4f;
|
import net.minecraft.client.util.math.Matrix4f;
|
||||||
|
@ -62,7 +63,7 @@ public class BlockRenderContext extends AbstractRenderContext implements RenderC
|
||||||
return 15 << 20 | 15 << 4;
|
return 15 << 20 | 15 << 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
return blockInfo.blockView.getLightmapCoordinates(blockInfo.blockView.getBlockState(pos), pos);
|
return WorldRenderer.method_23793(blockInfo.blockView, blockInfo.blockView.getBlockState(pos), pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
private float aoLevel(BlockPos pos) {
|
private float aoLevel(BlockPos pos) {
|
||||||
|
@ -79,8 +80,8 @@ public class BlockRenderContext extends AbstractRenderContext implements RenderC
|
||||||
this.vanillaRenderer = vanillaRenderer;
|
this.vanillaRenderer = vanillaRenderer;
|
||||||
this.bufferBuilder = buffer;
|
this.bufferBuilder = buffer;
|
||||||
this.matrixStack = matrixStack;
|
this.matrixStack = matrixStack;
|
||||||
this.matrix = matrixStack.peek();
|
this.matrix = matrixStack.method_23760().method_23761();
|
||||||
this.normalMatrix = matrixStack.peekNormal();
|
this.normalMatrix = matrixStack.method_23760().method_23762();
|
||||||
|
|
||||||
this.seed = seed;
|
this.seed = seed;
|
||||||
this.overlay = overlay;
|
this.overlay = overlay;
|
||||||
|
@ -100,7 +101,7 @@ public class BlockRenderContext extends AbstractRenderContext implements RenderC
|
||||||
|
|
||||||
protected void acceptVanillaModel(BakedModel model) {
|
protected void acceptVanillaModel(BakedModel model) {
|
||||||
isCallingVanilla = true;
|
isCallingVanilla = true;
|
||||||
didOutput = didOutput && vanillaRenderer.tesselate(blockInfo.blockView, model, blockInfo.blockState, blockInfo.blockPos, matrixStack, bufferBuilder, false, random, seed, overlay);
|
didOutput = didOutput && vanillaRenderer.render(blockInfo.blockView, model, blockInfo.blockState, blockInfo.blockPos, matrixStack, bufferBuilder, false, random, seed, overlay);
|
||||||
isCallingVanilla = false;
|
isCallingVanilla = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -80,7 +80,7 @@ public class BlockRenderInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
int blockColor(int colorIndex) {
|
int blockColor(int colorIndex) {
|
||||||
return 0xFF000000 | blockColorMap.getColorMultiplier(blockState, blockView, blockPos, colorIndex);
|
return 0xFF000000 | blockColorMap.getColor(blockState, blockView, blockPos, colorIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean shouldDrawFace(Direction face) {
|
boolean shouldDrawFace(Direction face) {
|
||||||
|
|
|
@ -23,9 +23,10 @@ import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.client.render.BufferBuilder;
|
import net.minecraft.client.render.BufferBuilder;
|
||||||
import net.minecraft.client.render.RenderLayer;
|
import net.minecraft.client.render.RenderLayer;
|
||||||
import net.minecraft.client.render.chunk.BlockLayeredBufferBuilderStorage;
|
import net.minecraft.client.render.WorldRenderer;
|
||||||
import net.minecraft.client.render.chunk.ChunkBatcher.ChunkRenderData;
|
import net.minecraft.client.render.chunk.BlockBufferBuilderStorage;
|
||||||
import net.minecraft.client.render.chunk.ChunkBatcher.ChunkRenderer;
|
import net.minecraft.client.render.chunk.ChunkBuilder.ChunkData;
|
||||||
|
import net.minecraft.client.render.chunk.ChunkBuilder.BuiltChunk;
|
||||||
import net.minecraft.client.render.chunk.ChunkRendererRegion;
|
import net.minecraft.client.render.chunk.ChunkRendererRegion;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.BlockRenderView;
|
import net.minecraft.world.BlockRenderView;
|
||||||
|
@ -69,8 +70,8 @@ public class ChunkRenderInfo {
|
||||||
|
|
||||||
private final BlockPos.Mutable chunkOrigin = new BlockPos.Mutable();
|
private final BlockPos.Mutable chunkOrigin = new BlockPos.Mutable();
|
||||||
AccessChunkRendererData chunkData;
|
AccessChunkRendererData chunkData;
|
||||||
ChunkRenderer chunkRenderer;
|
BuiltChunk chunkRenderer;
|
||||||
BlockLayeredBufferBuilderStorage builders;
|
BlockBufferBuilderStorage builders;
|
||||||
BlockRenderView blockView;
|
BlockRenderView blockView;
|
||||||
|
|
||||||
private final Object2ObjectOpenHashMap<RenderLayer, BufferBuilder> buffers = new Object2ObjectOpenHashMap<>();
|
private final Object2ObjectOpenHashMap<RenderLayer, BufferBuilder> buffers = new Object2ObjectOpenHashMap<>();
|
||||||
|
@ -82,7 +83,7 @@ public class ChunkRenderInfo {
|
||||||
aoLevelCache.defaultReturnValue(Float.MAX_VALUE);
|
aoLevelCache.defaultReturnValue(Float.MAX_VALUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void prepare(ChunkRendererRegion blockView, ChunkRenderer chunkRenderer, ChunkRenderData chunkData, BlockLayeredBufferBuilderStorage builders) {
|
void prepare(ChunkRendererRegion blockView, BuiltChunk chunkRenderer, ChunkData chunkData, BlockBufferBuilderStorage builders) {
|
||||||
this.blockView = blockView;
|
this.blockView = blockView;
|
||||||
this.chunkOrigin.set(chunkRenderer.getOrigin());
|
this.chunkOrigin.set(chunkRenderer.getOrigin());
|
||||||
this.chunkData = (AccessChunkRendererData) chunkData;
|
this.chunkData = (AccessChunkRendererData) chunkData;
|
||||||
|
@ -126,7 +127,7 @@ public class ChunkRenderInfo {
|
||||||
int result = brightnessCache.get(key);
|
int result = brightnessCache.get(key);
|
||||||
|
|
||||||
if (result == Integer.MAX_VALUE) {
|
if (result == Integer.MAX_VALUE) {
|
||||||
result = blockView.getLightmapCoordinates(blockView.getBlockState(pos), pos);
|
result = WorldRenderer.method_23793(blockView, blockView.getBlockState(pos), pos);
|
||||||
brightnessCache.put(key, result);
|
brightnessCache.put(key, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -90,8 +90,8 @@ public class ItemRenderContext extends AbstractRenderContext implements RenderCo
|
||||||
this.itemStack = stack;
|
this.itemStack = stack;
|
||||||
this.bufferBuilder = buffer;
|
this.bufferBuilder = buffer;
|
||||||
this.matrixStack = matrixStack;
|
this.matrixStack = matrixStack;
|
||||||
this.matrix = matrixStack.peek();
|
this.matrix = matrixStack.method_23760().method_23761();
|
||||||
this.normalMatrix = matrixStack.peekNormal();
|
this.normalMatrix = matrixStack.method_23760().method_23762();
|
||||||
this.overlay = overlay;
|
this.overlay = overlay;
|
||||||
|
|
||||||
this.vanillaHandler = vanillaHandler;
|
this.vanillaHandler = vanillaHandler;
|
||||||
|
|
|
@ -19,9 +19,9 @@ package net.fabricmc.fabric.impl.client.indigo.renderer.render;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.client.render.chunk.BlockLayeredBufferBuilderStorage;
|
import net.minecraft.client.render.chunk.BlockBufferBuilderStorage;
|
||||||
import net.minecraft.client.render.chunk.ChunkBatcher.ChunkRenderData;
|
import net.minecraft.client.render.chunk.ChunkBuilder.ChunkData;
|
||||||
import net.minecraft.client.render.chunk.ChunkBatcher.ChunkRenderer;
|
import net.minecraft.client.render.chunk.ChunkBuilder.BuiltChunk;
|
||||||
import net.minecraft.client.render.chunk.ChunkRendererRegion;
|
import net.minecraft.client.render.chunk.ChunkRendererRegion;
|
||||||
import net.minecraft.client.render.model.BakedModel;
|
import net.minecraft.client.render.model.BakedModel;
|
||||||
import net.minecraft.client.util.math.Matrix4f;
|
import net.minecraft.client.util.math.Matrix4f;
|
||||||
|
@ -83,7 +83,7 @@ public class TerrainRenderContext extends AbstractRenderContext implements Rende
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public TerrainRenderContext prepare(ChunkRendererRegion blockView, ChunkRenderer chunkRenderer, ChunkRenderData chunkData, BlockLayeredBufferBuilderStorage builders) {
|
public TerrainRenderContext prepare(ChunkRendererRegion blockView, BuiltChunk chunkRenderer, ChunkData chunkData, BlockBufferBuilderStorage builders) {
|
||||||
blockInfo.setBlockView(blockView);
|
blockInfo.setBlockView(blockView);
|
||||||
chunkInfo.prepare(blockView, chunkRenderer, chunkData, builders);
|
chunkInfo.prepare(blockView, chunkRenderer, chunkData, builders);
|
||||||
return this;
|
return this;
|
||||||
|
@ -96,8 +96,8 @@ public class TerrainRenderContext extends AbstractRenderContext implements Rende
|
||||||
|
|
||||||
/** Called from chunk renderer hook. */
|
/** Called from chunk renderer hook. */
|
||||||
public boolean tesselateBlock(BlockState blockState, BlockPos blockPos, final BakedModel model, MatrixStack matrixStack) {
|
public boolean tesselateBlock(BlockState blockState, BlockPos blockPos, final BakedModel model, MatrixStack matrixStack) {
|
||||||
this.matrix = matrixStack.peek();
|
this.matrix = matrixStack.method_23760().method_23761();
|
||||||
this.normalMatrix = matrixStack.peekNormal();
|
this.normalMatrix = matrixStack.method_23760().method_23762();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
aoCalc.clear();
|
aoCalc.clear();
|
||||||
|
|
|
@ -30,20 +30,20 @@ import net.fabricmc.fabric.impl.client.indigo.renderer.accessor.AccessAmbientOcc
|
||||||
|
|
||||||
@Mixin(targets = "net.minecraft.client.render.block.BlockModelRenderer$AmbientOcclusionCalculator")
|
@Mixin(targets = "net.minecraft.client.render.block.BlockModelRenderer$AmbientOcclusionCalculator")
|
||||||
public abstract class MixinAmbientOcclusionCalculator implements AccessAmbientOcclusionCalculator {
|
public abstract class MixinAmbientOcclusionCalculator implements AccessAmbientOcclusionCalculator {
|
||||||
@Shadow private float[] colorMultiplier;
|
@Shadow private float[] brightness;
|
||||||
@Shadow private int[] brightness;
|
@Shadow private int[] light;
|
||||||
|
|
||||||
@Shadow
|
@Shadow
|
||||||
public abstract void apply(BlockRenderView blockRenderView, BlockState blockState, BlockPos pos, Direction face, float[] aoData, BitSet controlBits);
|
public abstract void apply(BlockRenderView blockRenderView, BlockState blockState, BlockPos pos, Direction face, float[] aoData, BitSet controlBits);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float[] fabric_colorMultiplier() {
|
public float[] fabric_colorMultiplier() {
|
||||||
return colorMultiplier;
|
return brightness;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int[] fabric_brightness() {
|
public int[] fabric_brightness() {
|
||||||
return brightness;
|
return light;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -47,11 +47,11 @@ public abstract class MixinBlockModelRenderer implements AccessBlockModelRendere
|
||||||
protected BlockColors colorMap;
|
protected BlockColors colorMap;
|
||||||
|
|
||||||
@Shadow
|
@Shadow
|
||||||
protected abstract void updateShape(BlockRenderView blockView, BlockState blockState, BlockPos blockPos, int[] vertexData, Direction face, float[] aoData, BitSet controlBits);
|
protected abstract void getQuadDimensions(BlockRenderView blockView, BlockState blockState, BlockPos blockPos, int[] vertexData, Direction face, float[] aoData, BitSet controlBits);
|
||||||
|
|
||||||
private final ThreadLocal<BlockRenderContext> CONTEXTS = ThreadLocal.withInitial(BlockRenderContext::new);
|
private final ThreadLocal<BlockRenderContext> CONTEXTS = ThreadLocal.withInitial(BlockRenderContext::new);
|
||||||
|
|
||||||
@Inject(at = @At("HEAD"), method = "tesselate", cancellable = true)
|
@Inject(at = @At("HEAD"), method = "render(Lnet/minecraft/world/BlockRenderView;Lnet/minecraft/client/render/model/BakedModel;Lnet/minecraft/block/BlockState;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumer;ZLjava/util/Random;JI)Z", cancellable = true)
|
||||||
private void hookTesselate(BlockRenderView blockView, BakedModel model, BlockState state, BlockPos pos, MatrixStack matrix, VertexConsumer buffer, boolean checkSides, Random rand, long seed, int overlay, CallbackInfoReturnable<Boolean> ci) {
|
private void hookTesselate(BlockRenderView blockView, BakedModel model, BlockState state, BlockPos pos, MatrixStack matrix, VertexConsumer buffer, boolean checkSides, Random rand, long seed, int overlay, CallbackInfoReturnable<Boolean> ci) {
|
||||||
if (!((FabricBakedModel) model).isVanillaAdapter()) {
|
if (!((FabricBakedModel) model).isVanillaAdapter()) {
|
||||||
BlockRenderContext context = CONTEXTS.get();
|
BlockRenderContext context = CONTEXTS.get();
|
||||||
|
@ -69,6 +69,6 @@ public abstract class MixinBlockModelRenderer implements AccessBlockModelRendere
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fabric_updateShape(BlockRenderView blockView, BlockState blockState, BlockPos pos, int[] vertexData, Direction face, float[] aoData, BitSet controlBits) {
|
public void fabric_updateShape(BlockRenderView blockView, BlockState blockState, BlockPos pos, int[] vertexData, Direction face, float[] aoData, BitSet controlBits) {
|
||||||
updateShape(blockView, blockState, pos, vertexData, face, aoData, controlBits);
|
getQuadDimensions(blockView, blockState, pos, vertexData, face, aoData, controlBits);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,9 +32,9 @@ import net.minecraft.block.entity.BlockEntity;
|
||||||
import net.minecraft.client.render.BufferBuilder;
|
import net.minecraft.client.render.BufferBuilder;
|
||||||
import net.minecraft.client.render.VertexConsumer;
|
import net.minecraft.client.render.VertexConsumer;
|
||||||
import net.minecraft.client.render.block.BlockRenderManager;
|
import net.minecraft.client.render.block.BlockRenderManager;
|
||||||
import net.minecraft.client.render.chunk.BlockLayeredBufferBuilderStorage;
|
import net.minecraft.client.render.chunk.BlockBufferBuilderStorage;
|
||||||
import net.minecraft.client.render.chunk.ChunkBatcher;
|
import net.minecraft.client.render.chunk.ChunkBuilder;
|
||||||
import net.minecraft.client.render.chunk.ChunkBatcher.ChunkRenderer;
|
import net.minecraft.client.render.chunk.ChunkBuilder.BuiltChunk;
|
||||||
import net.minecraft.client.render.chunk.ChunkRendererRegion;
|
import net.minecraft.client.render.chunk.ChunkRendererRegion;
|
||||||
import net.minecraft.client.render.model.BakedModel;
|
import net.minecraft.client.render.model.BakedModel;
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
|
@ -67,10 +67,10 @@ public class MixinChunkRebuildTask {
|
||||||
@Shadow
|
@Shadow
|
||||||
protected ChunkRendererRegion field_20838;
|
protected ChunkRendererRegion field_20838;
|
||||||
@Shadow
|
@Shadow
|
||||||
protected ChunkRenderer field_20839;
|
protected BuiltChunk field_20839;
|
||||||
|
|
||||||
@Inject(at = @At("HEAD"), method = "method_22785")
|
@Inject(at = @At("HEAD"), method = "method_22785")
|
||||||
private void hookChunkBuild(float float_1, float float_2, float float_3, ChunkBatcher.ChunkRenderData renderData, BlockLayeredBufferBuilderStorage builder, CallbackInfoReturnable<Set<BlockEntity>> ci) {
|
private void hookChunkBuild(float float_1, float float_2, float float_3, ChunkBuilder.ChunkData renderData, BlockBufferBuilderStorage builder, CallbackInfoReturnable<Set<BlockEntity>> ci) {
|
||||||
if (field_20838 != null) {
|
if (field_20838 != null) {
|
||||||
TerrainRenderContext renderer = TerrainRenderContext.POOL.get();
|
TerrainRenderContext renderer = TerrainRenderContext.POOL.get();
|
||||||
renderer.prepare(field_20838, field_20839, renderData, builder);
|
renderer.prepare(field_20838, field_20839, renderData, builder);
|
||||||
|
@ -105,7 +105,7 @@ public class MixinChunkRebuildTask {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return renderManager.tesselateBlock(blockState, blockPos, blockView, matrix, bufferBuilder, checkSides, random);
|
return renderManager.renderBlock(blockState, blockPos, blockView, matrix, bufferBuilder, checkSides, random);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -22,11 +22,11 @@ import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
|
||||||
import net.minecraft.client.render.RenderLayer;
|
import net.minecraft.client.render.RenderLayer;
|
||||||
import net.minecraft.client.render.chunk.ChunkBatcher.ChunkRenderData;
|
import net.minecraft.client.render.chunk.ChunkBuilder.ChunkData;
|
||||||
|
|
||||||
import net.fabricmc.fabric.impl.client.indigo.renderer.accessor.AccessChunkRendererData;
|
import net.fabricmc.fabric.impl.client.indigo.renderer.accessor.AccessChunkRendererData;
|
||||||
|
|
||||||
@Mixin(ChunkRenderData.class)
|
@Mixin(ChunkData.class)
|
||||||
public class MixinChunkRenderData implements AccessChunkRendererData {
|
public class MixinChunkRenderData implements AccessChunkRendererData {
|
||||||
@Shadow
|
@Shadow
|
||||||
private Set<RenderLayer> initialized;
|
private Set<RenderLayer> initialized;
|
||||||
|
|
|
@ -20,11 +20,11 @@ import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
|
||||||
import net.minecraft.client.render.BufferBuilder;
|
import net.minecraft.client.render.BufferBuilder;
|
||||||
import net.minecraft.client.render.chunk.ChunkBatcher.ChunkRenderer;
|
import net.minecraft.client.render.chunk.ChunkBuilder.BuiltChunk;
|
||||||
|
|
||||||
import net.fabricmc.fabric.impl.client.indigo.renderer.accessor.AccessChunkRenderer;
|
import net.fabricmc.fabric.impl.client.indigo.renderer.accessor.AccessChunkRenderer;
|
||||||
|
|
||||||
@Mixin(ChunkRenderer.class)
|
@Mixin(BuiltChunk.class)
|
||||||
public abstract class MixinChunkRenderer implements AccessChunkRenderer {
|
public abstract class MixinChunkRenderer implements AccessChunkRenderer {
|
||||||
@Shadow
|
@Shadow
|
||||||
abstract void beginBufferBuilding(BufferBuilder builder);
|
abstract void beginBufferBuilding(BufferBuilder builder);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
archivesBaseName = "fabric-rendering-fluids-v1"
|
archivesBaseName = "fabric-rendering-fluids-v1"
|
||||||
version = getSubprojectVersion(project, "0.1.5")
|
version = getSubprojectVersion(project, "0.1.6")
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile project(path: ':fabric-api-base', configuration: 'dev')
|
compile project(path: ':fabric-api-base', configuration: 'dev')
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class MixinFluidRenderer {
|
||||||
FluidRenderHandlerRegistryImpl.INSTANCE.onFluidRendererReload(waterSprites, lavaSprites);
|
FluidRenderHandlerRegistryImpl.INSTANCE.onFluidRendererReload(waterSprites, lavaSprites);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(at = @At("HEAD"), method = "tesselate", cancellable = true)
|
@Inject(at = @At("HEAD"), method = "render", cancellable = true)
|
||||||
public void tesselate(BlockRenderView view, BlockPos pos, VertexConsumer vertexConsumer, FluidState state, CallbackInfoReturnable<Boolean> info) {
|
public void tesselate(BlockRenderView view, BlockPos pos, VertexConsumer vertexConsumer, FluidState state, CallbackInfoReturnable<Boolean> info) {
|
||||||
FluidRendererHookContainer ctr = fabric_renderHandler.get();
|
FluidRendererHookContainer ctr = fabric_renderHandler.get();
|
||||||
FluidRenderHandler handler = FluidRenderHandlerRegistryImpl.INSTANCE.getOverride(state.getFluid());
|
FluidRenderHandler handler = FluidRenderHandlerRegistryImpl.INSTANCE.getOverride(state.getFluid());
|
||||||
|
@ -72,12 +72,12 @@ public class MixinFluidRenderer {
|
||||||
} */
|
} */
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject(at = @At("RETURN"), method = "tesselate")
|
@Inject(at = @At("RETURN"), method = "render")
|
||||||
public void tesselateReturn(BlockRenderView view, BlockPos pos, VertexConsumer vertexConsumer, FluidState state, CallbackInfoReturnable<Boolean> info) {
|
public void tesselateReturn(BlockRenderView view, BlockPos pos, VertexConsumer vertexConsumer, FluidState state, CallbackInfoReturnable<Boolean> info) {
|
||||||
fabric_renderHandler.get().clear();
|
fabric_renderHandler.get().clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ModifyVariable(at = @At(value = "INVOKE", target = "net/minecraft/client/render/block/FluidRenderer.isSameFluid(Lnet/minecraft/world/BlockView;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/math/Direction;Lnet/minecraft/fluid/FluidState;)Z"), method = "tesselate", ordinal = 0)
|
@ModifyVariable(at = @At(value = "INVOKE", target = "net/minecraft/client/render/block/FluidRenderer.isSameFluid(Lnet/minecraft/world/BlockView;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/math/Direction;Lnet/minecraft/fluid/FluidState;)Z"), method = "render", ordinal = 0)
|
||||||
public boolean modLavaCheck(boolean chk) {
|
public boolean modLavaCheck(boolean chk) {
|
||||||
// First boolean local is set by vanilla according to 'matches lava'
|
// First boolean local is set by vanilla according to 'matches lava'
|
||||||
// but uses the negation consistent with 'matches water'
|
// but uses the negation consistent with 'matches water'
|
||||||
|
@ -88,13 +88,13 @@ public class MixinFluidRenderer {
|
||||||
return chk || !ctr.state.matches(FluidTags.WATER);
|
return chk || !ctr.state.matches(FluidTags.WATER);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ModifyVariable(at = @At(value = "INVOKE", target = "net/minecraft/client/render/block/FluidRenderer.isSameFluid(Lnet/minecraft/world/BlockView;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/math/Direction;Lnet/minecraft/fluid/FluidState;)Z"), method = "tesselate", ordinal = 0)
|
@ModifyVariable(at = @At(value = "INVOKE", target = "net/minecraft/client/render/block/FluidRenderer.isSameFluid(Lnet/minecraft/world/BlockView;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/math/Direction;Lnet/minecraft/fluid/FluidState;)Z"), method = "render", ordinal = 0)
|
||||||
public Sprite[] modSpriteArray(Sprite[] chk) {
|
public Sprite[] modSpriteArray(Sprite[] chk) {
|
||||||
FluidRendererHookContainer ctr = fabric_renderHandler.get();
|
FluidRendererHookContainer ctr = fabric_renderHandler.get();
|
||||||
return ctr.handler != null ? ctr.handler.getFluidSprites(ctr.view, ctr.pos, ctr.state) : chk;
|
return ctr.handler != null ? ctr.handler.getFluidSprites(ctr.view, ctr.pos, ctr.state) : chk;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ModifyVariable(at = @At(value = "CONSTANT", args = "intValue=16", ordinal = 0, shift = At.Shift.BEFORE), method = "tesselate", ordinal = 0)
|
@ModifyVariable(at = @At(value = "CONSTANT", args = "intValue=16", ordinal = 0, shift = At.Shift.BEFORE), method = "render", ordinal = 0)
|
||||||
public int modTintColor(int chk) {
|
public int modTintColor(int chk) {
|
||||||
FluidRendererHookContainer ctr = fabric_renderHandler.get();
|
FluidRendererHookContainer ctr = fabric_renderHandler.get();
|
||||||
return ctr.handler != null ? ctr.handler.getFluidColor(ctr.view, ctr.pos, ctr.state) : chk;
|
return ctr.handler != null ? ctr.handler.getFluidColor(ctr.view, ctr.pos, ctr.state) : chk;
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
archivesBaseName = "fabric-resource-loader-v0"
|
archivesBaseName = "fabric-resource-loader-v0"
|
||||||
version = getSubprojectVersion(project, "0.1.7")
|
version = getSubprojectVersion(project, "0.1.8")
|
||||||
|
|
|
@ -128,36 +128,34 @@ public class ModNioResourcePack extends AbstractFileResourcePack implements ModR
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<Identifier> findResources(ResourceType type, String path, int depth, Predicate<String> predicate) {
|
public Collection<Identifier> findResources(ResourceType type, String namespace, String path, int depth, Predicate<String> predicate) {
|
||||||
List<Identifier> ids = new ArrayList<>();
|
List<Identifier> ids = new ArrayList<>();
|
||||||
String nioPath = path.replace("/", separator);
|
String nioPath = path.replace("/", separator);
|
||||||
|
|
||||||
for (String namespace : getNamespaces(type)) {
|
Path namespacePath = getPath(type.getDirectory() + "/" + namespace);
|
||||||
Path namespacePath = getPath(type.getDirectory() + "/" + namespace);
|
|
||||||
|
|
||||||
if (namespacePath != null) {
|
if (namespacePath != null) {
|
||||||
Path searchPath = namespacePath.resolve(nioPath).toAbsolutePath().normalize();
|
Path searchPath = namespacePath.resolve(nioPath).toAbsolutePath().normalize();
|
||||||
|
|
||||||
if (Files.exists(searchPath)) {
|
if (Files.exists(searchPath)) {
|
||||||
try {
|
try {
|
||||||
Files.walk(searchPath, depth)
|
Files.walk(searchPath, depth)
|
||||||
.filter(Files::isRegularFile)
|
.filter(Files::isRegularFile)
|
||||||
.filter((p) -> {
|
.filter((p) -> {
|
||||||
String filename = p.getFileName().toString();
|
String filename = p.getFileName().toString();
|
||||||
return !filename.endsWith(".mcmeta") && predicate.test(filename);
|
return !filename.endsWith(".mcmeta") && predicate.test(filename);
|
||||||
})
|
})
|
||||||
.map(namespacePath::relativize)
|
.map(namespacePath::relativize)
|
||||||
.map((p) -> p.toString().replace(separator, "/"))
|
.map((p) -> p.toString().replace(separator, "/"))
|
||||||
.forEach((s) -> {
|
.forEach((s) -> {
|
||||||
try {
|
try {
|
||||||
ids.add(new Identifier(namespace, s));
|
ids.add(new Identifier(namespace, s));
|
||||||
} catch (InvalidIdentifierException e) {
|
} catch (InvalidIdentifierException e) {
|
||||||
LOGGER.error(e.getMessage());
|
LOGGER.error(e.getMessage());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LOGGER.warn("findResources at " + path + " in namespace " + namespace + ", mod " + modInfo.getId() + " failed!", e);
|
LOGGER.warn("findResources at " + path + " in namespace " + namespace + ", mod " + modInfo.getId() + " failed!", e);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue