mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-20 03:44:23 +01:00
Improve the seasons mod integration
This commit is contained in:
parent
fc29057f05
commit
54897e0595
13 changed files with 137 additions and 28 deletions
|
@ -29,6 +29,9 @@ public class UnicopiaMixinPlugin implements IMixinConfigPlugin {
|
|||
if (mixinClassName.indexOf("trinkets") != -1) {
|
||||
return FabricLoader.getInstance().isModLoaded("trinkets");
|
||||
}
|
||||
if (mixinClassName.indexOf("seasons") != -1) {
|
||||
return FabricLoader.getInstance().isModLoaded("seasons");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import org.jetbrains.annotations.Nullable;
|
|||
|
||||
import com.minelittlepony.unicopia.USounds;
|
||||
import com.minelittlepony.unicopia.ability.EarthPonyKickAbility.Buckable;
|
||||
import com.minelittlepony.unicopia.seasons.FertilizableUtil;
|
||||
|
||||
import net.fabricmc.fabric.api.registry.FlammableBlockRegistry;
|
||||
import net.minecraft.block.*;
|
||||
|
@ -71,7 +72,8 @@ public class FruitBearingBlock extends LeavesBlock implements TintedBlock, Bucka
|
|||
|
||||
if (world.isDay()) {
|
||||
BlockSoundGroup group = getSoundGroup(state);
|
||||
|
||||
int steps = FertilizableUtil.getGrowthSteps(world, pos, state, random);
|
||||
while (steps-- > 0) {
|
||||
if (state.get(STAGE) == Stage.FRUITING) {
|
||||
state = state.cycle(AGE);
|
||||
if (state.get(AGE) > 20) {
|
||||
|
@ -108,6 +110,7 @@ public class FruitBearingBlock extends LeavesBlock implements TintedBlock, Bucka
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) {
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
package com.minelittlepony.unicopia.mixin.seasons;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Pseudo;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
@Pseudo
|
||||
@Mixin(
|
||||
targets = { "io.github.lucaargolo.seasons.utils.FertilizableUtil" },
|
||||
remap = false
|
||||
)
|
||||
public interface MixinFertilizableUtil {
|
||||
@Invoker("getMultiplier")
|
||||
static float getMultiplier(ServerWorld world, BlockPos pos, BlockState state) {
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package com.minelittlepony.unicopia.seasons;
|
||||
|
||||
import com.minelittlepony.unicopia.mixin.seasons.MixinFertilizableUtil;
|
||||
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.random.Random;
|
||||
|
||||
public interface FertilizableUtil {
|
||||
boolean MOD_LOADED = FabricLoader.getInstance().isModLoaded("seasons");
|
||||
|
||||
static float getMultiplier(ServerWorld world, BlockPos pos, BlockState state) {
|
||||
if (MOD_LOADED) {
|
||||
return MixinFertilizableUtil.getMultiplier(world, pos, state);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int getGrowthSteps(ServerWorld world, BlockPos pos, BlockState state, Random random) {
|
||||
float multiplier = 1 + FertilizableUtil.getMultiplier(world, pos, state);
|
||||
int steps = 0;
|
||||
|
||||
while (multiplier > 0) {
|
||||
if (multiplier >= random.nextFloat()) {
|
||||
multiplier -= 1;
|
||||
steps++;
|
||||
}
|
||||
}
|
||||
|
||||
return steps;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"spring": 0.5,
|
||||
"summer": 0.6,
|
||||
"fall": 1.0,
|
||||
"winter": 0
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"spring": 0.5,
|
||||
"summer": 0.6,
|
||||
"fall": 1.0,
|
||||
"winter": 0
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"spring": 1.0,
|
||||
"summer": 1.6,
|
||||
"fall": 0.5,
|
||||
"winter": 0
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"spring": 1.0,
|
||||
"summer": 1.6,
|
||||
"fall": 0.5,
|
||||
"winter": 0
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"spring": 0.25,
|
||||
"summer": 0.5,
|
||||
"fall": 1.0,
|
||||
"winter": 0.5
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"spring": 0.25,
|
||||
"summer": 0.5,
|
||||
"fall": 1.0,
|
||||
"winter": 0.5
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"spring": 1.0,
|
||||
"summer": 1.0,
|
||||
"fall": 0.6,
|
||||
"winter": 0
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"spring": 1.0,
|
||||
"summer": 1.0,
|
||||
"fall": 0.6,
|
||||
"winter": 0
|
||||
}
|
|
@ -48,7 +48,8 @@
|
|||
"trinkets.MixinTrinketSurvivalSlot",
|
||||
"trinkets.MixinTrinketItem",
|
||||
"trinkets.MixinTrinketInventory",
|
||||
"trinkets.MixinScreenHandler"
|
||||
"trinkets.MixinScreenHandler",
|
||||
"seasons.MixinFertilizableUtil"
|
||||
],
|
||||
"client": [
|
||||
"client.MixinAnimalModel",
|
||||
|
|
Loading…
Reference in a new issue