Skip to content

Commit

Permalink
Merge pull request #530 from embeddedt/16-update
Browse files Browse the repository at this point in the history
[1.16] Port #529 and clean up build system
  • Loading branch information
Asek3 authored Jan 26, 2024
2 parents 1157255 + 6144a5b commit ade177d
Show file tree
Hide file tree
Showing 382 changed files with 101 additions and 79,462 deletions.
40 changes: 31 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
id 'dev.architectury.loom' version '0.10.0-SNAPSHOT'
id 'com.github.johnrengelman.shadow' version '7.1.2'
id 'maven-publish'
}

Expand Down Expand Up @@ -47,22 +48,24 @@ repositories {
}
}

configurations {
toJar
}

dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings loom.officialMojangMappings()
forge "net.minecraftforge:forge:${minecraft_version}-${forge_version}"

compileOnly "org.apache.ant:ant:1.8.2"
modCompileOnly "maven.modrinth:rubidium:0.2.13"
//modCompileOnly "me.jellysquid.mods:Rubidium:0.2.13"
modCompileOnly "curse.maven:epic-fight-mod-405076:4029362"

implementation fileTree(include: ['*.jar'], dir: 'libs')
toJar fileTree(include: ['antlr4-runtime-4.10.1.jar', 'glsl-transformer-1.0.0-pre21.2.jar'], dir: 'libs')
modRuntimeOnly "curse.maven:lazydfu-460819:3249059"

implementation(shadow(project(path: ":glsl-relocated", configuration: "bundledJar"))) {
transitive = false
}
implementation(shadow("org.anarres:jcpp:1.4.14")) {
transitive = false
}
shadow("org.slf4j:slf4j-api:1.7.12") // for jcpp
}

processResources {
Expand All @@ -86,8 +89,27 @@ java {
withSourcesJar()
}

jar {
from { configurations.toJar.collect { it.isDirectory() ? it : zipTree(it) } }
shadowJar {
configurations = [project.configurations.shadow]

from jar.archiveFile

relocate 'org.apache.commons.collections4', 'oculus.org.apache.commons.collections4'
relocate 'org.anarres.cpp', 'oculus.org.anarres.cpp'
relocate 'org.slf4j', 'oculus.org.slf4j'

archiveClassifier.set "shadow"

manifest {
attributes(
'Main-Class': 'net.coderbot.iris.LaunchWarn'
)
}
}

remapJar {
input.set shadowJar.archiveFile
dependsOn shadowJar
}

publishing {
Expand Down
42 changes: 42 additions & 0 deletions glsl-relocated/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
plugins {
id 'java-library'
id 'com.github.johnrengelman.shadow'
}

repositories {
mavenCentral()
}

dependencies {
implementation(shadow("io.github.douira:glsl-transformer:1.0.1")) {
exclude module: "antlr4" // we only want to shadow the runtime module
}
implementation shadow("org.antlr:antlr4-runtime:4.10.1")
}

shadowJar {
configurations = [project.configurations.shadow]

from jar.archiveFile

relocate 'org.antlr', 'oculus.org.antlr'

archiveClassifier.set "shadow"
}



configurations {
bundledJar {
canBeConsumed = true
canBeResolved = false
// If you want this configuration to share the same dependencies, otherwise omit this line
extendsFrom implementation, runtimeOnly
}
}



artifacts {
bundledJar(shadowJar)
}
2 changes: 2 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ pluginManagement {
gradlePluginPortal()
}
}

include("glsl-relocated")
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;

import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.objects.Reference2ReferenceOpenHashMap;
import net.coderbot.iris.Iris;
import net.coderbot.iris.shaderpack.materialmap.BlockEntry;
Expand All @@ -20,6 +22,8 @@
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.registries.ForgeRegistries;
import net.minecraftforge.registries.IRegistryDelegate;

public class BlockMaterialMapping {
public static Object2IntMap<BlockState> createBlockStateIdMap(Int2ObjectMap<List<BlockEntry>> blockPropertiesMap) {
Expand All @@ -34,15 +38,19 @@ 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<IRegistryDelegate<Block>, RenderType> createBlockTypeMap(Map<NamespacedId, BlockRenderType> blockPropertiesMap) {
Map<IRegistryDelegate<Block>, RenderType> blockTypeIds = new Object2ObjectOpenHashMap<>();

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

Block block = Registry.BLOCK.get(resourceLocation);
Block block = ForgeRegistries.BLOCKS.getValue(resourceLocation);

blockTypeIds.put(block, convertBlockToRenderType(blockType));
if (block == null || block == Blocks.AIR) {
return;
}

blockTypeIds.put(block.delegate, convertBlockToRenderType(blockType));
});

return blockTypeIds;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.Map;

import net.minecraftforge.registries.IRegistryDelegate;
import org.jetbrains.annotations.Nullable;

import it.unimi.dsi.fastutil.objects.Object2IntFunction;
Expand All @@ -16,7 +17,7 @@ public class BlockRenderingSettings {

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

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

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

public void setBlockTypeIds(Map<Block, RenderType> blockTypeIds) {
public void setBlockTypeIds(Map<IRegistryDelegate<Block>, RenderType> blockTypeIds) {
if (this.blockTypeIds != null && this.blockTypeIds.equals(blockTypeIds)) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.Map;

import net.minecraftforge.registries.IRegistryDelegate;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
Expand All @@ -17,9 +18,9 @@
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();
Map<IRegistryDelegate<Block>, RenderType> idMap = BlockRenderingSettings.INSTANCE.getBlockTypeIds();
if (idMap != null) {
RenderType type = idMap.get(arg.getBlock());
RenderType type = idMap.get(arg.getBlock().delegate);
if (type != null) {
cir.setReturnValue(type);
}
Expand All @@ -28,11 +29,12 @@ public class MixinItemBlockRenderTypes {

@Inject(method = "canRenderInLayer(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/client/renderer/RenderType;)Z", at = @At("HEAD"), cancellable = true)
private static void iris$checkCustomRenderType(BlockState arg, RenderType type, CallbackInfoReturnable<Boolean> cir) {
Map<Block, RenderType> idMap = BlockRenderingSettings.INSTANCE.getBlockTypeIds();
Map<IRegistryDelegate<Block>, RenderType> idMap = BlockRenderingSettings.INSTANCE.getBlockTypeIds();
if (idMap != null) {
RenderType irisType = idMap.get(arg.getBlock());
if (type.equals(irisType)) {
cir.setReturnValue(true);
RenderType irisType = idMap.get(arg.getBlock().delegate);
if (irisType != null) {
// If we have an override registered for this block, only allow rendering precisely that type
cir.setReturnValue(type.equals(irisType));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.antlr.v4.runtime.RecognitionException;
import org.antlr.v4.runtime.Token;
import oculus.org.antlr.v4.runtime.RecognitionException;
import oculus.org.antlr.v4.runtime.Token;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

Expand Down
76 changes: 0 additions & 76 deletions src/main/java/org/anarres/cpp/Argument.java

This file was deleted.

Loading

0 comments on commit ade177d

Please sign in to comment.