Skip to content

Commit

Permalink
debug all that good stuff.
Browse files Browse the repository at this point in the history
  • Loading branch information
eerussianguy committed Oct 25, 2022
1 parent 73d5f4e commit a4daeb3
Show file tree
Hide file tree
Showing 48 changed files with 143 additions and 88 deletions.
4 changes: 2 additions & 2 deletions resources/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,12 @@ def generate(rm: ResourceManager):
block = rm.blockstate('firmalife:wood/food_shelf/%s' % wood, variants=four_rotations('firmalife:block/wood/food_shelf/%s' % wood, (270, 180, None, 90)))
block.with_block_loot('firmalife:wood/food_shelf/%s' % wood).with_lang(lang('%s food shelf', wood)).with_tag('minecraft:mineable/axe')
rm.item_model('firmalife:wood/food_shelf/%s' % wood, parent='firmalife:block/wood/food_shelf/%s' % wood, no_textures=True)
rm.block_model('firmalife:wood/food_shelf/%s' % wood, parent='firmalife:block/food_shelf_base', textures={'wood': 'tfc:block/wood/planks/%s' % wood, 'string': 'minecraft:block/white_wool'})
rm.block_model('firmalife:wood/food_shelf/%s' % wood, parent='firmalife:block/food_shelf_base', textures={'wood': 'tfc:block/wood/planks/%s' % wood})

block = rm.blockstate('firmalife:wood/hanger/%s' % wood, model='firmalife:block/wood/hanger/%s' % wood)
block.with_block_loot('firmalife:wood/hanger/%s' % wood).with_lang(lang('%s hanger' % wood)).with_tag('minecraft:mineable/axe')
rm.item_model('firmalife:wood/hanger/%s' % wood, parent='firmalife:block/wood/hanger/%s' % wood, no_textures=True)
rm.block_model('firmalife:wood/hanger/%s' % wood, parent='firmalife:block/food_shelf_base', textures={'wood': 'tfc:block/wood/planks/%s' % wood})
rm.block_model('firmalife:wood/hanger/%s' % wood, parent='firmalife:block/hanger_base', textures={'wood': 'tfc:block/wood/planks/%s' % wood, 'string': 'minecraft:block/white_wool'})

