Skip to content

Commit

Permalink
- fix chromite ore dropping itself
Browse files Browse the repository at this point in the history
- fix iron composters not working
- fix crash on latest tfc
- added squirting moisture transducer, which waters planters automatically
- added embedded pipes, which the transducer drives into the ground below it in order to operate
  • Loading branch information
eerussianguy committed Oct 11, 2022
1 parent 2e31275 commit 9f467c7
Show file tree
Hide file tree
Showing 98 changed files with 642 additions and 421 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ mixin_version=0.8.5
jei_version=9.7.1.232
patchouli_version=1.18.2-70
tfc_version=0.0.0-indev
tfc_identifier=4013922
tfc_identifier=4024876
jade_version=3970956
top_version=3965688
12 changes: 11 additions & 1 deletion resources/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@ def generate(rm: ResourceManager):
tex = 'firmalife:block/greenhouse/climate_station/%s' % variant
rm.block_model('firmalife:climate_station_%s' % variant, {'west': tex, 'east': tex, 'north': tex, 'south': tex, 'particle': tex, 'up': 'firmalife:block/greenhouse/climate_station/top', 'down': 'firmalife:block/greenhouse/climate_station/end'}, 'block/cube')

trd = 'squirting_moisture_transducer'
rm.blockstate(trd, variants={
'stasis=true': {'model': 'firmalife:block/' + trd + '_on'},
'stasis=false': {'model': 'firmalife:block/' + trd + '_off'}
}).with_lang(lang(trd)).with_tag('minecraft:mineable/pickaxe').with_block_loot('firmalife:%s' % trd)
rm.item_model(trd, parent='firmalife:block/' + trd + '_on')
for variant in ('on', 'off'):
tex = 'firmalife:block/%s_%s' % (trd, variant)
rm.block_model('firmalife:%s_%s' % (trd, variant), {'west': tex, 'east': tex, 'north': tex, 'south': tex, 'particle': tex, 'up': 'firmalife:block/%s_top' % trd, 'down': 'firmalife:block/%s_top' % trd})

rm.blockstate('beehive', variants={
**four_rotations('minecraft:block/beehive_honey', (90, None, 180, 270), ',honey=true'),
**four_rotations('minecraft:block/beehive', (90, None, 180, 270), ',honey=false')
Expand Down Expand Up @@ -123,7 +133,7 @@ def generate(rm: ResourceManager):
'particle': 'tfc:block/rock/raw/%s' % rock,
'overlay': 'firmalife:block/ore/%s_%s' % (grade, ore)
}, parent='tfc:block/ore')
block.with_item_model().with_lang(lang('%s %s %s', grade, rock, ore)).with_block_loot('firmalife:ore/%s_%s/%s' % (grade, ore, rock)).with_tag('minecraft:mineable/pickaxe').with_tag('tfc:prospectable')
block.with_item_model().with_lang(lang('%s %s %s', grade, rock, ore)).with_block_loot('firmalife:ore/%s_%s' % (grade, ore)).with_tag('minecraft:mineable/pickaxe').with_tag('tfc:prospectable')
rm.block('firmalife:ore/%s_%s/%s/prospected' % (grade, ore, rock)).with_lang(lang(ore))

