Skip to content

Commit 3ce244c

Browse files
committed
Address deprecation warnings
1 parent 656ca90 commit 3ce244c

File tree

8 files changed

+45
-47
lines changed

8 files changed

+45
-47
lines changed

build.gradle

Lines changed: 8 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
buildscript {
22
repositories {
3-
// These repositories are only for Gradle plugins, put any other repositories in the repository block further below
43
maven { url = 'https://maven.minecraftforge.net' }
54
maven { url = 'https://maven.parchmentmc.org' }
65
mavenCentral()
@@ -12,36 +11,20 @@ buildscript {
1211
}
1312
apply plugin: 'net.minecraftforge.gradle'
1413
apply plugin: 'org.parchmentmc.librarian.forgegradle'
15-
// Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
1614
apply plugin: 'eclipse'
1715
apply plugin: 'maven-publish'
1816

19-
version = '0.9.1-beta'
20-
group = 'glowredman.modularmaterials' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
17+
version = '0.9.2-beta'
18+
group = 'glowredman.modularmaterials'
2119
archivesBaseName = 'modularmaterials'
2220

23-
// Mojang ships Java 16 to end users in 1.17+ instead of Java 8 in 1.16 or lower, so your mod should target Java 16.
2421
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
2522

2623
println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))
2724
minecraft {
28-
// The mappings can be changed at any time and must be in the following format.
29-
// Channel: Version:
30-
// snapshot YYYYMMDD Snapshot are built nightly.
31-
// stable # Stables are built at the discretion of the MCP team.
32-
// official MCVersion Official field/method names from Mojang mapping files
33-
//
34-
// You must be aware of the Mojang license when using the 'official' mappings.
35-
// See more information here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md
36-
//
37-
// Use non-default mappings at your own risk. They may not always work.
38-
// Simply re-run your setup task after changing the mappings to update your workspace.
39-
mappings channel: 'parchment', version: '1.18.1-2022.03.06-1.18.2'
40-
41-
// accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') // Currently, this location cannot be changed from the default.
42-
43-
// Default run configurations.
44-
// These can be tweaked, removed, or duplicated as needed.
25+
mappings channel: 'parchment', version: '2022.05.02-1.18.2'
26+
accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') // Currently, this location cannot be changed from the default.
27+
4528
runs {
4629
client {
4730
workingDirectory project.file('run')
@@ -114,24 +97,12 @@ minecraft {
11497
}
11598
}
11699

117-
// Include resources generated by data generators.
118100
sourceSets.main.resources { srcDir 'src/generated/resources' }
119101

120-
repositories {
121-
// Put repositories for dependencies here
122-
// ForgeGradle automatically adds the Forge maven and Maven Central for you
123-
124-
// If you have mod jar dependencies in ./libs, you can declare them as a repository like so:
125-
// flatDir {
126-
// dir 'libs'
127-
// }
128-
}
102+
repositories {}
129103

130104
dependencies {
131-
// Specify the version of Minecraft to use. If this is any group other than 'net.minecraft', it is assumed
132-
// that the dep is a ForgeGradle 'patcher' dependency, and its patches will be applied.
133-
// The userdev artifact is a special name and will get all sorts of transformations applied to it.
134-
minecraft 'net.minecraftforge:forge:1.18.2-40.0.12'
105+
minecraft 'net.minecraftforge:forge:1.18.2-40.1.16'
135106

136107
// Real mod deobf dependency examples - these get remapped to your current mappings
137108
// compileOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}:api") // Adds JEI API as a compile dependency
@@ -146,13 +117,12 @@ dependencies {
146117
// http://www.gradle.org/docs/current/userguide/dependency_management.html
147118
}
148119

149-
// Example for how to get properties into the manifest for reading at runtime.
150120
jar {
151121
manifest {
152122
attributes([
153123
"Specification-Title" : "modularmaterials",
154124
"Specification-Vendor" : "glowredman",
155-
"Specification-Version" : "1", // We are version 1 of ourselves
125+
"Specification-Version" : "2",
156126
"Implementation-Title" : project.name,
157127
"Implementation-Version" : project.jar.archiveVersion,
158128
"Implementation-Vendor" : "glowredman",

src/main/java/glowredman/modularmaterials/MM_Commands.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import glowredman.modularmaterials.data.PresetHandler;
1616
import glowredman.modularmaterials.data.legacy.LegacyHandler;
17+
import glowredman.modularmaterials.util.TagHelper;
1718
import net.minecraft.ChatFormatting;
1819
import net.minecraft.commands.CommandSourceStack;
1920
import net.minecraft.commands.Commands;
@@ -41,6 +42,7 @@
4142
import net.minecraftforge.event.RegisterCommandsEvent;
4243
import net.minecraftforge.eventbus.api.SubscribeEvent;
4344
import net.minecraftforge.fluids.FluidAttributes;
45+
import net.minecraftforge.registries.ForgeRegistries;
4446

4547
public class MM_Commands {
4648

@@ -99,12 +101,12 @@ private static int getInfo(CommandSourceStack commandSourceStack, BlockPos pos)
99101
BlockState blockstate = level.getBlockState(pos);
100102
Block block = blockstate.getBlock();
101103
String blockRegName = block.getRegistryName().toString();
102-
List<TagKey<Block>> blockTags = block.builtInRegistryHolder().tags().toList();
104+
List<TagKey<Block>> blockTags = TagHelper.getTags(ForgeRegistries.BLOCKS, block);
103105

104106
FluidState fluidstate = level.getFluidState(pos);
105107
Fluid fluid = fluidstate.getType();
106108
String fluidRegName = fluid.getRegistryName().toString();
107-
List<TagKey<Fluid>> fluidTags = fluid.builtInRegistryHolder().tags().toList();
109+
List<TagKey<Fluid>> fluidTags = TagHelper.getTags(ForgeRegistries.FLUIDS, fluid);
108110
FluidAttributes fluidAttributes = fluid.getAttributes();
109111

110112
commandSourceStack.sendSuccess(new TextComponent("Information for ").withStyle(ChatFormatting.GOLD)
@@ -117,7 +119,7 @@ private static int getInfo(CommandSourceStack commandSourceStack, BlockPos pos)
117119
.append(copyable(biome.value().getRegistryName().toString())), false);
118120

119121
commandSourceStack.sendSuccess(new TextComponent("Biome Category: ").withStyle(ChatFormatting.BLUE)
120-
.append(copyable(Biome.getBiomeCategory(biome).getName())), false);
122+
.append(copyable(biome.value().getBiomeCategory().getName())), false);
121123

122124
commandSourceStack.sendSuccess(new TextComponent("Dimension: ").withStyle(ChatFormatting.BLUE)
123125
.append(copyable(level.dimension().location().toString())), false);

src/main/java/glowredman/modularmaterials/block/BlockHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ public void registerBlocks(Register<Block> event) {
5757
String materialName = eMaterial.getKey();
5858
MM_Material material = eMaterial.getValue();
5959
if((material.enabled && material.enabledTypes.contains(typeName)) || MM_Reference.CONFIG.enableAll) {
60-
RegistryObject<MetaFluid> fluidS = RegistryObject.of(new ResourceLocation(MM_Reference.MODID, typeName + "." + materialName), ForgeRegistries.FLUIDS);
61-
RegistryObject<MetaFluid> fluidF = RegistryObject.of(new ResourceLocation(MM_Reference.MODID, "flowing_" + typeName + "." + materialName), ForgeRegistries.FLUIDS);
60+
RegistryObject<MetaFluid> fluidS = RegistryObject.create(new ResourceLocation(MM_Reference.MODID, typeName + "." + materialName), ForgeRegistries.FLUIDS);
61+
RegistryObject<MetaFluid> fluidF = RegistryObject.create(new ResourceLocation(MM_Reference.MODID, "flowing_" + typeName + "." + materialName), ForgeRegistries.FLUIDS);
6262

6363
FluidAttributes.Builder b = FluidAttributes.builder(
6464
new ResourceLocation(MM_Reference.MODID, "fluids/" + material.texture + "/" + typeName + "_still"),

src/main/java/glowredman/modularmaterials/block/MetaFluidBlock.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import glowredman.modularmaterials.data.object.MM_Material;
77
import glowredman.modularmaterials.data.object.MM_Type;
88
import glowredman.modularmaterials.fluid.MetaFluid;
9+
import glowredman.modularmaterials.util.TagHelper;
910
import net.minecraft.core.BlockPos;
1011
import net.minecraft.core.Direction;
1112
import net.minecraft.sounds.SoundEvent;
@@ -24,6 +25,7 @@
2425
import net.minecraft.world.phys.shapes.Shapes;
2526
import net.minecraft.world.phys.shapes.VoxelShape;
2627
import net.minecraftforge.event.ForgeEventFactory;
28+
import net.minecraftforge.registries.ForgeRegistries;
2729

2830
public class MetaFluidBlock extends LiquidBlock {
2931

@@ -95,7 +97,7 @@ public void neighborChanged(BlockState pState, Level pLevel, BlockPos pPos, Bloc
9597
}
9698

9799
private boolean shouldSpreadLiquid(Level pLevel, BlockPos pPos, BlockState pState) {
98-
if (this.getFluid().is(FluidTags.LAVA)) {
100+
if (TagHelper.hasTag(ForgeRegistries.FLUIDS, this.getFluid(), FluidTags.LAVA)) {
99101
boolean flag = pLevel.getBlockState(pPos.below()).is(Blocks.SOUL_SOIL);
100102

101103
for (Direction direction : POSSIBLE_FLOW_DIRECTIONS) {

src/main/java/glowredman/modularmaterials/item/MetaBucketItem.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import glowredman.modularmaterials.MM_Reference;
88
import glowredman.modularmaterials.data.object.MM_Material;
99
import glowredman.modularmaterials.fluid.MetaFluid;
10+
import glowredman.modularmaterials.util.TagHelper;
1011
import net.minecraft.advancements.CriteriaTriggers;
1112
import net.minecraft.core.BlockPos;
1213
import net.minecraft.core.Direction;
@@ -44,6 +45,7 @@
4445
import net.minecraftforge.common.capabilities.ICapabilityProvider;
4546
import net.minecraftforge.event.ForgeEventFactory;
4647
import net.minecraftforge.fluids.capability.wrappers.FluidBucketWrapper;
48+
import net.minecraftforge.registries.ForgeRegistries;
4749

4850
public class MetaBucketItem extends BucketItem {
4951

@@ -176,7 +178,7 @@ public boolean emptyContents(Player pPlayer, Level pLevel, BlockPos pPos, BlockH
176178
boolean flag1 = blockstate.isAir() || flag || block instanceof LiquidBlockContainer && ((LiquidBlockContainer) block).canPlaceLiquid(pLevel, pPos, blockstate, this.getFluid());
177179
if (!flag1) {
178180
return pResult != null && this.emptyContents(pPlayer, pLevel, pResult.getBlockPos().relative(pResult.getDirection()), (BlockHitResult) null);
179-
} else if (pLevel.dimensionType().ultraWarm() && this.getFluid().is(FluidTags.WATER)) {
181+
} else if (pLevel.dimensionType().ultraWarm() && TagHelper.hasTag(ForgeRegistries.FLUIDS, this.getFluid(), FluidTags.WATER)) {
180182
int i = pPos.getX();
181183
int j = pPos.getY();
182184
int k = pPos.getZ();
@@ -208,7 +210,7 @@ public boolean emptyContents(Player pPlayer, Level pLevel, BlockPos pPos, BlockH
208210
@Override
209211
protected void playEmptySound(Player pPlayer, LevelAccessor pLevel, BlockPos pPos) {
210212
SoundEvent soundevent = this.getFluid().getAttributes().getEmptySound();
211-
if (soundevent == null) soundevent = this.getFluid().is(FluidTags.LAVA) ? SoundEvents.BUCKET_EMPTY_LAVA : SoundEvents.BUCKET_EMPTY;
213+
if (soundevent == null) soundevent = TagHelper.hasTag(ForgeRegistries.FLUIDS, this.getFluid(), FluidTags.LAVA) ? SoundEvents.BUCKET_EMPTY_LAVA : SoundEvents.BUCKET_EMPTY;
212214
pLevel.playSound(pPlayer, pPos, soundevent, SoundSource.BLOCKS, 1.0F, 1.0F);
213215
pLevel.gameEvent(pPlayer, GameEvent.FLUID_PLACE, pPos);
214216
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package glowredman.modularmaterials.util;
2+
3+
import java.util.List;
4+
import java.util.stream.Stream;
5+
6+
import net.minecraft.tags.TagKey;
7+
import net.minecraftforge.registries.IForgeRegistry;
8+
import net.minecraftforge.registries.IForgeRegistryEntry;
9+
import net.minecraftforge.registries.tags.IReverseTag;
10+
11+
public class TagHelper {
12+
13+
public static <T extends IForgeRegistryEntry<T>> List<TagKey<T>> getTags(IForgeRegistry<T> registry, T object) {
14+
return registry.tags().getReverseTag(object).map(IReverseTag::getTagKeys).orElseGet(Stream::of).toList();
15+
}
16+
17+
public static <T extends IForgeRegistryEntry<T>> boolean hasTag(IForgeRegistry<T> registry, T object, TagKey<T> tag) {
18+
return registry.tags().getTag(tag).contains(object);
19+
}
20+
21+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
public net.minecraft.world.level.biome.Biome m_47567_()Lnet/minecraft/world/level/biome/Biome$BiomeCategory; # getBiomeCategory

src/main/resources/META-INF/mods.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ description='''Dynamic and fully customizeable material-generation-system for Mi
4141
# Does this dependency have to exist - if not, ordering below must be specified
4242
mandatory=true #mandatory
4343
# The version range of the dependency
44-
versionRange="[40.0.0,)" #mandatory
44+
versionRange="[40.0.18,)" #mandatory
4545
# An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory
4646
ordering="NONE"
4747
# Side this dependency is applied on - BOTH, CLIENT or SERVER

0 commit comments

Comments
 (0)