for fruit in FRUITS.keys():
for prefix in ('', 'growing_'):
Expand Down
4 changes: 4 additions & 0 deletions resources/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,16 @@ def preset_vein(ore: str, vein_type: str, rocks: List[str], spoiler_ore: Optiona
'firmalife.tooltip.food_trait.vintage': 'Vintage',
'firmalife.tooltip.food_trait.fresh': 'Fresh',
'firmalife.tooltip.food_trait.oven_baked': 'Oven Baked',
'firmalife.tooltip.food_trait.hung': 'Hung in a Cellar',
'firmalife.tooltip.food_trait.shelved': 'On a Cellar Shelf',
'firmalife.tooltip.food_trait.smoked': 'Smoked',
'firmalife.tooltip.food_trait.rancid_smoked': 'Rancid Smoked',
'firmalife.tooltip.food_trait.raw': 'Raw (INEDIBLE)',
'firmalife.tooltip.seed_ball': 'Throw me!',
'firmalife.tooltip.seed_ball_disabled': 'This server has disabled seed balls!',
'firmalife.cellar.found': 'Found a cellar of %s blocks',
'firmalife.cellar.valid_block': 'In a valid cellar',
'firmalife.cellar.invalid_block': 'Invalid cellar',
'firmalife.greenhouse.valid_block': '§aGrowing',
'firmalife.greenhouse.invalid_block': '§cNot Growing',
'firmalife.greenhouse.no_sky': 'There is not enough sky light to grow',
Expand Down
2 changes: 1 addition & 1 deletion resources/generate_book.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def make_book(rm: ResourceManager, i18n: I18n, local_instance: bool = False):
text('Beehives know about the area in a 5 block radius from them. If there are at least 10 flowers around the hive, there is a chance an empty frame will be populated with a $(thing)Queen$(). This is indicated by bee particles flying around the hive.'),
text('If a beehive has two frames with queens, and an empty frame, the two colonies have a chance of $(thing)Breeding$() and producing a new queen in the empty frame. This has the effect of passing on the $(thing)Abilities$() of each parent to the offspring. Abilities are different traits bees have that change how they effect the world around them. They are on a scale of 1-10, with 10 being the max.'),
crafting('firmalife:crafting/honey_jar_open', text_contents='Bees also produce $(thing)Honey$(). Using $(item)$(k:key.use)$() with an $(l:firmalife:firmalife/jar)Empty Jar$() on a hive that visibly has honey gives you a $(thing)Honey Jar$(). Opening a Honey Jar gives you $(thing)Raw Honey$(), a $(thing)Sugar$() substitute.'),
crafting('firmalife:crafting/scrape_beehive_frame', text_contents='Crafting a filled frame with a $(thing)Knife$() gives you $(thing)Beeswax$(), which has many uses. However, this kills the queen inside the frame so be careful!'),
text('Pressing $(item)$(k:key.use)$() a filled frame in your inventory with a $(thing)Knife$() gives you $(thing)Beeswax$(), which has many uses. However, this kills the queen inside the frame so be careful!'),
crafting('firmalife:crafting/treated_lumber', text_contents='The most important use of beeswax is in creating $(thing)Treated Lumber$().'),
text('$(li)Bees can help fertilize planters!$()$(li)Scraping a frame sacrifices the queen. Be smart!$()$(li)Being wet prevents bees from attacking you.$()', 'Bee Tips'),
text('$(li)$(thing)Hardiness$(): Allows bees to produce honey at lower temperatures. Hardiness 10 allows up to -16°C, whereas Hardiness 1 allows up to 2°C.$()$(li)$(thing)Production$(): Improves the speed of honey production.$()$(li)$(thing)Mutant$(): Increases variability in the traits passed during breeding$().', 'List of Abilities'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class FLBlockEntities
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<FoodShelfBlockEntity>> FOOD_SHELF = register("food_shelf", FoodShelfBlockEntity::new, Stream.of(FLBlocks.FOOD_SHELVES.values()).<Supplier<? extends Block>>flatMap(Helpers::flatten));
public static final RegistryObject<BlockEntityType<HangerBlockEntity>> HANGER = register("food_shelf", HangerBlockEntity::new, Stream.of(FLBlocks.HANGERS.values()).<Supplier<? extends Block>>flatMap(Helpers::flatten));
public static final RegistryObject<BlockEntityType<HangerBlockEntity>> HANGER = register("hanger", HangerBlockEntity::new, Stream.of(FLBlocks.HANGERS.values()).<Supplier<? extends Block>>flatMap(Helpers::flatten));

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
Expand Up @@ -47,6 +47,11 @@ public void saveAdditional(CompoundTag nbt)
nbt.putBoolean("climateValid", climateValid);
}

public boolean isClimateValid()
{
return climateValid;
}

@Override
public void onLoad()
{
Expand All @@ -67,7 +72,9 @@ public boolean isItemValid(int slot, ItemStack stack)
final ItemStack current = inventory.getStackInSlot(slot);
if (!current.isEmpty())
{
return Helpers.isItem(stack, current.getItem());
ItemStack currentWithoutTrait = current.copy();
FoodCapability.removeTrait(currentWithoutTrait, getFoodTrait());
return FoodCapability.areStacksStackableExceptCreationDate(stack, currentWithoutTrait);
}
return stack.getCapability(FoodCapability.CAPABILITY).isPresent();
}
Expand All @@ -82,13 +89,20 @@ public InteractionResult use(Player player, InteractionHand hand)
assert level != null;
var res = InteractionResult.PASS;
final ItemStack held = player.getItemInHand(hand);
if (!held.isEmpty())
if (!held.isEmpty() && isItemValid(0, held))
{
res = FLHelpers.insertOne(level, held, 0, inventory, player);
if (climateValid)
{
FoodCapability.applyTrait(held, getFoodTrait());
}
player.setItemInHand(hand, Helpers.mergeInsertStack(inventory, 0, held));

FoodCapability.removeTrait(player.getItemInHand(hand), getFoodTrait());
res = InteractionResult.sidedSuccess(level.isClientSide);
}
else if (player.isShiftKeyDown())
{
ItemStack stack = inventory.extractItem(0, 1, false);
ItemStack stack = inventory.extractItem(0, Integer.MAX_VALUE, false);
if (stack.isEmpty()) return InteractionResult.PASS;
FoodCapability.removeTrait(stack, getFoodTrait());
ItemHandlerHelper.giveItemToPlayer(player, stack);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package com.eerussianguy.firmalife.common.blockentities;

import net.minecraft.core.BlockPos;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.state.BlockState;

import com.eerussianguy.firmalife.common.FLTags;
import com.eerussianguy.firmalife.common.items.FLFoodTraits;
import net.dries007.tfc.common.capabilities.food.FoodTrait;
import net.dries007.tfc.util.Helpers;

public class HangerBlockEntity extends FoodShelfBlockEntity
{
Expand All @@ -18,4 +21,10 @@ public FoodTrait getFoodTrait()
{
return FLFoodTraits.HUNG;
}

@Override
public boolean isItemValid(int slot, ItemStack stack)
{
return super.isItemValid(slot, stack) && Helpers.isItem(stack, FLTags.Items.CAN_BE_HUNG);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static void init() { }
public static final FoodTrait RANCID_SMOKED = register("rancid_smoked", 2.0f);
public static final FoodTrait RAW = register("raw", 1f);
public static final FoodTrait SHELVED = register("shelved", 0.7f);
public static final FoodTrait HUNG = register("shelved", 0.6f);
public static final FoodTrait HUNG = register("hung", 0.6f);

private static FoodTrait register(String name, float mod)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.eerussianguy.firmalife.common.blocks.*;
import com.eerussianguy.firmalife.common.items.FLFoodTraits;
import com.eerussianguy.firmalife.config.FLConfig;
import net.dries007.tfc.common.capabilities.Capabilities;
import net.dries007.tfc.common.capabilities.food.FoodCapability;
import net.dries007.tfc.common.capabilities.food.FoodTrait;
import net.dries007.tfc.common.capabilities.food.IFood;
Expand All @@ -37,6 +38,8 @@ public static void register(BiConsumer<BlockEntityTooltip, Class<? extends Block
r.accept(CHEESE, CheeseWheelBlock.class);
r.accept(OVEN, OvenBottomBlock.class);
r.accept(OVEN, OvenTopBlock.class);
r.accept(SHELF_OR_HANGER, FoodShelfBlock.class);
r.accept(SHELF_OR_HANGER, HangerBlock.class);
}

public static final BlockEntityTooltip DRYING_MAT = (level, state, pos, entity, tooltip) -> {
Expand Down Expand Up @@ -98,6 +101,28 @@ else if (traits != null)
}
};

public static final BlockEntityTooltip SHELF_OR_HANGER = (level, state, pos, entity, tooltip) -> {
if (level.getBlockEntity(pos) instanceof FoodShelfBlockEntity shelf)
{
if (shelf.isClimateValid())
{
tooltip.accept(Helpers.translatable("firmalife.cellar.valid_block"));
}
else
{
tooltip.accept(Helpers.translatable("firmalife.cellar.invalid_block"));
}
shelf.getCapability(Capabilities.ITEM).ifPresent(inv -> {
ItemStack stack = inv.getStackInSlot(0);
stack.getCapability(FoodCapability.CAPABILITY).ifPresent(food -> {
List<Component> foodTooltip = new ArrayList<>();
food.addTooltipInfo(stack, foodTooltip);
foodTooltip.forEach(tooltip);
});
});
}
};

public static final BlockEntityTooltip OVEN = (level, state, pos, entity, tooltip) -> {
if (entity instanceof OvenLike oven)
{
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/assets/firmalife/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -424,12 +424,16 @@
"firmalife.tooltip.food_trait.vintage": "Vintage",
"firmalife.tooltip.food_trait.fresh": "Fresh",
"firmalife.tooltip.food_trait.oven_baked": "Oven Baked",
"firmalife.tooltip.food_trait.hung": "Hung in a Cellar",
"firmalife.tooltip.food_trait.shelved": "On a Cellar Shelf",
"firmalife.tooltip.food_trait.smoked": "Smoked",
"firmalife.tooltip.food_trait.rancid_smoked": "Rancid Smoked",
"firmalife.tooltip.food_trait.raw": "Raw (INEDIBLE)",
"firmalife.tooltip.seed_ball": "Throw me!",
"firmalife.tooltip.seed_ball_disabled": "This server has disabled seed balls!",
"firmalife.cellar.found": "Found a cellar of %s blocks",
"firmalife.cellar.valid_block": "In a valid cellar",
"firmalife.cellar.invalid_block": "Invalid cellar",
"firmalife.greenhouse.valid_block": "§aGrowing",
"firmalife.greenhouse.invalid_block": "§cNot Growing",
"firmalife.greenhouse.no_sky": "There is not enough sky light to grow",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"__comment__": "This file was automatically created by mcresources",
"parent": "firmalife:block/food_shelf_base",
"textures": {
"wood": "tfc:block/wood/planks/acacia",
"string": "minecraft:block/white_wool"
"wood": "tfc:block/wood/planks/acacia"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"__comment__": "This file was automatically created by mcresources",
"parent": "firmalife:block/food_shelf_base",
"textures": {
"wood": "tfc:block/wood/planks/ash",
"string": "minecraft:block/white_wool"
"wood": "tfc:block/wood/planks/ash"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"__comment__": "This file was automatically created by mcresources",
"parent": "firmalife:block/food_shelf_base",
"textures": {
"wood": "tfc:block/wood/planks/aspen",
"string": "minecraft:block/white_wool"
"wood": "tfc:block/wood/planks/aspen"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"__comment__": "This file was automatically created by mcresources",
"parent": "firmalife:block/food_shelf_base",
"textures": {
"wood": "tfc:block/wood/planks/birch",
"string": "minecraft:block/white_wool"
"wood": "tfc:block/wood/planks/birch"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"__comment__": "This file was automatically created by mcresources",
"parent": "firmalife:block/food_shelf_base",
"textures": {
"wood": "tfc:block/wood/planks/blackwood",
"string": "minecraft:block/white_wool"
"wood": "tfc:block/wood/planks/blackwood"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"__comment__": "This file was automatically created by mcresources",
"parent": "firmalife:block/food_shelf_base",
"textures": {
"wood": "tfc:block/wood/planks/chestnut",
"string": "minecraft:block/white_wool"
"wood": "tfc:block/wood/planks/chestnut"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"__comment__": "This file was automatically created by mcresources",
"parent": "firmalife:block/food_shelf_base",
"textures": {
"wood": "tfc:block/wood/planks/douglas_fir",
"string": "minecraft:block/white_wool"
"wood": "tfc:block/wood/planks/douglas_fir"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"__comment__": "This file was automatically created by mcresources",
"parent": "firmalife:block/food_shelf_base",
"textures": {
"wood": "tfc:block/wood/planks/hickory",
"string": "minecraft:block/white_wool"
"wood": "tfc:block/wood/planks/hickory"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"__comment__": "This file was automatically created by mcresources",
"parent": "firmalife:block/food_shelf_base",
"textures": {
"wood": "tfc:block/wood/planks/kapok",
"string": "minecraft:block/white_wool"
"wood": "tfc:block/wood/planks/kapok"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"__comment__": "This file was automatically created by mcresources",
"parent": "firmalife:block/food_shelf_base",
"textures": {
"wood": "tfc:block/wood/planks/maple",
"string": "minecraft:block/white_wool"
"wood": "tfc:block/wood/planks/maple"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"__comment__": "This file was automatically created by mcresources",
"parent": "firmalife:block/food_shelf_base",
"textures": {
"wood": "tfc:block/wood/planks/oak",
"string": "minecraft:block/white_wool"
"wood": "tfc:block/wood/planks/oak"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"__comment__": "This file was automatically created by mcresources",
"parent": "firmalife:block/food_shelf_base",
"textures": {
"wood": "tfc:block/wood/planks/palm",
"string": "minecraft:block/white_wool"
"wood": "tfc:block/wood/planks/palm"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"__comment__": "This file was automatically created by mcresources",
"parent": "firmalife:block/food_shelf_base",
"textures": {
"wood": "tfc:block/wood/planks/pine",
"string": "minecraft:block/white_wool"
"wood": "tfc:block/wood/planks/pine"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"__comment__": "This file was automatically created by mcresources",
"parent": "firmalife:block/food_shelf_base",
"textures": {
"wood": "tfc:block/wood/planks/rosewood",
"string": "minecraft:block/white_wool"
"wood": "tfc:block/wood/planks/rosewood"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"__comment__": "This file was automatically created by mcresources",
"parent": "firmalife:block/food_shelf_base",
"textures": {
"wood": "tfc:block/wood/planks/sequoia",
"string": "minecraft:block/white_wool"
"wood": "tfc:block/wood/planks/sequoia"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"__comment__": "This file was automatically created by mcresources",
"parent": "firmalife:block/food_shelf_base",
"textures": {
"wood": "tfc:block/wood/planks/spruce",
"string": "minecraft:block/white_wool"
"wood": "tfc:block/wood/planks/spruce"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"__comment__": "This file was automatically created by mcresources",
"parent": "firmalife:block/food_shelf_base",
"textures": {
"wood": "tfc:block/wood/planks/sycamore",
"string": "minecraft:block/white_wool"
"wood": "tfc:block/wood/planks/sycamore"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"__comment__": "This file was automatically created by mcresources",
"parent": "firmalife:block/food_shelf_base",
"textures": {
"wood": "tfc:block/wood/planks/white_cedar",
"string": "minecraft:block/white_wool"
"wood": "tfc:block/wood/planks/white_cedar"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"__comment__": "This file was automatically created by mcresources",
"parent": "firmalife:block/food_shelf_base",
"textures": {
"wood": "tfc:block/wood/planks/willow",
"string": "minecraft:block/white_wool"
"wood": "tfc:block/wood/planks/willow"
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"__comment__": "This file was automatically created by mcresources",
"parent": "firmalife:block/food_shelf_base",
"parent": "firmalife:block/hanger_base",
"textures": {
"wood": "tfc:block/wood/planks/acacia"
"wood": "tfc:block/wood/planks/acacia",
"string": "minecraft:block/white_wool"
}
}
Loading

0 comments on commit a4daeb3

Please sign in to comment.