Skip to content

Commit

Permalink
extra fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
PinkGoosik committed Jan 11, 2023
1 parent dc5e9fb commit 3dcaebc
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
13 changes: 8 additions & 5 deletions src/main/java/winterly/block/FrozenFlowerBlock.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package winterly.block;

import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
Expand Down Expand Up @@ -127,11 +128,13 @@ public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random
world.setBlockState(pos, Objects.requireNonNullElse(cachedFlower, this).getDefaultState());
}
}
else if(!state.get(PERSISTENT) && world.getLightLevel(LightType.SKY, pos) > 0 && world.getBiome(pos).value().getTemperature(pos) >= 0.15F) {
dropStacks(state, world, pos);
if(state.get(LAYERS) != 0) {
var cachedFlower = CachedFlowers.getFlower(world.getRegistryKey(), pos);
world.setBlockState(pos, Objects.requireNonNullElse(cachedFlower, this).getDefaultState());
else if(FabricLoader.getInstance().isModLoaded("seasons")) {
if(!state.get(PERSISTENT) && world.getLightLevel(LightType.SKY, pos) > 0 && world.getBiome(pos).value().getTemperature(pos) >= 0.15F) {
dropStacks(state, world, pos);
if(state.get(LAYERS) != 0) {
var cachedFlower = CachedFlowers.getFlower(world.getRegistryKey(), pos);
world.setBlockState(pos, Objects.requireNonNullElse(cachedFlower, this).getDefaultState());
}
}
}
}
Expand Down
10 changes: 6 additions & 4 deletions src/main/java/winterly/block/FrozenGrassBlock.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package winterly.block;

import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
Expand Down Expand Up @@ -49,10 +50,11 @@ public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random
dropStacks(state, world, pos);
world.setBlockState(pos, Blocks.GRASS.getDefaultState());
}

if(!state.get(PERSISTENT) && world.getLightLevel(LightType.SKY, pos) > 0 && world.getBiome(pos).value().getTemperature(pos) >= 0.15F) {
dropStacks(state, world, pos);
world.setBlockState(pos, Blocks.GRASS.getDefaultState());
else if(FabricLoader.getInstance().isModLoaded("seasons")) {
if(!state.get(PERSISTENT) && world.getLightLevel(LightType.SKY, pos) > 0 && world.getBiome(pos).value().getTemperature(pos) >= 0.15F) {
dropStacks(state, world, pos);
world.setBlockState(pos, Blocks.GRASS.getDefaultState());
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/winterly/mixin/common/SnowBlockMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ void getPlacementState(ItemPlacementContext ctx, CallbackInfoReturnable<BlockSta
BlockState state = ctx.getWorld().getBlockState(ctx.getBlockPos());
if(state.isOf(WinterlyBlocks.FROZEN_GRASS)) {
int layers = state.get(SnowBlock.LAYERS);
cir.setReturnValue(state.with(SnowBlock.LAYERS, Math.min(8, layers + 1)));
cir.setReturnValue(state.with(SnowBlock.LAYERS, Math.min(8, layers + 1)).with(FrozenGrassBlock.PERSISTENT, true));
}
else if(state.isOf(WinterlyBlocks.FROZEN_FLOWER)) {
int layers = state.get(FrozenFlowerBlock.LAYERS);
cir.setReturnValue(state.with(FrozenFlowerBlock.LAYERS, Math.min(8, layers + 1)));
cir.setReturnValue(state.with(FrozenFlowerBlock.LAYERS, Math.min(8, layers + 1)).with(FrozenGrassBlock.PERSISTENT, true));
}
else if(state.isOf(Blocks.GRASS)) {
cir.setReturnValue(WinterlyBlocks.FROZEN_GRASS.getDefaultState().with(FrozenGrassBlock.PERSISTENT, true));
Expand Down

0 comments on commit 3dcaebc

Please sign in to comment.