for carving in CARVINGS.keys():
Expand Down
7 changes: 6 additions & 1 deletion resources/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
'cocoa_butter', 'cocoa_powder', 'toast', 'dark_chocolate', 'milk_chocolate', 'white_chocolate')
SIMPLE_SPICES = ('ground_cinnamon', 'cinnamon', 'basil_leaves')
SIMPLE_BLOCKS: Dict[str, str] = {
'sealed_bricks': 'minecraft:mineable/pickaxe'
'sealed_bricks': 'minecraft:mineable/pickaxe',
'embedded_pipe': 'minecraft:mineable/pickaxe',
}
BLOCK_ENTITIES = ('oven_bottom', 'oven_top', 'drying_mat', 'beehive', 'solar_drier', 'mixing_bowl', 'iron_composter', 'string', 'berry_bush', 'large_planter', 'bonsai_planter', 'trellis_planter', 'hanging_planter', 'quad_planter', 'climate_station')
EXTRA_FLUIDS = ('yeast_starter', 'coconut_milk', 'yak_milk', 'goat_milk', 'curdled_yak_milk', 'curdled_goat_milk', 'pina_colada', 'cream')
Expand Down Expand Up @@ -147,6 +148,10 @@ def preset_vein(ore: str, vein_type: str, rocks: List[str], spoiler_ore: Optiona
'firmalife.greenhouse.wrong_type': 'This crop does not grow in this planter. It grows in a ',
'firmalife.greenhouse.found': 'Found a greenhouse of %s blocks',
'firmalife.planter.growth_water': 'Growth: %s, Water: %s',
'firmalife.transducer.no_pipes': 'Currently empty. Add embedded pipes with right click!',
'firmalife.transducer.current_pipes': 'Pipe Inventory: %s',
'firmalife.transducer.pipe_length': 'Current Pipes: %s',
'firmalife.transducer.pipe_wanted': 'Pipes needed due to the the local climate: %s',

'firmalife.bee.queen': 'Queen',
'firmalife.bee.no_queen': 'No Queen',
Expand Down
1 change: 1 addition & 0 deletions resources/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def generate(rm: ResourceManager):
rm.block_tag('drops_fruit_leaf', '#tfc:fruit_tree_leaves')
rm.block_tag('cellar_insulation', 'firmalife:sealed_bricks', 'firmalife:sealed_door')
rm.block_tag('buzzing_leaves', 'firmalife:plant/fig_leaves')
rm.block_tag('pipe_replaceable', '#tfc:dirt', '#tfc:grass', '#minecraft:base_stone_overworld', '#forge:gravel', '#minecraft:sand', '#tfc:can_carve')

rm.block_tag('minecraft:mineable/axe', *['firmalife:plant/%s_branch' % t for t in FRUITS], *['firmalife:plant/%s_growing_branch' % t for t in FRUITS], *['firmalife:plant/%s' % p for p in HERBS], 'firmalife:plant/butterfly_grass')
rm.block_tag('tfc:mineable_with_sharp_tool', *['firmalife:plant/%s_leaves' % t for t in FRUITS], *['firmalife:plant/%s_sapling' % t for t in FRUITS])
Expand Down
2 changes: 2 additions & 0 deletions resources/recipes.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ def generate(rm: ResourceManager):
rm.crafting_shapeless('crafting/pickled_egg', ('minecraft:clay_ball', 'tfc:powder/wood_ash', 'tfc:powder/salt', 'tfc:food/boiled_egg'), 'firmalife:food/pickled_egg')
rm.crafting_shaped('crafting/seed_ball', [' X ', 'XYX', ' X '], {'X': '#tfc:seeds', 'Y': 'tfc:compost'}, 'firmalife:seed_ball').with_advancement('tfc:compost')
rm.crafting_shapeless('crafting/raw_pumpkin_pie', ('firmalife:food/pumpkin_pie_dough', 'firmalife:pie_pan'), 'firmalife:food/raw_pumpkin_pie').with_advancement('firmalife:food/pumpkin_pie_dough')
rm.crafting_shaped('crafting/squirting_moisture_transducer', ['XYX', 'XZX', 'XYX'], {'X': '#forge:sheets/stainless_steel', 'Y': 'tfc:brass_mechanisms', 'Z': '#forge:rods/nickel'}, 'firmalife:squirting_moisture_transducer').with_advancement('#forge:rods/stainless_steel')
rm.crafting_shaped('crafting/embedded_pipe', ['XY', 'XY', 'ZZ'], {'X': '#forge:rods/stainless_steel', 'Y': '#forge:rods/copper', 'Z': 'firmalife:beeswax'}, '6 firmalife:embedded_pipe').with_advancement('#forge:rods/stainless_steel')
rm.domain = 'tfc'
rm.crafting_shapeless('crafting/pumpkin_pie', ('firmalife:food/cooked_pumpkin_pie',), 'minecraft:pumpkin_pie').with_advancement('firmalife:food/cooked_pumpkin_pie')
rm.domain = 'firmalife'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public static class Blocks
public static final TagKey<Block> BEE_RESTORATION_WATER_PLANTS = create("bee_restoration_water_plants");
public static final TagKey<Block> BUTTERFLY_GRASS_MUTANTS = create("butterfly_grass_mutants");
public static final TagKey<Block> BUZZING_LEAVES = create("buzzing_leaves");
public static final TagKey<Block> PIPE_REPLACEABLE = create("pipe_replaceable");

private static TagKey<Block> create(String id)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public class FLBlockEntities
public static final RegistryObject<BlockEntityType<StringBlockEntity>> STRING = register("string", StringBlockEntity::new, FLBlocks.WOOL_STRING);
public static final RegistryObject<BlockEntityType<MixingBowlBlockEntity>> MIXING_BOWL = register("mixing_bowl", MixingBowlBlockEntity::new, FLBlocks.MIXING_BOWL);
public static final RegistryObject<BlockEntityType<BerryBushBlockEntity>> BERRY_BUSH = register("berry_bush", FLBerryBushBlockEntity::new, Stream.of(FLBlocks.FRUIT_TREE_LEAVES.values()).<Supplier<? extends Block>>flatMap(Helpers::flatten));
public static final RegistryObject<BlockEntityType<SquirtingMoistureTransducerBlockEntity>> SQUIRTING_MOISTURE_TRANSDUCER = register("squirting_moisture_transducer", SquirtingMoistureTransducerBlockEntity::new, FLBlocks.SQUIRTING_MOISTURE_TRANSDUCER);

public static final RegistryObject<BlockEntityType<LargePlanterBlockEntity>> LARGE_PLANTER = register("large_planter", LargePlanterBlockEntity::new, FLBlocks.LARGE_PLANTER);
public static final RegistryObject<BlockEntityType<BonsaiPlanterBlockEntity>> BONSAI_PLANTER = register("bonsai_planter", BonsaiPlanterBlockEntity::new, FLBlocks.BONSAI_PLANTER);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
package com.eerussianguy.firmalife.common.blockentities;

import java.util.Random;

import net.minecraft.core.BlockPos;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.util.Mth;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.items.ItemStackHandler;

import com.eerussianguy.firmalife.common.FLHelpers;
import com.eerussianguy.firmalife.common.FLTags;
import com.eerussianguy.firmalife.common.blocks.FLBlocks;
import com.eerussianguy.firmalife.common.blocks.greenhouse.SquirtingMoistureTransducerBlock;
import net.dries007.tfc.client.particle.TFCParticles;
import net.dries007.tfc.common.blockentities.TickableInventoryBlockEntity;
import net.dries007.tfc.common.capabilities.Capabilities;
import net.dries007.tfc.util.Helpers;
import net.dries007.tfc.util.climate.Climate;

public class SquirtingMoistureTransducerBlockEntity extends TickableInventoryBlockEntity<ItemStackHandler> implements ClimateReceiver
{
public static void serverTick(Level level, BlockPos pos, BlockState state, SquirtingMoistureTransducerBlockEntity transducer)
{
transducer.checkForLastTickSync();
if (level.getGameTime() % 20 == 0 || transducer.cachedMoisture == -1)
{
transducer.cachedMoisture = updateMoisture(level, pos, state, transducer);
}
if (transducer.climateValid)
{
if (level.getGameTime() % WATER_UPDATE_INTERVAL == 0 && level instanceof ServerLevel serverLevel && updateMoisture(level, pos, state, transducer) > getMinPipes(level, pos))
{
final double x = pos.getX() + 0.5;
final double y = pos.getY() + 1.1;
final double z = pos.getZ() + 0.5;
final Random random = level.random;
serverLevel.sendParticles(ParticleTypes.BUBBLE, x + Helpers.triangle(random, 2), y + Helpers.triangle(random, 2) + 2, z + Helpers.triangle(random, 2), 15, 0.0, 0.0, 0.0, 1);
serverLevel.sendParticles(TFCParticles.STEAM.get(), x, y, z, 15, 0.0, 0.0, 0.0, 1);
FLHelpers.allPositionsCentered(pos, 4, 4).forEach(checkPos -> {
if (level.getBlockEntity(checkPos) instanceof ClimateReceiver receiver)
{
receiver.addWater(0.1f);
}
});
Helpers.playSound(level, pos, SoundEvents.GENERIC_EXTINGUISH_FIRE);
}
}
}

public static int getMinPipes(Level level, BlockPos pos)
{
return Mth.floor(Mth.map(Climate.getRainfall(level, pos), 0f, 500f, 31, 13));
}

private static int updateMoisture(Level level, BlockPos pos, BlockState state, SquirtingMoistureTransducerBlockEntity transducer)
{
final BlockPos.MutableBlockPos mutable = new BlockPos.MutableBlockPos();
final Block pipe = FLBlocks.EMBEDDED_PIPE.get();
final BlockState pipeState = pipe.defaultBlockState();
return transducer.getCapability(Capabilities.ITEM).map(inv -> {
int found = 0;
for (int y = -1; y >= -32; y--)
{
mutable.setWithOffset(pos, 0, y, 0);
final BlockState stateAt = level.getBlockState(mutable);
if (!Helpers.isBlock(stateAt, pipe))
{
if (!level.isClientSide)
{
ItemStack stack = inv.getStackInSlot(0);
if (!stack.isEmpty() && (Helpers.isBlock(stateAt, FLTags.Blocks.PIPE_REPLACEABLE) || stateAt.isAir()))
{
found++;
level.setBlockAndUpdate(mutable, pipeState);
inv.extractItem(0, 1, false);
transducer.markForSync();
Helpers.playSound(level, pos, SoundEvents.METAL_PLACE);
return found; // we only will update one
}
}
else
{
return found;
}
}
else
{
found++;
}
}
return found;
}).orElse(0);
}

private static final int WATER_UPDATE_INTERVAL = 20 * 60;

private boolean climateValid = false;
private int cachedMoisture = -1;

public SquirtingMoistureTransducerBlockEntity(BlockPos pos, BlockState state)
{
super(FLBlockEntities.SQUIRTING_MOISTURE_TRANSDUCER.get(), pos, state, defaultInventory(1), FLHelpers.blockEntityName("squirting_moisture_transducer"));
}

public boolean isClimateValid()
{
return climateValid;
}

/**
* for visualization only
*/
public int getCachedMoisture()
{
assert level != null;
if (cachedMoisture == -1 || level.getGameTime() % 20 == 0)
{
cachedMoisture = updateMoisture(level, getBlockPos(), level.getBlockState(getBlockPos()), this);
}
return cachedMoisture;
}

@Override
public int getSlotStackLimit(int slot)
{
return 32;
}

@Override
public boolean isItemValid(int slot, ItemStack stack)
{
return stack.getItem() == FLBlocks.EMBEDDED_PIPE.get().asItem();
}

@Override
public void loadAdditional(CompoundTag nbt)
{
super.loadAdditional(nbt);
climateValid = nbt.getBoolean("valid");
cachedMoisture = -1;
}

@Override
public void saveAdditional(CompoundTag nbt)
{
super.saveAdditional(nbt);
nbt.putBoolean("valid", climateValid);
}

@Override
public void addWater(float amount) { }

@Override
public void setValid(Level level, BlockPos pos, boolean valid, int tier, boolean cellar)
{
if (!cellar)
{
this.climateValid = valid;
markForSync();
BlockState state = level.getBlockState(pos);
if (state.getBlock() instanceof SquirtingMoistureTransducerBlock)
{
boolean stasis = state.getValue(SquirtingMoistureTransducerBlock.STASIS);
if (stasis != valid)
{
level.setBlockAndUpdate(pos, state.setValue(SquirtingMoistureTransducerBlock.STASIS, valid));
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public class FLBlocks
public static final RegistryObject<Block> DRYING_MAT = register("drying_mat", () -> new DryingMatBlock(ExtendedProperties.of(Material.DECORATION).strength(3.0f).sound(SoundType.AZALEA_LEAVES).flammable(60, 30).blockEntity(FLBlockEntities.DRYING_MAT).serverTicks(DryingMatBlockEntity::serverTick)), DECORATIONS);
public static final RegistryObject<Block> SOLAR_DRIER = register("solar_drier", () -> new SolarDrierBlock(ExtendedProperties.of(Material.WOOD).strength(3.0f).sound(SoundType.WOOD).noOcclusion().flammable(60, 30).blockEntity(FLBlockEntities.SOLAR_DRIER).serverTicks(DryingMatBlockEntity::serverTick)), DECORATIONS);
public static final RegistryObject<Block> BEEHIVE = register("beehive", () -> new FLBeehiveBlock(ExtendedProperties.of(Material.WOOD).strength(0.6f).sound(SoundType.WOOD).flammable(60, 30).blockEntity(FLBlockEntities.BEEHIVE).serverTicks(FLBeehiveBlockEntity::serverTick)), DECORATIONS);
public static final RegistryObject<Block> IRON_COMPOSTER = register("iron_composter", () -> new TFCComposterBlock(ExtendedProperties.of(Material.WOOD).strength(0.6F).noOcclusion().sound(SoundType.METAL).randomTicks().flammable(60, 90).blockEntity(FLBlockEntities.IRON_COMPOSTER)), DECORATIONS);
public static final RegistryObject<Block> IRON_COMPOSTER = register("iron_composter", () -> new IronComposterBlock(ExtendedProperties.of(Material.WOOD).strength(0.6F).noOcclusion().sound(SoundType.METAL).randomTicks().flammable(60, 90).blockEntity(FLBlockEntities.IRON_COMPOSTER)), DECORATIONS);
public static final RegistryObject<Block> WOOL_STRING = register("wool_string", () -> new StringBlock(ExtendedProperties.of(Material.CLOTH_DECORATION).noCollission().strength(2.0f).sound(SoundType.WOOL).randomTicks().blockEntity(FLBlockEntities.STRING).serverTicks(StringBlockEntity::serverTick), TFCItems.WOOL_YARN));
public static final RegistryObject<Block> MIXING_BOWL = register("mixing_bowl", () -> new MixingBowlBlock(ExtendedProperties.of(Material.DIRT).sound(SoundType.STONE).strength(1f).noOcclusion().blockEntity(FLBlockEntities.MIXING_BOWL).ticks(MixingBowlBlockEntity::serverTick, MixingBowlBlockEntity::clientTick)), DECORATIONS);

Expand Down Expand Up @@ -92,6 +92,8 @@ public class FLBlocks
public static final RegistryObject<Block> SEALED_BRICKS = register("sealed_bricks", () -> new Block(Properties.of(Material.STONE).sound(SoundType.STONE).strength(2.0f, 10).requiresCorrectToolForDrops()), DECORATIONS);
public static final RegistryObject<Block> SEALED_DOOR = register("sealed_door", () -> new DoorBlock(Properties.of(Material.WOOD).sound(SoundType.STONE).strength(2.0f, 10).requiresCorrectToolForDrops()), DECORATIONS);
public static final RegistryObject<Block> HOLLOW_SHELL = register("hollow_shell", () -> new GroundcoverBlock(ExtendedProperties.of(Material.GRASS).strength(0.05F, 0.0F).sound(SoundType.NETHER_WART).noCollission(), GroundcoverBlock.SMALL, FLItems.HOLLOW_SHELL));
public static final RegistryObject<Block> EMBEDDED_PIPE = register("embedded_pipe", () -> new Block(Properties.of(Material.METAL).sound(SoundType.COPPER).strength(2f)), DECORATIONS);
public static final RegistryObject<Block> SQUIRTING_MOISTURE_TRANSDUCER = register("squirting_moisture_transducer", () -> new SquirtingMoistureTransducerBlock(ExtendedProperties.of(Material.METAL).strength(8f).sound(SoundType.LANTERN).blockEntity(FLBlockEntities.SQUIRTING_MOISTURE_TRANSDUCER).serverTicks(SquirtingMoistureTransducerBlockEntity::serverTick)), DECORATIONS);

public static final RegistryObject<Block> BUTTERFLY_GRASS = register("plant/butterfly_grass", () -> MutatingPlantBlock.create(FLPlant.BUTTERFLY_GRASS, FLPlant.BUTTERFLY_GRASS.nonSolidFire(), FLTags.Blocks.BUTTERFLY_GRASS_MUTANTS), FLORA);
public static final RegistryObject<Block> POTTED_BUTTERFLY_GRASS = register("plant/potted/butterfly_grass", () -> new FlowerPotBlock(() -> (FlowerPotBlock) Blocks.FLOWER_POT, BUTTERFLY_GRASS, Properties.of(Material.DECORATION).instabreak().noOcclusion()));
Expand Down
Loading

0 comments on commit 9f467c7

Please sign in to comment.