diff --git a/gradle.properties b/gradle.properties index bf4f011..0dc8137 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,7 +9,7 @@ modrinth_version=2.7.3 github_api_version=1.314 # Mod Properties -mod_version=2.0+1.19 +mod_version=2.0.2+1.19 maven_group=io.github.lucaargolo # Fabric Properties diff --git a/src/main/java/io/github/lucaargolo/seasons/OldSeasonsCompat.java b/src/main/java/io/github/lucaargolo/seasons/OldSeasonsCompat.java new file mode 100644 index 0000000..647bf60 --- /dev/null +++ b/src/main/java/io/github/lucaargolo/seasons/OldSeasonsCompat.java @@ -0,0 +1,17 @@ +package io.github.lucaargolo.seasons; + +import io.github.lucaargolo.seasons.block.SeasonalIceBlock; +import io.github.lucaargolo.seasons.block.SeasonalSnowBlock; +import io.github.lucaargolo.seasons.utils.ModIdentifier; +import net.fabricmc.api.ModInitializer; +import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; +import net.minecraft.block.Blocks; +import net.minecraft.util.registry.Registry; + +public class OldSeasonsCompat implements ModInitializer { + @Override + public void onInitialize() { + Registry.register(Registry.BLOCK, new ModIdentifier("seasonal_ice"), new SeasonalIceBlock(FabricBlockSettings.copyOf(Blocks.ICE))); + Registry.register(Registry.BLOCK, new ModIdentifier("seasonal_snow"), new SeasonalSnowBlock(FabricBlockSettings.copyOf(Blocks.SNOW))); + } +} diff --git a/src/main/java/io/github/lucaargolo/seasons/block/SeasonalIceBlock.java b/src/main/java/io/github/lucaargolo/seasons/block/SeasonalIceBlock.java new file mode 100644 index 0000000..9da556b --- /dev/null +++ b/src/main/java/io/github/lucaargolo/seasons/block/SeasonalIceBlock.java @@ -0,0 +1,37 @@ +package io.github.lucaargolo.seasons.block; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.block.IceBlock; +import net.minecraft.item.Item; +import net.minecraft.server.world.ServerWorld; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.random.Random; + +public class SeasonalIceBlock extends IceBlock { + + public SeasonalIceBlock(Settings settings) { + super(settings); + } + + @Override + public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { + world.setBlockState(pos, Blocks.ICE.getStateWithProperties(state)); + } + + @Override + public String getTranslationKey() { + return Blocks.ICE.getTranslationKey(); + } + + @Override + protected Block asBlock() { + return Blocks.ICE; + } + + @Override + public Item asItem() { + return Blocks.ICE.asItem(); + } +} \ No newline at end of file diff --git a/src/main/java/io/github/lucaargolo/seasons/block/SeasonalSnowBlock.java b/src/main/java/io/github/lucaargolo/seasons/block/SeasonalSnowBlock.java new file mode 100644 index 0000000..46f9525 --- /dev/null +++ b/src/main/java/io/github/lucaargolo/seasons/block/SeasonalSnowBlock.java @@ -0,0 +1,37 @@ +package io.github.lucaargolo.seasons.block; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.block.SnowBlock; +import net.minecraft.item.Item; +import net.minecraft.server.world.ServerWorld; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.random.Random; + +public class SeasonalSnowBlock extends SnowBlock { + + public SeasonalSnowBlock(Settings settings) { + super(settings); + } + + @Override + public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) { + world.setBlockState(pos, Blocks.SNOW.getStateWithProperties(state)); + } + + @Override + public String getTranslationKey() { + return Blocks.SNOW.getTranslationKey(); + } + + @Override + protected Block asBlock() { + return Blocks.SNOW; + } + + @Override + public Item asItem() { + return Blocks.SNOW.asItem(); + } +} \ No newline at end of file diff --git a/src/main/java/io/github/lucaargolo/seasons/utils/CompatWarnState.java b/src/main/java/io/github/lucaargolo/seasons/utils/CompatWarnState.java index ba48077..9dca566 100644 --- a/src/main/java/io/github/lucaargolo/seasons/utils/CompatWarnState.java +++ b/src/main/java/io/github/lucaargolo/seasons/utils/CompatWarnState.java @@ -52,8 +52,10 @@ private void saveState() { NbtList list = new NbtList(); warnedIds.forEach(s -> list.add(NbtString.of(s))); nbt.put("list", list); - File compatWarnFile = new File(MinecraftClient.getInstance().runDirectory, File.separator+"data"+File.separator+"seasons_compat_warn.nbt"); + File compatWarnFile = new File(MinecraftClient.getInstance().runDirectory, File.separator+"data"+File.separator+"seasons_compat_warn.dat"); try { + Boolean ignored = compatWarnFile.getParentFile().mkdirs(); + Boolean ignored2 = compatWarnFile.createNewFile(); NbtIo.writeCompressed(nbt, compatWarnFile); } catch (IOException e) { FabricSeasons.LOGGER.error("["+MOD_NAME+"] Failed to save season url warn state.", e); @@ -62,7 +64,7 @@ private void saveState() { public static CompatWarnState getState(MinecraftClient client) { CompatWarnState state = new CompatWarnState(client); - File compatWarnFile = new File(MinecraftClient.getInstance().runDirectory, File.separator+"data"+File.separator+"seasons_compat_warn.nbt"); + File compatWarnFile = new File(MinecraftClient.getInstance().runDirectory, File.separator+"data"+File.separator+"seasons_compat_warn.dat"); NbtCompound nbt; try { nbt = NbtIo.readCompressed(compatWarnFile); diff --git a/src/main/resources/assets/seasons/blockstates/seasonal_ice.json b/src/main/resources/assets/seasons/blockstates/seasonal_ice.json new file mode 100644 index 0000000..0617dfc --- /dev/null +++ b/src/main/resources/assets/seasons/blockstates/seasonal_ice.json @@ -0,0 +1,7 @@ +{ + "variants": { + "": { + "model": "minecraft:block/ice" + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/seasons/blockstates/seasonal_snow.json b/src/main/resources/assets/seasons/blockstates/seasonal_snow.json new file mode 100644 index 0000000..a82cad9 --- /dev/null +++ b/src/main/resources/assets/seasons/blockstates/seasonal_snow.json @@ -0,0 +1,28 @@ +{ + "variants": { + "layers=1": { + "model": "minecraft:block/snow_height2" + }, + "layers=2": { + "model": "minecraft:block/snow_height4" + }, + "layers=3": { + "model": "minecraft:block/snow_height6" + }, + "layers=4": { + "model": "minecraft:block/snow_height8" + }, + "layers=5": { + "model": "minecraft:block/snow_height10" + }, + "layers=6": { + "model": "minecraft:block/snow_height12" + }, + "layers=7": { + "model": "minecraft:block/snow_height14" + }, + "layers=8": { + "model": "minecraft:block/snow_block" + } + } +} \ No newline at end of file diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index fe75f8b..b25199e 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -20,7 +20,8 @@ "environment": "*", "entrypoints": { "main": [ - "io.github.lucaargolo.seasons.FabricSeasons" + "io.github.lucaargolo.seasons.FabricSeasons", + "io.github.lucaargolo.seasons.OldSeasonsCompat" ], "client": [ "io.github.lucaargolo.seasons.FabricSeasonsClient"