Skip to content

Commit fe514ce

Browse files
committed
Port to 1.18.2, many random fixes
1 parent b2fceba commit fe514ce

31 files changed

+252
-341
lines changed

build.gradle

+16-50
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
buildscript {
22
repositories {
33
maven { url = 'https://maven.minecraftforge.net/' }
4-
maven { url = 'https://repo.spongepowered.org/maven' }
5-
mavenCentral()
64
}
75
dependencies {
8-
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true
96
classpath 'org.spongepowered:mixingradle:0.7.+'
107
}
118
}
@@ -14,14 +11,13 @@ plugins {
1411
id 'java'
1512
id 'maven-publish'
1613
id 'com.github.johnrengelman.shadow' version '7.1.2'
14+
id 'net.minecraftforge.gradle' version '5.1.+'
15+
id 'org.parchmentmc.librarian.forgegradle' version '1.+'
16+
id 'org.spongepowered.mixin' version '0.7.+'
1717
}
18-
apply plugin: 'net.minecraftforge.gradle'
19-
// Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
20-
apply plugin: 'org.spongepowered.mixin'
2118

2219
version = project.mod_version
2320
group = project.maven_group
24-
archivesBaseName = "${project.archives_base_name}-${project.minecraft_version}"
2521

2622
repositories {
2723
maven {
@@ -69,7 +65,7 @@ java.toolchain.languageVersion = JavaLanguageVersion.of(17)
6965
println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))
7066

