Skip to content

Commit

Permalink
Updated to 1.21.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Adubbz committed Oct 29, 2024
1 parent 4ad93ae commit c3c228a
Show file tree
Hide file tree
Showing 29 changed files with 209 additions and 156 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// 1.21 2024-06-15T10:07:24.2355164 Item Models: sereneseasons
// 1.21.3 2024-10-29T11:57:32.3272904 Item Models: sereneseasons
8131cb872e089e4f0ac2bccf3d4d7a25d7d92ec7 assets/sereneseasons/models/item/calendar.json
cb387a39c39a0f4665c565e7218cd4426875246a assets/sereneseasons/models/item/calendar_00.json
c154671ec34c7931bc05c47db4f69f21a5e413c7 assets/sereneseasons/models/item/calendar_01.json
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// 1.21 2024-06-15T10:07:24.2345172 Block States: sereneseasons
// 1.21.3 2024-10-29T11:57:32.3262892 Block States: sereneseasons
edf060403d4f871caf88b27e91d713ee2be4ebc1 assets/sereneseasons/blockstates/season_sensor.json
2797b7f59442c019e778d4e72e49c819153d75b3 assets/sereneseasons/models/block/season_sensor_autumn.json
607600cb666bf37bc704c834d7d0ffc585b405d0 assets/sereneseasons/models/block/season_sensor_spring.json
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// 1.21 2024-06-15T10:07:24.2355164 Recipes
// 1.21.3 2024-10-29T11:57:32.3267901 SS Recipes
e072858e57ee517a9ad673759ea337523f1faf58 data/sereneseasons/advancement/recipes/redstone/season_sensor.json
a6e2e9061195651e5a5ebe536429b983725e47a8 data/sereneseasons/advancement/recipes/tools/calendar.json
6dcfb1f16a07426dedd4bb0c22cf7e8875aaa637 data/sereneseasons/recipe/calendar.json
3a8122eb3cd03dfa946e5daabcc7c0a9813346e2 data/sereneseasons/recipe/season_sensor.json
8baddb9771f6e76a935fa1bf988623c65578b91f data/sereneseasons/recipe/calendar.json
1e0108f730fc7055f414ae4274b89cda22b7a722 data/sereneseasons/recipe/season_sensor.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@
"type": "minecraft:crafting_shaped",
"category": "equipment",
"key": {
"C": {
"item": "minecraft:clock"
},
"P": {
"item": "minecraft:paper"
}
"C": "minecraft:clock",
"P": "minecraft:paper"
},
"pattern": [
"PPP",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,10 @@
"type": "minecraft:crafting_shaped",
"category": "redstone",
"key": {
"#": {
"item": "minecraft:cobblestone_slab"
},
"C": {
"item": "sereneseasons:calendar"
},
"G": {
"item": "minecraft:glass"
},
"Q": {
"item": "minecraft:quartz"
}
"#": "minecraft:cobblestone_slab",
"C": "sereneseasons:calendar",
"G": "minecraft:glass",
"Q": "minecraft:quartz"
},
"pattern": [
"GGG",
Expand Down
8 changes: 5 additions & 3 deletions common/src/main/java/sereneseasons/init/ModBlockEntities.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.minecraft.Util;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.datafix.fixes.References;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import sereneseasons.api.SSBlockEntities;
Expand All @@ -15,18 +16,19 @@
import sereneseasons.core.SereneSeasons;

import java.util.List;
import java.util.Set;
import java.util.function.BiConsumer;

public class ModBlockEntities
{
public static void registerBlockEntities(BiConsumer<ResourceLocation, BlockEntityType<?>> func)
{
SSBlockEntities.SEASON_SENSOR = register(func, "season_sensor", BlockEntityType.Builder.of(SeasonSensorBlockEntity::new, SSBlocks.SEASON_SENSOR));
SSBlockEntities.SEASON_SENSOR = register(func, "season_sensor", SeasonSensorBlockEntity::new, Set.of(SSBlocks.SEASON_SENSOR));
}

private static <T extends BlockEntity> BlockEntityType<?> register(BiConsumer<ResourceLocation, BlockEntityType<?>> func, String name, BlockEntityType.Builder<T> builder)
private static <T extends BlockEntity> BlockEntityType<?> register(BiConsumer<ResourceLocation, BlockEntityType<?>> func, String name, BlockEntityType.BlockEntitySupplier<T> supplier, Set<Block> blocks)
{
var type = builder.build(Util.fetchChoiceType(References.BLOCK_ENTITY, name));
var type = new BlockEntityType(supplier, blocks);
func.accept(ResourceLocation.fromNamespaceAndPath(SereneSeasons.MOD_ID, name), type);
return type;
}
Expand Down
21 changes: 18 additions & 3 deletions common/src/main/java/sereneseasons/init/ModBlocks.java
Original file line number Diff line number Diff line change
@@ -1,24 +1,39 @@
package sereneseasons.init;

import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockBehaviour;
import sereneseasons.api.SSBlocks;
import sereneseasons.block.SeasonSensorBlock;
import sereneseasons.core.SereneSeasons;

import java.util.function.BiConsumer;
import java.util.function.Function;

public class ModBlocks
{
public static void registerBlocks(BiConsumer<ResourceLocation, Block> func)
{
SSBlocks.SEASON_SENSOR = register(func, new SeasonSensorBlock(Block.Properties.of().strength(0.2F).sound(SoundType.STONE)), "season_sensor");
SSBlocks.SEASON_SENSOR = register(func, "season_sensor", SeasonSensorBlock::new, Block.Properties.of().strength(0.2F).sound(SoundType.STONE));
}

private static Block register(BiConsumer<ResourceLocation, Block> func, Block block, String name)
private static Block register(BiConsumer<ResourceLocation, Block> func, ResourceKey<Block> key, Function<BlockBehaviour.Properties, Block> factory, BlockBehaviour.Properties properties)
{
func.accept(ResourceLocation.fromNamespaceAndPath(SereneSeasons.MOD_ID, name), block);
Block block = factory.apply(properties.setId(key));
func.accept(key.location(), block);
return block;
}

private static Block register(BiConsumer<ResourceLocation, Block> func, String name, Function<BlockBehaviour.Properties, Block> factory, BlockBehaviour.Properties properties)
{
return register(func, blockId(name), factory, properties);
}

private static ResourceKey<Block> blockId(String name)
{
return ResourceKey.create(Registries.BLOCK, ResourceLocation.fromNamespaceAndPath(SereneSeasons.MOD_ID, name));
}
}
6 changes: 3 additions & 3 deletions common/src/main/java/sereneseasons/init/ModFertility.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ else if (!ModConfig.fertility.seasonalCrops || biome.is(ModTags.Biomes.BLACKLIST
}
else
{
if (!biome.value().warmEnoughToRain(pos))
if (!biome.value().warmEnoughToRain(pos, level.getSeaLevel()))
{
if (winterPlants.contains(cropName))
{
Expand Down Expand Up @@ -139,7 +139,7 @@ else if (season == Season.WINTER && winterPlants.contains(cropName))

private static void populateSeasonCrops(TagKey<Block> tag, Set<String> cropSet, int bitmask)
{
BuiltInRegistries.BLOCK.getTag(tag).ifPresent(blocks ->
BuiltInRegistries.BLOCK.get(tag).ifPresent(blocks ->
{
for (Holder<Block> block : blocks)
{
Expand Down Expand Up @@ -176,7 +176,7 @@ private static void populateSeasonCrops(TagKey<Block> tag, Set<String> cropSet,

private static void populateSeasonSeeds(TagKey<Item> tag, Set<String> cropSet, int bitmask)
{
BuiltInRegistries.ITEM.getTag(tag).ifPresent(items ->
BuiltInRegistries.ITEM.get(tag).ifPresent(items ->
{
for (Holder<Item> item : items)
{
Expand Down
52 changes: 47 additions & 5 deletions common/src/main/java/sereneseasons/init/ModItems.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
package sereneseasons.init;

import glitchcore.util.Environment;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
import sereneseasons.api.SSBlocks;
import sereneseasons.api.SSItems;
import sereneseasons.core.SereneSeasons;
import sereneseasons.item.CalendarItem;

import java.util.function.BiConsumer;
import java.util.function.BiFunction;
import java.util.function.Function;

import static sereneseasons.api.SSItems.*;

Expand All @@ -29,20 +34,57 @@ public static void setup(BiConsumer<ResourceLocation, Item> func)
public static void registerItems(BiConsumer<ResourceLocation, Item> func)
{
// SS Creative Tab Icon
SSItems.SS_ICON = register(func, "ss_icon", new Item(new Item.Properties()));
SSItems.SS_ICON = registerItem(func, "ss_icon", new Item.Properties());

// Main Items
SSItems.CALENDAR = register(func, "calendar", new CalendarItem(new Item.Properties().stacksTo(1)));
SSItems.CALENDAR = registerItem(func, "calendar", CalendarItem::new, new Item.Properties().stacksTo(1));
}

public static void registerBlockItems(BiConsumer<ResourceLocation, Item> func)
{
SEASON_SENSOR = register(func, "season_sensor", new BlockItem(SSBlocks.SEASON_SENSOR, new Item.Properties()));
SEASON_SENSOR = registerBlock(func, SSBlocks.SEASON_SENSOR);
}

private static Item register(BiConsumer<ResourceLocation, Item> func, String name, Item item)
public static Item registerBlock(BiConsumer<ResourceLocation, Item> func, Block block)
{
func.accept(ResourceLocation.fromNamespaceAndPath(SereneSeasons.MOD_ID, name), item);
return registerBlock(func, block, BlockItem::new);
}

public static Item registerBlock(BiConsumer<ResourceLocation, Item> func, Block block, BiFunction<Block, Item.Properties, Item> factory)
{
return registerBlock(func, block, factory, new Item.Properties());
}

public static Item registerBlock(BiConsumer<ResourceLocation, Item> func, Block block, BiFunction<Block, Item.Properties, Item> factory, Item.Properties properties)
{
return registerItem(func, blockIdToItemId(block.builtInRegistryHolder().key()), p_370785_ -> factory.apply(block, p_370785_), properties.useBlockDescriptionPrefix()
);
}

private static Item registerItem(BiConsumer<ResourceLocation, Item> func, ResourceKey<Item> key, Function<Item.Properties, Item> factory, Item.Properties properties)
{
Item item = factory.apply(properties.setId(key));
func.accept(key.location(), item);
return item;
}

private static Item registerItem(BiConsumer<ResourceLocation, Item> func, String name, Function<Item.Properties, Item> factory, Item.Properties properties)
{
return registerItem(func, itemId(name), factory, properties);
}

private static Item registerItem(BiConsumer<ResourceLocation, Item> func, String name, Item.Properties properties)
{
return registerItem(func, itemId(name), Item::new, properties);
}

private static ResourceKey<Item> blockIdToItemId(ResourceKey<Block> key)
{
return ResourceKey.create(Registries.ITEM, key.location());
}

private static ResourceKey<Item> itemId(String name)
{
return ResourceKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath(SereneSeasons.MOD_ID, name));
}
}
8 changes: 4 additions & 4 deletions common/src/main/java/sereneseasons/mixin/MixinBiome.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ public class MixinBiome
@Inject(method="shouldSnow", at=@At("HEAD"), cancellable = true)
public void onShouldSnow(LevelReader level, BlockPos pos, CallbackInfoReturnable<Boolean> cir)
{
cir.setReturnValue(SeasonHooks.shouldSnowHook((Biome)(Object)this, level, pos));
cir.setReturnValue(SeasonHooks.shouldSnowHook((Biome)(Object)this, level, pos, level.getSeaLevel()));
}

@Redirect(method = "shouldFreeze(Lnet/minecraft/world/level/LevelReader;Lnet/minecraft/core/BlockPos;Z)Z", at=@At(value = "INVOKE", target = "net/minecraft/world/level/biome/Biome.warmEnoughToRain(Lnet/minecraft/core/BlockPos;)Z"))
public boolean onShouldFreeze_warmEnoughToRain(Biome biome, BlockPos pos, LevelReader level)
@Redirect(method = "shouldFreeze(Lnet/minecraft/world/level/LevelReader;Lnet/minecraft/core/BlockPos;Z)Z", at=@At(value = "INVOKE", target = "net/minecraft/world/level/biome/Biome.warmEnoughToRain(Lnet/minecraft/core/BlockPos;I)Z"))
public boolean onShouldFreeze_warmEnoughToRain(Biome biome, BlockPos pos, int seaLevel, LevelReader level)
{
return SeasonHooks.shouldFreezeWarmEnoughToRainHook(biome, pos, level);
return SeasonHooks.shouldFreezeWarmEnoughToRainHook(biome, pos, seaLevel, level);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
@Mixin(ServerLevel.class)
public class MixinServerLevel
{
@Redirect(method="tickPrecipitation", at=@At(value = "INVOKE", target = "Lnet/minecraft/world/level/biome/Biome;getPrecipitationAt(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/biome/Biome$Precipitation;"))
public Biome.Precipitation tickIceAndSnow_getPrecipitationAt(Biome biome, BlockPos pos)
@Redirect(method="tickPrecipitation", at=@At(value = "INVOKE", target = "Lnet/minecraft/world/level/biome/Biome;getPrecipitationAt(Lnet/minecraft/core/BlockPos;I)Lnet/minecraft/world/level/biome/Biome$Precipitation;"))
public Biome.Precipitation tickIceAndSnow_getPrecipitationAt(Biome biome, BlockPos pos, int seaLevel)
{
return SeasonHooks.getPrecipitationAtTickIceAndSnowHook((LevelReader)this, biome, pos);
return SeasonHooks.getPrecipitationAtTickIceAndSnowHook((LevelReader)this, biome, pos, seaLevel);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
public class MixinBiomeClient
{
@Inject(method="getPrecipitationAt", at=@At("HEAD"), cancellable = true)
public void onGetPrecipitationAt(BlockPos pos, CallbackInfoReturnable<Biome.Precipitation> cir)
public void onGetPrecipitationAt(BlockPos pos, int seaLevel, CallbackInfoReturnable<Biome.Precipitation> cir)
{
Minecraft minecraft = Minecraft.getInstance();
Level level = minecraft.level;

if (level != null)
{
cir.setReturnValue(SeasonHooks.getPrecipitationAtSeasonal(level, level.getBiome(pos), pos));
cir.setReturnValue(SeasonHooks.getPrecipitationAtSeasonal(level, level.getBiome(pos), pos, seaLevel));
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*******************************************************************************
* Copyright 2022, the Glitchfiend Team.
* All rights reserved.
******************************************************************************/
package sereneseasons.mixin.client;

import net.minecraft.client.renderer.WeatherEffectRenderer;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.biome.Biome;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import sereneseasons.core.SereneSeasons;
import sereneseasons.season.SeasonHooks;

@Mixin(WeatherEffectRenderer.class)
public class MixinWeatherEffectRenderer
{
@Inject(method="getPrecipitationAt", at=@At(value = "HEAD"), cancellable = true)
public void onGetPrecipitationAt(Level level, BlockPos pos, CallbackInfoReturnable<Biome.Precipitation> cir)
{
cir.setReturnValue(SeasonHooks.getPrecipitationAtSeasonal(level, level.getBiome(pos), pos, level.getSeaLevel()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,15 @@ private static void meltInChunk(ChunkMap chunkMap, LevelChunk chunkIn, float mel
Holder<Biome> biome = world.getBiome(topAirPos);
Holder<Biome> groundBiome = world.getBiome(topGroundPos);

if (!biome.is(ModTags.Biomes.BLACKLISTED_BIOMES) && SeasonHooks.getBiomeTemperature(world, biome, topGroundPos) >= 0.15F)
if (!biome.is(ModTags.Biomes.BLACKLISTED_BIOMES) && SeasonHooks.getBiomeTemperature(world, biome, topGroundPos, world.getSeaLevel()) >= 0.15F)
{
if (aboveGroundState.getBlock() == Blocks.SNOW)
{
world.setBlockAndUpdate(topAirPos, Blocks.AIR.defaultBlockState());
}
}

if (!groundBiome.is(ModTags.Biomes.BLACKLISTED_BIOMES) && SeasonHooks.getBiomeTemperature(world, groundBiome, topGroundPos) >= 0.15F)
if (!groundBiome.is(ModTags.Biomes.BLACKLISTED_BIOMES) && SeasonHooks.getBiomeTemperature(world, groundBiome, topGroundPos, world.getSeaLevel()) >= 0.15F)
{
if (groundState.getBlock() == Blocks.ICE)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import javax.annotation.Nullable;
import java.util.List;
import java.util.Optional;

public class SeasonColorHandlers
{
Expand Down Expand Up @@ -64,8 +65,8 @@ private static int resolveColors(ResolverType type, Biome biome, double x, doubl

if (level == null) return originalColor;

Registry<Biome> biomeRegistry = level.registryAccess().registryOrThrow(Registries.BIOME);
Holder<Biome> biomeHolder = biomeRegistry.getResourceKey(biome).flatMap(biomeRegistry::getHolder).orElse(null);
Registry<Biome> biomeRegistry = level.registryAccess().lookupOrThrow(Registries.BIOME);
Holder.Reference<Biome> biomeHolder = biomeRegistry.getResourceKey(biome).flatMap(biomeRegistry::get).orElse(null);

if (biomeHolder != null)
{
Expand Down
Loading

0 comments on commit c3c228a

Please sign in to comment.