Skip to content

Commit

Permalink
Introduce data-driven plant temperature part 2
Browse files Browse the repository at this point in the history
  • Loading branch information
yuesha-yc committed Dec 8, 2024
1 parent 342ad65 commit 717063f
Show file tree
Hide file tree
Showing 30 changed files with 657 additions and 536 deletions.
14 changes: 8 additions & 6 deletions src/generated/resources/assets/frostedheart/lang/en_ud.json
Original file line number Diff line number Diff line change
Expand Up @@ -643,8 +643,8 @@
"message.frostedheart.cow.nomilk.hungry": "˙ʇɐǝɥʍ ɹo ssɐɹb ʎɹp ʇı pǝǝℲ ˙ʞןıɯ ǝɔnpoɹd oʇ ʎɹbunɥ ooʇ sı ʍoɔ sıɥ⟘",
"message.frostedheart.crank.feel_hunger": "˙ʞuɐɹɔ sıɥʇ ǝsn oʇ ʎɹbunɥ ooʇ ɯ,I",
"message.frostedheart.creative_help": "]ɥɔɹɐǝsǝɹ ןןɐ ʞɔoןun oʇ ʞɔıןƆ[",
"message.frostedheart.crop_no_bonemeal": "%s ɹǝpun ʇɔǝɟɟǝ ǝʞɐʇ ʇou op sɹǝzıןıʇɹǝℲ ˙ʍoן ooʇ sı ǝɹǝɥ ןǝʌǝן ʇsoɹɟǝp ןıoS",
"message.frostedheart.crop_not_growable": "%s ɹǝpun ʍoɹb ʇ,uoʍ doɹɔ sıɥ⟘ ˙ʍoן ooʇ sı ǝɹǝɥ ןǝʌǝן ʇsoɹɟǝp ןıoS",
"message.frostedheart.crop_no_bonemeal": "%s ɹǝpun ʇɔǝɟɟǝ ǝʞɐʇ ʇou op sɹǝzıןıʇɹǝℲ ˙ʍoן ooʇ sı ǝɹǝɥ ǝɹnʇɐɹǝdɯǝʇ ןıoS",
"message.frostedheart.crop_not_growable": "%s ɹǝpun ʍoɹb ʇ,uoʍ doɹɔ sıɥ⟘ ˙ʍoן ooʇ sı ǝɹǝɥ ǝɹnʇɐɹǝdɯǝʇ ןıoS",
"message.frostedheart.eat_wanted_food": "˙poob ןǝǝɟ noʎ ¡ʎɯɯnʎ",
"message.frostedheart.eaten_poisonous_food": "¡ʇɐǝɯ ʍɐɹ ʇɐǝ ʇou pןnoɥs noʎ",
"message.frostedheart.energy.full": "˙ǝʞɐɔ ɟo ǝɔǝıd ɐ sı buıɥʇʎɹǝʌǝ 'ɔıʇǝbɹǝuǝ ןǝǝɟ I",
Expand Down Expand Up @@ -673,7 +673,7 @@
"message.frostedheart.forecast.night": "%s :ʇɥbıN ʍoɹɹoɯo⟘ \n%s :uooN ʍoɹɹoɯo⟘ \n%s :buıuɹoW ʍoɹɹoɯo⟘ \n%s :ʇɥbıupıW \n%s :ʇɥbıuo⟘ \n:ʇsɐɔǝɹoℲ ɹǝɥʇɐǝM buıuǝʌƎ",
"message.frostedheart.forecast.snow_today": "<: ʎɐpo⟘ pǝʇɔǝdxƎ ʍouS ",
"message.frostedheart.forecast.snow_tomorrow": "<: ʍoɹɹoɯo⟘ pǝʇɔǝdxƎ ʍouS ",
"message.frostedheart.info.soil_thermometerbody": "%s :ʞɔoןq sıɥʇ ɟo ןǝʌǝן ʇsoɹɟǝp ןıoS",
"message.frostedheart.info.soil_thermometerbody": "%s :ʞɔoןq sıɥʇ ǝɹnʇɐɹǝdɯǝʇ ןıoS",
"message.frostedheart.info.thermometerbody": "%s :ǝɹnʇɐɹǝdɯǝ⟘ ʎpoᗺ",
"message.frostedheart.item_task": "ǝnuıʇuoɔ oʇ %s ʇǝ⅁",
"message.frostedheart.kill_task": "ǝnuıʇuoɔ oʇ %s ןןıʞ",
Expand Down Expand Up @@ -882,11 +882,13 @@
"tooltip.frostedheart.temp.equipment": " :pǝddınbƎ uǝɥM",
"tooltip.frostedheart.temp.food": " :pǝɯnsuoƆ uǝɥM",
"tooltip.frostedheart.temp.item": " :pןǝH uǝɥM",
"tooltip.frostedheart.temp.plant.blizzard_resistant": "pɹɐzzıןᗺ oʇ ʇuɐʇsısǝᴚ",
"tooltip.frostedheart.temp.plant.blizzard_vulnerable": "pɹɐzzıןᗺ oʇ ǝןqɐɹǝuןnΛ",
"tooltip.frostedheart.temp.plant.bonemeal": " :ǝʌoqⱯ ǝzıןıʇɹǝℲ uɐƆ",
"tooltip.frostedheart.temp.plant.grow": " :ǝʌoqⱯ ʍoɹ⅁ uɐƆ",
"tooltip.frostedheart.temp.plant.fertilize": " :uǝǝʍʇǝᗺ ǝzıןıʇɹǝℲ uɐƆ",
"tooltip.frostedheart.temp.plant.grow": " :uǝǝʍʇǝᗺ ʍoɹ⅁ uɐƆ",
"tooltip.frostedheart.temp.plant.snow_resistant": "ʍouS oʇ ʇuɐʇsısǝᴚ",
"tooltip.frostedheart.temp.plant.snow_vulnerable": "ʍouS oʇ ǝןqɐɹǝuןnΛ",
"tooltip.frostedheart.temp.plant.survive": " :ǝʌoqⱯ ǝʌıʌɹnS uɐƆ",
"tooltip.frostedheart.temp.plant.survive": " :uǝǝʍʇǝᗺ ǝʌıʌɹnS uɐƆ",
"tooltip.frostedheart.temperature_probe": "ǝɹnʇɐɹǝdɯǝʇ ʇuǝıqɯɐ ʎɐןdsıp oʇ noʎ ɥʇıʍ ʇı ʎɹɹɐƆ",
"tooltip.frostedheart.thermometer.usage": "ǝɹnsɐǝɯ oʇ pןoɥ puɐ ǝs∩",
"tooltip.frostedheart.weather_helmet": "buıuǝʌǝ puɐ buıuɹoɯ ʇɐ ʇsɐɔǝɹoɟ ɹǝɥʇɐǝʍ ǝʌıǝɔǝɹ oʇ dn ʇı ɹɐǝ⅁",
Expand Down
14 changes: 8 additions & 6 deletions src/generated/resources/assets/frostedheart/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -643,8 +643,8 @@
"message.frostedheart.cow.nomilk.hungry": "This cow is too hungry to produce milk. Feed it dry grass or wheat.",
"message.frostedheart.crank.feel_hunger": "I'm too hungry to use this crank.",
"message.frostedheart.creative_help": "[Click to unlock all research]",
"message.frostedheart.crop_no_bonemeal": "Soil defrost level here is too low. Fertilizers do not take effect under %s",
"message.frostedheart.crop_not_growable": "Soil defrost level here is too low. This crop won't grow under %s",
"message.frostedheart.crop_no_bonemeal": "Soil temperature here is too low. Fertilizers do not take effect under %s",
"message.frostedheart.crop_not_growable": "Soil temperature here is too low. This crop won't grow under %s",
"message.frostedheart.eat_wanted_food": "Yummy! You feel good.",
"message.frostedheart.eaten_poisonous_food": "You should not eat raw meat!",
"message.frostedheart.energy.full": "I feel energetic, everything is a piece of cake.",
Expand Down Expand Up @@ -673,7 +673,7 @@
"message.frostedheart.forecast.night": "Evening Weather Forecast:\n Tonight: %s\n Midnight: %s\n Tomorrow Morning: %s\n Tomorrow Noon: %s\n Tomorrow Night: %s",
"message.frostedheart.forecast.snow_today": " Snow Expected Today :<",
"message.frostedheart.forecast.snow_tomorrow": " Snow Expected Tomorrow :<",
"message.frostedheart.info.soil_thermometerbody": "Soil defrost level of this block: %s",
"message.frostedheart.info.soil_thermometerbody": "Soil temperature this block: %s",
"message.frostedheart.info.thermometerbody": "Body Temperature: %s",
"message.frostedheart.item_task": "Get %s to continue",
"message.frostedheart.kill_task": "Kill %s to continue",
Expand Down Expand Up @@ -882,11 +882,13 @@
"tooltip.frostedheart.temp.equipment": "When Equipped: ",
"tooltip.frostedheart.temp.food": "When Consumed: ",
"tooltip.frostedheart.temp.item": "When Held: ",
"tooltip.frostedheart.temp.plant.blizzard_resistant": "Resistant to Blizzard",
"tooltip.frostedheart.temp.plant.blizzard_vulnerable": "Vulnerable to Blizzard",
"tooltip.frostedheart.temp.plant.bonemeal": "Can Fertilize Above: ",
"tooltip.frostedheart.temp.plant.grow": "Can Grow Above: ",
"tooltip.frostedheart.temp.plant.fertilize": "Can Fertilize Between: ",
"tooltip.frostedheart.temp.plant.grow": "Can Grow Between: ",
"tooltip.frostedheart.temp.plant.snow_resistant": "Resistant to Snow",
"tooltip.frostedheart.temp.plant.snow_vulnerable": "Vulnerable to Snow",
"tooltip.frostedheart.temp.plant.survive": "Can Survive Above: ",
"tooltip.frostedheart.temp.plant.survive": "Can Survive Between: ",
"tooltip.frostedheart.temperature_probe": "Carry it with you to display ambient temperature",
"tooltip.frostedheart.thermometer.usage": "Use and hold to measure",
"tooltip.frostedheart.weather_helmet": "Gear it up to receive weather forecast at morning and evening",
Expand Down
26 changes: 23 additions & 3 deletions src/main/java/com/teammoeg/frostedheart/FHBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package com.teammoeg.frostedheart;