7167
minecraft {
72-
mappings channel: 'official', version: snapshot
68+
mappings channel: mappings_channel, version: mappings_version
7369

7470
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
7571
accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
@@ -88,11 +84,6 @@ minecraft {
8884
// Recommended logging level for the console
8985
property 'forge.logging.console.level', 'debug'
9086

91-
//args '--mixin', 'mixins.dsurround.json'
92-
//args '--mixin', 'mixins.sndctrl.json'
93-
//args '--mixin', 'mixins.mobeffects.json'
94-
//args '--mixin', 'mixins.environs.json'
95-
9687
mods {
9788
dsurround {
9889
source sourceSets.main
@@ -160,45 +151,20 @@ dependencies {
160151
// The userdev artifact is a special name and will get all sorts of transformations applied to it.
161152
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
162153

163-
annotationProcessor 'org.spongepowered:mixin:0.8.4:processor'
164-
165-
// You may put jars on which you depend on in ./libs or you may define them like so..
166-
// compile "some.group:artifact:version:classifier"
167-
// compile "some.group:artifact:version"
168-
169-
// Real examples
170-
// compile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // adds buildcraft to the dev env
171-
// compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env
172-
173-
// The 'provided' configuration is for optional dependencies that exist at compile-time but might not at runtime.
174-
// provided 'com.mod-buildcraft:buildcraft:6.0.8:dev'
154+
annotationProcessor "org.spongepowered:mixin:${mixin_version}:processor"
175155

176-
// These dependencies get remapped to your current MCP mappings
177-
// deobf 'com.mod-buildcraft:buildcraft:6.0.8:dev'
156+
// implementation fg.deobf("curse.maven:SereneSeasons-291874:3621343")
157+
implementation fg.deobf("me.shedaniel.cloth:cloth-config-forge:${cloth_config_version}")
178158

179-
// For more info...
180-
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
181-
// http://www.gradle.org/docs/current/userguide/dependency_management.html
182-
183-
implementation fg.deobf("curse.maven:SereneSeasons-291874:3621343")
184-
implementation fg.deobf("curse.maven:clothAPI-348521:3641133")
185-
186-
runtimeOnly fg.deobf("curse.maven:jei-238222:3723162")
187-
runtimeOnly fg.deobf("curse.maven:TheOneProbe-245211:3665852")
159+
runtimeOnly fg.deobf("curse.maven:jei-238222:${jei_file_id}")
160+
runtimeOnly fg.deobf("curse.maven:the-one-probe-245211:${the_one_probe_file_id}")
188161

189162
// Capability Syncer
190163
shadow fg.deobf("dev._100media.capabilitysyncer:capabilitysyncer:${capabilitysyncer_version}")
191164
}
192165

193-
processResources {
194-
duplicatesStrategy = DuplicatesStrategy.FAIL
195-
filesMatching("META-INF/mods.toml") {
196-
expand 'version': project.version
197-
}
198-
}
199-
200166
jar {
201-
167+
archiveClassifier = 'slim'
202168
from(configurations.embed.collect { it.isDirectory() ? it : zipTree(it) }) {
203169
exclude "LICENSE.txt", "META-INF/MANIFSET.MF", "META-INF/maven/**", "META-INF/*.RSA", "META-INF/*.SF"
204170
}
@@ -210,17 +176,15 @@ jar {
210176

211177
manifest {
212178
attributes([
213-
//"MixinConfigs": "mixins.dsurround.json,mixins.sndctrl.json,mixins.mobeffects.json,mixins.environs.json",
214179
"Specification-Title": "${mod_id}",
215180
"Specification-Vendor": "OreCruncher",
216181
"Specification-Version": "1", // We are version 1 of ourselves
217182
"Implementation-Title": project.name,
218-
"Implementation-Version": "${version}",
183+
"Implementation-Version": project.version,
219184
"Implementation-Vendor" : "OreCruncher",
220185
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
221186
])
222187
}
223-
224188
}
225189

226190
def relocateTargets = ['dev._100media.capabilitysyncer']
@@ -233,9 +197,7 @@ shadowJar {
233197
finalizedBy 'reobfShadowJar'
234198
}
235199

236-
artifacts {
237-
shadowJar
238-
}
200+
assemble.dependsOn shadowJar
239201

240202
reobf {
241203
shadowJar {}
@@ -252,6 +214,10 @@ jar.finalizedBy('reobfJar')
252214
// However if you are in a multi-project build, dev time needs unobfed jar files, so you can delay the obfuscation until publishing by doing
253215
// publish.dependsOn('reobfJar')
254216

217+
tasks.withType(JavaCompile).configureEach {
218+
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
219+
}
220+
255221
publishing {
256222
publications {
257223
mavenJava(MavenPublication) {

configuration.gradle

-37
This file was deleted.

gradle.properties

+14-7
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,22 @@
22
# This is required to provide enough memory for the Minecraft decompilation process.
33
org.gradle.jvmargs=-Xmx3G
44
org.gradle.daemon=false
5-
# Base Forge info
6-
minecraft_version=1.18.1
7-
forge_version=39.1.0
8-
snapshot=1.18.1
5+
6+
# Base Forge Info
7+
minecraft_version=1.18.2
8+
forge_version=40.1.0
9+
mappings_channel=parchment
10+
mappings_version=2022.05.22-1.18.2
11+
912
# Mod Properties
1013
mod_id=dsurround
1114
mod_version=4.0.5.0
1215
maven_group=org.orecruncher
13-
archives_base_name=DynamicSurroundings
14-
updateurl=https://raw.githubusercontent.com/OreCruncher/DynamicSurroundings2/master/version.json
15-
capabilitysyncer_version=1.18.2-2.0.7
16+
mod_name=DynamicSurroundings
1617

18+
# Dependencies
19+
mixin_version=0.8.5
20+
capabilitysyncer_version=1.18.2-2.0.7
21+
cloth_config_version=6.2.62
22+
jei_file_id=3723913
23+
the_one_probe_file_id=3671753

settings.gradle

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
pluginManagement {
2+
repositories {
3+
gradlePluginPortal()
4+
maven {
5+
name 'MinecraftForge'
6+
url 'https://maven.minecraftforge.net/'
7+
}
8+
maven {
9+
name 'ParchmentMC'
10+
url 'https://maven.parchmentmc.org'
11+
}
12+
}
13+
resolutionStrategy {
14+
eachPlugin {
15+
if (requested.id.toString() == 'org.spongepowered.mixin') {
16+
useModule("org.spongepowered:mixingradle:${requested.version}")
17+
}
18+
}
19+
}
20+
}
21+
22+
rootProject.name = mod_name

src/main/java/org/orecruncher/dsurround/commands/dump/DumpCommand.java

-5
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ public static void register(@Nonnull final CommandDispatcher<CommandSourceStack>
4848
.then(Commands.literal("acoustics").executes(cmd -> dumpAcoustics(cmd.getSource())))
4949
.then(Commands.literal("audioeffects").executes(cmd -> dumpAudioEffects(cmd.getSource())))
5050
.then(Commands.literal("blocks").executes(cmd -> dumpBlocks(cmd.getSource())))
51-
.then(Commands.literal("blocktags").executes(cmd -> dumpBlockTags(cmd.getSource())))
5251
.then(Commands.literal("biomes").executes(cmd -> dumpBiomes(cmd.getSource())))
5352
.then(Commands.literal("items").executes(cmd -> dumpItems(cmd.getSource())))
5453
.then(Commands.literal("footsteps").executes(cmd -> dumpFootsteps(cmd.getSource())))
@@ -69,10 +68,6 @@ private static int dumpBlocks(@Nonnull final CommandSourceStack source) {
6968
return handle(source, "dump.blocks", DumpCommand::tbd);
7069
}
7170

72-
private static int dumpBlockTags(@Nonnull final CommandSourceStack source) {
73-
return handle(source, "dump.blocktags", TagUtils::dumpBlockTags);
74-
}
75-
7671
private static int dumpBiomes(@Nonnull final CommandSourceStack source) {
7772
return handle(source, "dump.biomes", DumpCommand::tbd);
7873
}

src/main/java/org/orecruncher/environs/fog/BiomeFogRangeCalculator.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public FogResult calculate(@Nonnull final EntityViewRenderEvent.RenderFogEvent e
6060
final BiomeManager biomemanager = world.getBiomeManager();
6161
final Vec3 origin = GameUtils.getMC().gameRenderer.getMainCamera().getPosition().subtract(2.0D, 2.0D, 2.0D).scale(0.25D);
6262
final Vec3 visibilitySurvey = CubicSampler.gaussianSampleVec3(origin, (x, y, z) -> {
63-
final Biome b = biomemanager.getNoiseBiomeAtQuart(x, y, z);
63+
final Biome b = biomemanager.getNoiseBiomeAtQuart(x, y, z).value();
6464
final BiomeInfo info = BiomeUtil.getBiomeData(b);
6565
return new Vec3(info.getVisibility(), 0, 0);
6666
});

src/main/java/org/orecruncher/environs/library/BiomeLibrary.java

+11-7
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@
2121
import com.google.gson.reflect.TypeToken;
2222
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
2323
import net.minecraft.core.BlockPos;
24-
import net.minecraft.data.worldgen.biome.Biomes;
24+
import net.minecraft.core.Registry;
25+
import net.minecraft.core.RegistryAccess;
2526
import net.minecraft.tags.FluidTags;
2627
import net.minecraft.world.entity.player.Player;
2728
import net.minecraft.world.level.biome.Biome;
29+
import net.minecraft.world.level.biome.Biomes;
2830
import net.minecraftforge.api.distmarker.Dist;
2931
import net.minecraftforge.api.distmarker.OnlyIn;
3032
import org.orecruncher.dsurround.DynamicSurroundings;
@@ -125,7 +127,7 @@ static void initFromConfig(@Nonnull final List<BiomeConfig> cfg) {
125127

126128
@Nonnull
127129
public static BiomeInfo getPlayerBiome(@Nonnull final Player player, final boolean getTrue) {
128-
final Biome biome = player.getCommandSenderWorld().getBiome(new BlockPos(player.getX(), 0, player.getZ()));
130+
final Biome biome = player.getCommandSenderWorld().getBiome(new BlockPos(player.getX(), 0, player.getZ())).value();
129131
BiomeInfo info = BiomeUtil.getBiomeData(biome);
130132

131133
if (!getTrue) {
@@ -181,9 +183,10 @@ public void start() {
181183
BiomeUtil.setBiomeData(b, new BiomeInfo(handler));
182184
});
183185

184-
// Make sure the default biomes are set
185-
BiomeUtil.getBiomeData(Biomes.PLAINS);
186-
BiomeUtil.getBiomeData(Biomes.THE_VOID);
186+
Registry<Biome> biomeRegistry = RegistryAccess.BUILTIN.get().registryOrThrow(Registry.BIOME_REGISTRY);
187+
// Make sure the default biomes are set
188+
BiomeUtil.getBiomeData(biomeRegistry.get(Biomes.PLAINS));
189+
BiomeUtil.getBiomeData(biomeRegistry.get(Biomes.THE_VOID));
187190

188191
final Collection<IResourceAccessor> configs = ResourceUtils.findConfigs(DynamicSurroundings.MOD_ID, DynamicSurroundings.DATA_PATH, "biomes.json");
189192

@@ -203,8 +206,9 @@ public void log() {
203206
@Override
204207
public void stop() {
205208
ForgeUtils.getBiomes().forEach(b -> BiomeUtil.setBiomeData(b, null));
206-
BiomeUtil.setBiomeData(Biomes.PLAINS, null);
207-
BiomeUtil.setBiomeData(Biomes.THE_VOID, null);
209+
Registry<Biome> biomeRegistry = RegistryAccess.BUILTIN.get().registryOrThrow(Registry.BIOME_REGISTRY);
210+
BiomeUtil.setBiomeData(biomeRegistry.get(Biomes.PLAINS), null);
211+
BiomeUtil.setBiomeData(biomeRegistry.get(Biomes.THE_VOID), null);
208212
}
209213
}
210214

src/main/java/org/orecruncher/environs/library/BlockStateLibrary.java

+4-6
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121
import com.google.common.collect.ImmutableList;
2222
import com.google.gson.reflect.TypeToken;
2323
import net.minecraft.resources.ResourceLocation;
24-
import net.minecraft.tags.Tag;
2524
import net.minecraft.world.level.block.Block;
2625
import net.minecraft.world.level.block.Blocks;
2726
import net.minecraft.world.level.block.state.BlockState;
2827
import net.minecraftforge.api.distmarker.Dist;
2928
import net.minecraftforge.api.distmarker.OnlyIn;
29+
import net.minecraftforge.registries.tags.ITag;
3030
import org.apache.commons.lang3.StringUtils;
3131
import org.orecruncher.dsurround.DynamicSurroundings;
3232
import org.orecruncher.environs.Environs;
@@ -143,11 +143,9 @@ private static void register(@Nonnull final BlockConfig entry) {
143143
private static Collection<BlockStateMatcher> expand(@Nonnull final String blockName) {
144144
if (blockName.startsWith(TAG_SPECIFIER)) {
145145
final String tagName = blockName.substring(1);
146-
final Tag<Block> tag = TagUtils.getBlockTag(tagName);
147-
if (tag != null) {
148-
return tag.getValues().stream().map(BlockStateMatcher::create).filter(m -> !m.isEmpty()).collect(Collectors.toList());
149-
}
150-
LOGGER.debug("Unknown block tag '%s' in Block specification", tagName);
146+
final ITag<Block> tag = TagUtils.getBlockTag(tagName);
147+
148+
return tag.stream().map(BlockStateMatcher::create).filter(m -> !m.isEmpty()).collect(Collectors.toList());
151149
} else {
152150
final BlockStateMatcher matcher = BlockStateMatcher.create(blockName);
153151
if (!matcher.isEmpty()) {

src/main/java/org/orecruncher/environs/mixins/MixinDripParticleDripping.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
import javax.annotation.Nonnull;
2929

30-
@Mixin(targets = {"net.minecraft.client.particle.DripParticle$FallingLiquidParticle"})
30+
@Mixin(targets = {"net.minecraft.client.particle.DripParticle$FallAndLandParticle"})
3131
public class MixinDripParticleDripping {
3232

3333
@Inject(method = "postMoveUpdate", at = @At("HEAD"))

src/main/java/org/orecruncher/environs/scanner/CeilingCoverage.java

+7-4
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@
2121
import net.minecraft.core.BlockPos;
2222
import net.minecraft.core.Vec3i;
2323
import net.minecraft.tags.BlockTags;
24-
import net.minecraft.tags.Tag;
24+
import net.minecraft.tags.TagKey;
2525
import net.minecraft.world.level.Level;
2626
import net.minecraft.world.level.block.Block;
2727
import net.minecraft.world.level.block.state.BlockState;
2828
import net.minecraftforge.api.distmarker.Dist;
2929
import net.minecraftforge.api.distmarker.OnlyIn;
3030
import net.minecraftforge.common.Tags;
31+
import net.minecraftforge.registries.ForgeRegistries;
32+
import net.minecraftforge.registries.tags.ITagManager;
3133
import org.orecruncher.environs.handlers.CommonState;
3234
import org.orecruncher.environs.library.DimensionInfo;
3335
import org.orecruncher.environs.library.DimensionLibrary;
@@ -54,7 +56,7 @@ public final class CeilingCoverage {
5456
private static final float INSIDE_THRESHOLD = 1.0F - 65.0F / 176.0F;
5557
private static final Cell[] cells;
5658
private static final float TOTAL_POINTS;
57-
private static final ObjectArray<Tag<Block>> NON_CEILING = new ObjectArray<>();
59+
private static final ObjectArray<TagKey<Block>> NON_CEILING = new ObjectArray<>();
5860

5961
static {
6062

@@ -176,8 +178,9 @@ private boolean actsAsCeiling(@Nonnull final BlockState state) {
176178

177179
// Test the block tags in our NON_CEILING set to see if any match
178180
final Block block = state.getBlock();
179-
for (final Tag<Block> tag : NON_CEILING) {
180-
if (tag.contains(block))
181+
ITagManager<Block> blockTags = ForgeRegistries.BLOCKS.tags();
182+
for (final TagKey<Block> tagKey : NON_CEILING) {
183+
if (blockTags.getTag(tagKey).contains(block))
181184
return false;
182185
}
183186
return true;

0 commit comments

Comments
 (0)