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 #109, Fix #107 #119

Closed
wants to merge 5 commits into from
Closed
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
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/io/github/lucaargolo/seasons/OldSeasonsCompat.java
Original file line number Diff line number Diff line change
@@ -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)));
}
}
Original file line number Diff line number Diff line change
@@ -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();
}
}
Original file line number Diff line number Diff line change
@@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"variants": {
"": {
"model": "minecraft:block/ice"
}
}
}
28 changes: 28 additions & 0 deletions src/main/resources/assets/seasons/blockstates/seasonal_snow.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
3 changes: 2 additions & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down