Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some bugs #502

Merged
merged 5 commits into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ repositories {
includeGroup "maven.modrinth"
}
}
maven { url "https://maven.blamejared.com/" }
maven {
url "https://maven.su5ed.dev/releases"
}
Expand All @@ -51,7 +52,7 @@ dependencies {
forge "net.minecraftforge:forge:${minecraft_version}-${forge_version}"

//modCompileOnly "maven.modrinth:rubidium:0.7.1"
modCompileOnly "me.jellysquid.mods:rubidium-upstream:0.7.1+git.1cdb739"
modCompileOnly "org.embeddedt:embeddium-1.20.1:0.2.12-git.149aa28+mc1.20.1"
}

processResources {
Expand Down
Empty file modified gradlew
100644 → 100755
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.Property;
import net.minecraftforge.client.ChunkRenderTypeSet;

import java.util.HashMap;
import java.util.List;
Expand All @@ -35,15 +36,15 @@ public static Object2IntMap<BlockState> createBlockStateIdMap(Int2ObjectMap<List
return blockStateIds;
}

public static Map<Block, RenderType> createBlockTypeMap(Map<NamespacedId, BlockRenderType> blockPropertiesMap) {
Map<Block, RenderType> blockTypeIds = new Reference2ReferenceOpenHashMap<>();
public static Map<Block, ChunkRenderTypeSet> createBlockTypeMap(Map<NamespacedId, BlockRenderType> blockPropertiesMap) {
Map<Block, ChunkRenderTypeSet> blockTypeIds = new Reference2ReferenceOpenHashMap<>();

blockPropertiesMap.forEach((id, blockType) -> {
ResourceLocation resourceLocation = new ResourceLocation(id.getNamespace(), id.getName());

Block block = BuiltInRegistries.BLOCK.get(resourceLocation);

blockTypeIds.put(block, convertBlockToRenderType(blockType));
blockTypeIds.put(block, ChunkRenderTypeSet.of(convertBlockToRenderType(blockType)));
});

return blockTypeIds;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import net.minecraft.client.renderer.RenderType;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.client.ChunkRenderTypeSet;
import org.jetbrains.annotations.Nullable;

import java.util.Map;
Expand All @@ -15,7 +16,7 @@ public class BlockRenderingSettings {

private boolean reloadRequired;
private Object2IntMap<BlockState> blockStateIds;
private Map<Block, RenderType> blockTypeIds;
private Map<Block, ChunkRenderTypeSet> blockTypeIds;
private Object2IntFunction<NamespacedId> entityIds;
private Object2IntFunction<NamespacedId> itemIds;
private float ambientOcclusionLevel;
Expand Down Expand Up @@ -53,7 +54,7 @@ public Object2IntMap<BlockState> getBlockStateIds() {
}

@Nullable
public Map<Block, RenderType> getBlockTypeIds() {
public Map<Block, ChunkRenderTypeSet> getBlockTypeIds() {
return blockTypeIds;
}

Expand All @@ -77,7 +78,7 @@ public void setBlockStateIds(Object2IntMap<BlockState> blockStateIds) {
this.blockStateIds = blockStateIds;
}

public void setBlockTypeIds(Map<Block, RenderType> blockTypeIds) {
public void setBlockTypeIds(Map<Block, ChunkRenderTypeSet> blockTypeIds) {
if (this.blockTypeIds != null && this.blockTypeIds.equals(blockTypeIds)) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,14 @@ public MixinRegionChunkRenderer(RenderDevice device, ChunkVertexType vertexType)
}

@Redirect(remap = false, method = "createRegionTessellation", at = @At(value = "INVOKE", target = "Lme/jellysquid/mods/sodium/client/gl/tessellation/TessellationBinding;forVertexBuffer(Lme/jellysquid/mods/sodium/client/gl/buffer/GlBuffer;[Lme/jellysquid/mods/sodium/client/gl/attribute/GlVertexAttributeBinding;)Lme/jellysquid/mods/sodium/client/gl/tessellation/TessellationBinding;"))
@SuppressWarnings({"rawtypes", "unchecked"})
private TessellationBinding iris$onInit(GlBuffer buffer, GlVertexAttributeBinding[] attributes) {
if (!BlockRenderingSettings.INSTANCE.shouldUseExtendedVertexFormat()) {
return TessellationBinding.forVertexBuffer(buffer, attributes);
}

GlVertexFormat vertexFormat = this.vertexFormat;

attributes = new GlVertexAttributeBinding[]{
new GlVertexAttributeBinding(IrisChunkShaderBindingPoints.ATTRIBUTE_POSITION_ID,
vertexFormat.getAttribute(IrisChunkMeshAttributes.POSITION_MATERIAL_MESH)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import net.minecraft.client.renderer.RenderType;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.client.ChunkRenderTypeSet;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
Expand All @@ -14,11 +15,11 @@

@Mixin(ItemBlockRenderTypes.class)
public class MixinItemBlockRenderTypes {
@Inject(method = "getChunkRenderType", at = @At("HEAD"), cancellable = true)
private static void iris$setCustomRenderType(BlockState arg, CallbackInfoReturnable<RenderType> cir) {
Map<Block, RenderType> idMap = BlockRenderingSettings.INSTANCE.getBlockTypeIds();
@Inject(method = "getRenderLayers", at = @At("HEAD"), cancellable = true, remap = false)
private static void iris$setCustomRenderType(BlockState arg, CallbackInfoReturnable<ChunkRenderTypeSet> cir) {
Map<Block, ChunkRenderTypeSet> idMap = BlockRenderingSettings.INSTANCE.getBlockTypeIds();
if (idMap != null) {
RenderType type = idMap.get(arg.getBlock());
ChunkRenderTypeSet type = idMap.get(arg.getBlock());
if (type != null) {
cir.setReturnValue(type);
}
Expand Down
dima-dencep marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.coderbot.iris.mixin.fantastic;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import net.coderbot.iris.fantastic.ParticleRenderingPhase;
Expand All @@ -23,10 +24,7 @@
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.*;
import java.util.function.Supplier;

/**
Expand Down Expand Up @@ -63,10 +61,10 @@ public class MixinParticleEngine implements PhasedParticleEngine {
@Final
private Map<ParticleRenderType, Queue<Particle>> particles;

private static final List<ParticleRenderType> OPAQUE_PARTICLE_RENDER_TYPES;
private static final Set<ParticleRenderType> OPAQUE_PARTICLE_RENDER_TYPES;

static {
OPAQUE_PARTICLE_RENDER_TYPES = ImmutableList.of(
OPAQUE_PARTICLE_RENDER_TYPES = ImmutableSet.of(
ParticleRenderType.PARTICLE_SHEET_OPAQUE,
ParticleRenderType.PARTICLE_SHEET_LIT,
ParticleRenderType.CUSTOM,
Expand All @@ -81,20 +79,13 @@ public class MixinParticleEngine implements PhasedParticleEngine {

@Redirect(method = "render(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource$BufferSource;Lnet/minecraft/client/renderer/LightTexture;Lnet/minecraft/client/Camera;FLnet/minecraft/client/renderer/culling/Frustum;)V", at = @At(value = "FIELD", target = "Lnet/minecraft/client/particle/ParticleEngine;particles:Ljava/util/Map;"))
private Map<ParticleRenderType, Queue<Particle>> iris$selectParticlesToRender(ParticleEngine instance) {
Map<ParticleRenderType, Queue<Particle>> toRender = new HashMap<>(particles);
if (phase == ParticleRenderingPhase.TRANSLUCENT) {
// Remove all known opaque particle texture sheets.
for(ParticleRenderType type : OPAQUE_PARTICLE_RENDER_TYPES)
toRender.remove(type);

return toRender;
return Maps.filterKeys(particles, type -> !OPAQUE_PARTICLE_RENDER_TYPES.contains(type));
} else if (phase == ParticleRenderingPhase.OPAQUE) {
// Render only opaque particle sheets
toRender.remove(ParticleRenderType.PARTICLE_SHEET_TRANSLUCENT);
return toRender;
return Maps.filterKeys(particles, type -> !type.equals(ParticleRenderType.PARTICLE_SHEET_TRANSLUCENT));
} else {
// Don't override particle rendering
return toRender;
return particles;
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
package net.coderbot.iris.mixin.fantastic;

import net.coderbot.iris.fantastic.IrisParticleRenderTypes;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.particle.BlockMarker;
import net.minecraft.client.particle.ParticleRenderType;
import net.minecraft.client.renderer.ItemBlockRenderTypes;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.client.ChunkRenderTypeSet;
import net.minecraftforge.client.model.data.ModelData;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
Expand All @@ -21,9 +26,10 @@ public class MixinStationaryItemParticle {

@Inject(method = "<init>", at = @At("RETURN"))
private void iris$resolveTranslucency(ClientLevel clientLevel, double d, double e, double f, BlockState blockState, CallbackInfo ci) {
RenderType type = ItemBlockRenderTypes.getChunkRenderType(blockState);
BakedModel model = Minecraft.getInstance().getBlockRenderer().getBlockModel(blockState);
ChunkRenderTypeSet types = model.getRenderTypes(blockState, clientLevel.random, ModelData.EMPTY);

if (type == RenderType.solid() || type == RenderType.cutout() || type == RenderType.cutoutMipped()) {
if (types.contains(RenderType.solid()) || types.contains(RenderType.cutout()) || types.contains(RenderType.cutoutMipped())) {
isOpaque = true;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
package net.coderbot.iris.mixin.fantastic;

import net.coderbot.iris.fantastic.IrisParticleRenderTypes;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.particle.ParticleRenderType;
import net.minecraft.client.particle.TerrainParticle;
import net.minecraft.client.renderer.ItemBlockRenderTypes;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.client.ChunkRenderTypeSet;
import net.minecraftforge.client.model.data.ModelData;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
Expand All @@ -22,9 +26,10 @@ public class MixinTerrainParticle {

@Inject(method = "<init>(Lnet/minecraft/client/multiplayer/ClientLevel;DDDDDDLnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/core/BlockPos;)V", at = @At("RETURN"))
private void iris$resolveTranslucency(ClientLevel level, double x, double y, double z, double velocityX, double velocityY, double velocityZ, BlockState blockState, BlockPos blockPos, CallbackInfo ci) {
RenderType type = ItemBlockRenderTypes.getChunkRenderType(blockState);
BakedModel model = Minecraft.getInstance().getBlockRenderer().getBlockModel(blockState);
ChunkRenderTypeSet types = model.getRenderTypes(blockState, level.random, ModelData.EMPTY);

if (type == RenderType.solid() || type == RenderType.cutout() || type == RenderType.cutoutMipped()) {
if (types.contains(RenderType.solid()) || types.contains(RenderType.cutout()) || types.contains(RenderType.cutoutMipped())) {
isOpaque = true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

@Mixin(TextureManager.class)
public class MixinTextureManager {
@Inject(method = "m_244739_", at = @At("TAIL"))
@Inject(method = { "method_18167", "m_244739_", "lambda$reload$5" }, at = @At("TAIL"), remap = false)
private void iris$onTailReloadLambda(ResourceManager resourceManager, Executor applyExecutor, CompletableFuture<?> future, Void void1, CallbackInfo ci) {
TextureFormatLoader.reload(resourceManager);
PBRTextureManager.INSTANCE.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,21 @@
*/
@Mixin(ClientLevel.class)
public class MixinClientLevel {
@ModifyVariable(method = "getShade", at = @At("HEAD"), argsOnly = true)
@ModifyVariable(method = "getShade(Lnet/minecraft/core/Direction;Z)F", at = @At("HEAD"), argsOnly = true)
private boolean iris$maybeDisableDirectionalShading(boolean shaded) {
if (BlockRenderingSettings.INSTANCE.shouldDisableDirectionalShading()) {
return false;
} else {
return shaded;
}
}

@ModifyVariable(method = "getShade(FFFZ)F", at = @At("HEAD"), argsOnly = true, remap = false)
private boolean iris$maybeDisableDirectionalShadingForge(boolean shaded) {
if (BlockRenderingSettings.INSTANCE.shouldDisableDirectionalShading()) {
return false;
} else {
return shaded;
}
}
}
7 changes: 6 additions & 1 deletion src/main/java/net/coderbot/iris/pipeline/HandRenderer.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package net.coderbot.iris.pipeline;

import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.client.model.data.ModelData;
import org.joml.Matrix4f;
import net.coderbot.batchedentityrendering.impl.FullyBufferedMultiBufferSource;
import net.coderbot.iris.mixin.GameRendererAccessor;
Expand Down Expand Up @@ -60,7 +63,9 @@ public boolean isHandTranslucent(InteractionHand hand) {
Item item = Minecraft.getInstance().player.getItemBySlot(hand == InteractionHand.OFF_HAND ? EquipmentSlot.OFFHAND : EquipmentSlot.MAINHAND).getItem();

if (item instanceof BlockItem) {
return ItemBlockRenderTypes.getChunkRenderType(((BlockItem) item).getBlock().defaultBlockState()) == RenderType.translucent();
BlockState state = ((BlockItem) item).getBlock().defaultBlockState();
BakedModel model = Minecraft.getInstance().getBlockRenderer().getBlockModel(state);
return model.getRenderTypes(state, Minecraft.getInstance().level.random, ModelData.EMPTY).contains(RenderType.translucent());
}

return false;
Expand Down
Loading