fix: more injection fix + bad culling #20
@ -9,7 +9,7 @@ loader_version=0.15.11
|
||||
|
||||
# Mod Properties
|
||||
modrinth_id = jCpoCBpn
|
||||
mod_version = 1.6.1
|
||||
mod_version = 1.6.2
|
||||
maven_group = fr.adrien1106
|
||||
archives_base_name = ReFramed
|
||||
mod_id = reframed
|
||||
|
@ -6,11 +6,13 @@ import com.moulberry.axiom.utils.IntMatrix;
|
||||
import com.moulberry.axiom.world_modification.CompressedBlockEntity;
|
||||
import fr.adrien1106.reframed.client.model.MultiRetexturableModel;
|
||||
import fr.adrien1106.reframed.client.model.RetexturingBakedModel;
|
||||
import fr.adrien1106.reframed.util.DefaultList;
|
||||
import fr.adrien1106.reframed.util.mixin.IAxiomChunkedBlockRegionMixin;
|
||||
import fr.adrien1106.reframed.util.mixin.IMultipartBakedModelMixin;
|
||||
import fr.adrien1106.reframed.util.mixin.ThemedBlockEntity;
|
||||
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.client.render.BufferBuilder;
|
||||
import net.minecraft.client.render.Camera;
|
||||
@ -78,15 +80,19 @@ public abstract class AxiomChunkedBlockRegionMixin implements IAxiomChunkedBlock
|
||||
cancellable = true)
|
||||
private static void onRenderBlock(BufferBuilder blockBuilder, BlockRenderManager renderer, BlockPos.Mutable pos, Random rand, MatrixStack matrices, BlockRenderView world, Matrix4f currentPoseMatrix, Matrix4f basePoseMatrix, int x, int y, int z, BlockState state, boolean useAmbientOcclusion, CallbackInfo ci, @Local BakedModel model) {
|
||||
List<BakedModel> models;
|
||||
if ((models = getModels(model, state)).isEmpty() // not a retexturable model
|
||||
|| !(world.getBlockEntity(pos) instanceof ThemedBlockEntity block_entity) // not a themed block entity
|
||||
) return;
|
||||
if ((models = getModels(model, state)).isEmpty()) return;
|
||||
|
||||
DefaultList<BlockState> themes = new DefaultList<>(
|
||||
Blocks.AIR.getDefaultState(),
|
||||
world.getBlockEntity(pos) instanceof ThemedBlockEntity themed
|
||||
? themed.getThemes()
|
||||
: List.of()
|
||||
);
|
||||
models.stream().flatMap(m -> m instanceof MultiRetexturableModel mm
|
||||
? mm.models().stream()
|
||||
: Stream.of((RetexturingBakedModel)m)
|
||||
).forEach(m -> {
|
||||
m.setCamo(world, block_entity.getTheme(m.getThemeIndex()), pos);
|
||||
m.setCamo(world, themes.get(m.getThemeIndex() - 1), pos);
|
||||
if (useAmbientOcclusion && state.getLuminance() == 0 && m.useAmbientOcclusion()) renderer.getModelRenderer()
|
||||
.renderSmooth(world, m, state, pos, matrices, blockBuilder, true, rand, state.getRenderingSeed(pos), OverlayTexture.DEFAULT_UV);
|
||||
else renderer.getModelRenderer()
|
||||
|
@ -1,6 +1,5 @@
|
||||
package fr.adrien1106.reframed.mixin.compat;
|
||||
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import fr.adrien1106.reframed.client.util.RenderHelper;
|
||||
import fr.adrien1106.reframed.util.blocks.ThemeableBlockEntity;
|
||||
import fr.adrien1106.reframed.util.mixin.IBlockRenderInfoMixin;
|
||||
@ -24,7 +23,6 @@ public abstract class IndiumBlockRenderInfoMixin implements IBlockRenderInfoMixi
|
||||
@Shadow public BlockPos blockPos;
|
||||
@Shadow public BlockRenderView blockView;
|
||||
@Shadow public BlockState blockState;
|
||||
@Shadow(remap = false) private int cullResultFlags;
|
||||
|
||||
@Unique private int theme_index = 0;
|
||||
@Unique private int model_hash = 0;
|
||||
@ -32,19 +30,18 @@ public abstract class IndiumBlockRenderInfoMixin implements IBlockRenderInfoMixi
|
||||
@Inject(
|
||||
method = "shouldDrawFace",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Llink/infra/indium/renderer/render/BlockRenderInfo;shouldDrawFaceInner(Lnet/minecraft/util/math/Direction;)Z"
|
||||
value = "INVOKE_ASSIGN",
|
||||
target = "Lnet/minecraft/util/math/Direction;getId()I",
|
||||
shift = At.Shift.AFTER
|
||||
),
|
||||
cancellable = true
|
||||
)
|
||||
private void shouldDrawInnerFace(Direction face, CallbackInfoReturnable<Boolean> cir, @Local int mask) {
|
||||
private void shouldDrawInnerFace(Direction face, CallbackInfoReturnable<Boolean> cir) {
|
||||
BlockPos other_pos = blockPos.offset(face);
|
||||
if (!(blockView.getBlockEntity(blockPos) instanceof ThemeableBlockEntity
|
||||
|| blockView.getBlockEntity(other_pos) instanceof ThemeableBlockEntity)
|
||||
) return;
|
||||
boolean result = RenderHelper.shouldDrawSide(blockState, blockView, blockPos, face, other_pos, theme_index);
|
||||
if (result) cullResultFlags |= mask;
|
||||
cir.setReturnValue(result);
|
||||
cir.setReturnValue(RenderHelper.shouldDrawSide(blockState, blockView, blockPos, face, other_pos, theme_index));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -42,7 +42,6 @@ public abstract class IndiumNonTerrainBlockRenderContextMixin extends AbstractBl
|
||||
target = "Llink/infra/indium/renderer/render/BlockRenderInfo;prepareForWorld(Lnet/minecraft/world/BlockRenderView;Z)V",
|
||||
shift = At.Shift.AFTER
|
||||
),
|
||||
remap = false,
|
||||
cancellable = true
|
||||
)
|
||||
private void renderMultipleModels(BlockRenderView blockView, BakedModel wrapper, BlockState state, BlockPos pos, MatrixStack matrixStack, VertexConsumer buffer, boolean cull, Random random, long seed, int overlay, CallbackInfo ci) {
|
||||
|
140
src/main/java/fr/adrien1106/reframed/util/DefaultList.java
Normal file
140
src/main/java/fr/adrien1106/reframed/util/DefaultList.java
Normal file
@ -0,0 +1,140 @@
|
||||
package fr.adrien1106.reframed.util;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
|
||||
public class DefaultList<T> implements List<T> {
|
||||
|
||||
protected T default_value;
|
||||
protected List<T> elements;
|
||||
|
||||
public DefaultList(T default_value, List<T> elements) {
|
||||
this.default_value = default_value;
|
||||
this.elements = elements;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return elements.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return elements.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Object o) {
|
||||
return elements.contains(o) || default_value.equals(o);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Iterator<T> iterator() {
|
||||
return elements.iterator();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Object[] toArray() {
|
||||
return elements.toArray();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public <T1> T1[] toArray(@NotNull T1[] a) {
|
||||
return elements.toArray(a);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean add(T t) {
|
||||
return elements.add(t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(Object o) {
|
||||
return elements.remove(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsAll(@NotNull Collection<?> c) {
|
||||
return elements.containsAll(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAll(@NotNull Collection<? extends T> c) {
|
||||
return elements.addAll(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAll(int index, @NotNull Collection<? extends T> c) {
|
||||
return elements.addAll(index, c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeAll(@NotNull Collection<?> c) {
|
||||
return elements.removeAll(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean retainAll(@NotNull Collection<?> c) {
|
||||
return elements.retainAll(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
elements.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(int index) {
|
||||
return index < elements.size() && index >= 0 ? elements.get(index) : default_value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T set(int index, T element) {
|
||||
return elements.set(index, element);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(int index, T element) {
|
||||
elements.add(index, element);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T remove(int index) {
|
||||
return elements.remove(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int indexOf(Object o) {
|
||||
return elements.indexOf(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int lastIndexOf(Object o) {
|
||||
return elements.lastIndexOf(o);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ListIterator<T> listIterator() {
|
||||
return elements.listIterator();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ListIterator<T> listIterator(int index) {
|
||||
return elements.listIterator();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<T> subList(int fromIndex, int toIndex) {
|
||||
return elements.subList(fromIndex, toIndex);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user