import com.google.common.collect.ImmutableMap;
import com.simibubi.create.AllTags;
import com.simibubi.create.foundation.data.AssetLookup;
import com.simibubi.create.foundation.data.ModelGen;
Expand Down Expand Up @@ -67,6 +68,8 @@
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;

import java.util.HashMap;
import java.util.Map;
import java.util.function.Function;
import java.util.function.Supplier;

Expand Down Expand Up @@ -1056,7 +1059,7 @@ protected static <T extends Block> RegistryObject<T> register(String name, Suppl
.loot((lt, b) -> lt.add(b,
lt.createSingleItemTableWithSilkTouch(b, Items.RAW_COPPER, ConstantValue.exactly(1))))
.register();
public static final BlockEntry<RyeBlock> RYE_BLOCK = REGISTRATE.block("rye_block", p -> new RyeBlock(WorldTemperature.COLD_RESIST_GROW_TEMPERATURE, FHProps.cropProps))
public static final BlockEntry<RyeBlock> RYE_BLOCK = REGISTRATE.block("rye_block", p -> new RyeBlock(FHProps.cropProps))
.blockstate((c, p) -> p.getExistingVariantBuilder(c.get()))
.item()
.model(AssetLookup.existingItemModel())
Expand All @@ -1066,7 +1069,7 @@ protected static <T extends Block> RegistryObject<T> register(String name, Suppl
.register();

public static final BlockEntry<WolfBerryBushBlock> WOLFBERRY_BUSH_BLOCK = REGISTRATE.block("wolfberry_bush_block",
p -> new WolfBerryBushBlock(WorldTemperature.COLD_RESIST_GROW_TEMPERATURE, FHProps.berryBushBlocks, 2))
p -> new WolfBerryBushBlock(FHProps.berryBushBlocks))
.blockstate((c, p) -> p.getExistingVariantBuilder(c.get()))
.item()
.model(AssetLookup.existingItemModel())
Expand All @@ -1076,7 +1079,7 @@ protected static <T extends Block> RegistryObject<T> register(String name, Suppl
.register();

public static final BlockEntry<WhiteTurnipBlock> WHITE_TURNIP_BLOCK = REGISTRATE.block("white_turnip_block",
p -> new WhiteTurnipBlock(WorldTemperature.COLD_RESIST_GROW_TEMPERATURE, FHProps.cropProps))
p -> new WhiteTurnipBlock(FHProps.cropProps))
.blockstate((c, p) -> p.getExistingVariantBuilder(c.get()))
.item()
.model(AssetLookup.existingItemModel())
Expand Down Expand Up @@ -1880,4 +1883,21 @@ protected static <T extends Block> RegistryObject<T> register(String name, Suppl
.register();

public static void init() { }

public static final Map<Block, Supplier<? extends Block>> SNOWY_TERRAIN_BLOCKS = new HashMap<>(new ImmutableMap.Builder<Block, Supplier<? extends Block>>()
.put(Blocks.DIRT, DIRT_PERMAFROST)
.put(Blocks.PODZOL, PODZOL_PERMAFROST)
.put(Blocks.MYCELIUM, MYCELIUM_PERMAFROST)
.put(Blocks.COARSE_DIRT, COARSE_DIRT_PERMAFROST)
.put(Blocks.SAND, SAND_PERMAFROST)
.put(Blocks.RED_SAND, RED_SAND_PERMAFROST)
.put(Blocks.GRAVEL, GRAVEL_PERMAFROST)
.put(Blocks.CLAY, CLAY_PERMAFROST)
.put(Blocks.ROOTED_DIRT, ROOTED_DIRT_PERMAFROST)
.put(Blocks.MUD, MUD_PERMAFROST)
// .put(FHBlocks.KAOLIN.get(), KAOLIN_PERMAFROST)
// .put(FHBlocks.BAUXITE.get(), BAUXITE_PERMAFROST)
// .put(FHBlocks.PEAT.get(), PEAT_PERMAFROST)
.build()
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,48 +19,18 @@

package com.teammoeg.frostedheart.content.agriculture;

import com.teammoeg.frostedheart.content.climate.WorldClimate;
import com.teammoeg.frostedheart.content.climate.WorldTemperature;
import com.teammoeg.frostedheart.content.climate.WorldTemperature.TemperatureCheckResult;
import com.teammoeg.frostedheart.util.FHUtils;

import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.SweetBerryBushBlock;
import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.core.BlockPos;
import net.minecraft.world.phys.Vec3;
import net.minecraft.world.level.Level;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.RandomSource;
import net.minecraft.world.level.block.SweetBerryBushBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.Vec3;

public class FHBerryBushBlock extends SweetBerryBushBlock {

private int growTemperature;
protected int growSpeed = 10;//0<growSpeed<50,growSpeed=50时具有原版浆果丛的生长速度

public FHBerryBushBlock(int growTemperature, Properties properties) {
super(properties);

this.growTemperature = growTemperature;
}//if you don't want to set growSpeed

public FHBerryBushBlock(int growTemperature, Properties properties, int growSpeed) {
super(properties);

this.growTemperature = growTemperature;
this.growSpeed = growSpeed;
}

@Override
public boolean isBonemealSuccess(Level worldIn, RandomSource rand, BlockPos pos, BlockState state) {
return WorldTemperature.isSuitableForCrop(worldIn,pos,getGrowTemperature()+ WorldTemperature.BONEMEAL_TEMPERATURE).isSuitable();
}


public int getGrowTemperature() {
return growTemperature;
public FHBerryBushBlock(Properties pProperties) {
super(pProperties);
}

@Override
Expand All @@ -79,22 +49,4 @@ public void entityInside(BlockState state, Level worldIn, BlockPos pos, Entity e
}
}

@Override
public void randomTick(BlockState state, ServerLevel worldIn, BlockPos pos, RandomSource random) {
int i = state.getValue(AGE);
TemperatureCheckResult res = WorldTemperature.isSuitableForCrop(worldIn,pos,getGrowTemperature(),getGrowTemperature()-5);
if(!res.isValid())return;
if(res.isRipedOff()) {
FHUtils.setToAirPreserveFluid(worldIn, pos);
}else if (res.isDeadly()) {
if (worldIn.getRandom().nextInt(3) == 0) {
worldIn.setBlock(pos, this.defaultBlockState(), 2);
}
} else if(res.isSuitable())
if (i < 3 && worldIn.getRawBrightness(pos.above(), 0) >= 9 && net.minecraftforge.common.ForgeHooks.onCropsGrowPre(worldIn, pos, state, random.nextInt(50) < this.growSpeed)) {
worldIn.setBlock(pos, state.setValue(AGE, i + 1), 2);
net.minecraftforge.common.ForgeHooks.onCropsGrowPost(worldIn, pos, state);
}
}

}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import com.teammoeg.frostedheart.FHBlocks;

import net.minecraft.world.level.block.CropBlock;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
Expand All @@ -35,12 +36,12 @@
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;

public class RyeBlock extends FHCropBlock {
public class RyeBlock extends CropBlock {
public static final IntegerProperty Rye_AGE = BlockStateProperties.AGE_7;
private static final VoxelShape[] SHAPE = new VoxelShape[]{Block.box(0.0D, 0.0D, 0.0D, 16.0D, 2.0D, 16.0D), Block.box(0.0D, 0.0D, 0.0D, 16.0D, 4.0D, 16.0D), Block.box(0.0D, 0.0D, 0.0D, 16.0D, 6.0D, 16.0D), Block.box(0.0D, 0.0D, 0.0D, 16.0D, 8.0D, 16.0D), Block.box(0.0D, 0.0D, 0.0D, 16.0D, 10.0D, 16.0D), Block.box(0.0D, 0.0D, 0.0D, 16.0D, 12.0D, 16.0D), Block.box(0.0D, 0.0D, 0.0D, 16.0D, 14.0D, 16.0D), Block.box(0.0D, 0.0D, 0.0D, 16.0D, 16.0D, 16.0D)};

public RyeBlock( int growTemp, BlockBehaviour.Properties properties) {
super(growTemp, properties);
public RyeBlock(BlockBehaviour.Properties properties) {
super(properties);
}

protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import com.teammoeg.frostedheart.FHBlocks;

import net.minecraft.world.level.block.CropBlock;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
Expand All @@ -35,12 +36,12 @@
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;

public class WhiteTurnipBlock extends FHCropBlock {
public class WhiteTurnipBlock extends CropBlock {
public static final IntegerProperty WhiteTurnip_AGE = BlockStateProperties.AGE_7;
private static final VoxelShape[] SHAPE = new VoxelShape[]{Block.box(0.0D, 0.0D, 0.0D, 16.0D, 2.0D, 16.0D), Block.box(0.0D, 0.0D, 0.0D, 16.0D, 4.0D, 16.0D), Block.box(0.0D, 0.0D, 0.0D, 16.0D, 6.0D, 16.0D), Block.box(0.0D, 0.0D, 0.0D, 16.0D, 8.0D, 16.0D), Block.box(0.0D, 0.0D, 0.0D, 16.0D, 10.0D, 16.0D), Block.box(0.0D, 0.0D, 0.0D, 16.0D, 12.0D, 16.0D), Block.box(0.0D, 0.0D, 0.0D, 16.0D, 14.0D, 16.0D), Block.box(0.0D, 0.0D, 0.0D, 16.0D, 16.0D, 16.0D)};

public WhiteTurnipBlock(int growTemp, BlockBehaviour.Properties properties) {
super(growTemp, properties);
public WhiteTurnipBlock(BlockBehaviour.Properties properties) {
super(properties);
}

protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,9 @@

public class WolfBerryBushBlock extends FHBerryBushBlock {
public static final IntegerProperty AGE = BlockStateProperties.AGE_3;
/* private static final VoxelShape BUSHLING_SHAPE = Block.makeCuboidShape(3.0D, 0.0D, 3.0D, 13.0D, 8.0D, 13.0D);
private static final VoxelShape GROWING_SHAPE = Block.makeCuboidShape(1.0D, 0.0D, 1.0D, 15.0D, 15.0D, 15.0D);

public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
if (state.get(AGE) == 0) {
return BUSHLING_SHAPE;
}else if(state.get(AGE) == 1){
return GROWING_SHAPE;
} else {
return state.get(AGE) < 3 ? GROWING_SHAPE : super.getShape(state, worldIn, pos, context);
}
}*/

public WolfBerryBushBlock(int growTemperature, Properties properties, int growSpeed) {
super(growTemperature, properties, growSpeed);
public WolfBerryBushBlock(Properties properties) {
super(properties);
}
ResourceLocation wolfBerries=new ResourceLocation(FHMain.MODID,"wolfberries");
public ItemStack getCloneItemStack(BlockGetter worldIn, BlockPos pos, BlockState state) {
Expand Down
Loading

0 comments on commit 717063f

Please sign in to comment.