diff --git a/build.gradle b/build.gradle index 495678ad..7c3e308b 100644 --- a/build.gradle +++ b/build.gradle @@ -124,6 +124,13 @@ repositories { includeGroup "curse.maven" } } + maven { + // Jade + url "https://www.cursemaven.com" + content { + includeGroup "curse.maven" + } + } flatDir { dir 'libs' @@ -142,6 +149,12 @@ dependencies { // Patchouli implementation fg.deobf("vazkii.patchouli:Patchouli:${patchouli_version}") + // Jade + compileOnly fg.deobf("curse.maven:jade-324717:${jade_version}") + runtimeOnly fg.deobf("curse.maven:jade-324717:${jade_version}") + compileOnly fg.deobf("curse.maven:top-245211:${top_version}") + //runtimeOnly fg.deobf("curse.maven:top-245211:${top_version}") + // JEI compileOnly fg.deobf("mezz.jei:jei-${minecraft_version}:${jei_version}:api") runtimeOnly fg.deobf("mezz.jei:jei-${minecraft_version}:${jei_version}") diff --git a/gradle.properties b/gradle.properties index 2c0a7f78..6f9201fc 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,4 +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=3975434 \ No newline at end of file +tfc_identifier=3975434 +jade_version=3970956 +top_version=3965688 \ No newline at end of file diff --git a/resources/assets.py b/resources/assets.py index 5781ca30..c35e5627 100644 --- a/resources/assets.py +++ b/resources/assets.py @@ -152,7 +152,7 @@ def generate(rm: ResourceManager): make_jar(rm, fruit, 'firmalife:block/jar/%s' % fruit).with_tag('foods/preserves') for block, tag in SIMPLE_BLOCKS.items(): - rm.blockstate(block).with_block_model().with_tag(tag).with_lang(lang(block)).with_item_model() + rm.blockstate(block).with_block_model().with_tag(tag).with_lang(lang(block)).with_item_model().with_block_loot('firmalife:%s' % block) for item in SIMPLE_ITEMS: rm.item_model(item).with_lang(lang(item)) for item in SIMPLE_FOODS: diff --git a/resources/constants.py b/resources/constants.py index 0760174d..c676a783 100644 --- a/resources/constants.py +++ b/resources/constants.py @@ -132,7 +132,7 @@ def preset_vein(ore: str, vein_type: str, rocks: List[str], spoiler_ore: Optiona 'firmalife.greenhouse.error_unknown': 'Unknown reason for failure to grow', 'firmalife.greenhouse.no_sky': 'There is not enough sky light to grow', 'firmalife.greenhouse.climate_invalid': 'This block is not in a valid greenhouse. Try clicking your climate station.', - 'firmalife.greenhouse.air_above': 'Planters need an air block above them to work', + 'firmalife.greenhouse.air_needed': 'Planters need a block of air to grow into.', 'firmalife.greenhouse.dehydrated': 'This planter needs to be watered with a Watering Can', 'firmalife.greenhouse.wrong_tier': 'To grow this crop, upgrade to a better greenhouse', 'firmalife.greenhouse.wrong_type': 'This crop does not grow in this planter. It grows in a ', @@ -166,6 +166,12 @@ def preset_vein(ore: str, vein_type: str, rocks: List[str], spoiler_ore: Optiona 'firmalife.enum.plantertype.quad': 'Quad Planter', 'firmalife.enum.plantertype.large': 'Large Planter', + 'firmalife.jade.food_age': 'Age: %s', + 'firmalife.jade.aging': 'Currently Aging', + 'firmalife.jade.not_aging': 'Not Aging', + 'firmalife.jade.slices': 'Slices: %s', + 'firmalife.jade.cure_time_left': 'Curing Time Left: %s', + 'death.attack.firmalife.oven': '%1$s died by sticking their hand in a hot oven.', 'death.attack.firmalife.oven.player': '%1$s climbed into an oven to escape %2$s.', 'death.attack.firmalife.swarm': '%1$s was stung to death by bees.', diff --git a/src/main/java/com/eerussianguy/firmalife/FirmaLife.java b/src/main/java/com/eerussianguy/firmalife/FirmaLife.java index 3d721d3a..a349cc55 100644 --- a/src/main/java/com/eerussianguy/firmalife/FirmaLife.java +++ b/src/main/java/com/eerussianguy/firmalife/FirmaLife.java @@ -2,8 +2,11 @@ import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.eventbus.api.IEventBus; +import net.minecraftforge.fml.InterModComms; +import net.minecraftforge.fml.ModList; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; +import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.fml.loading.FMLEnvironment; @@ -28,6 +31,7 @@ import com.eerussianguy.firmalife.common.recipes.data.FLIngredients; import com.eerussianguy.firmalife.common.recipes.data.FLItemStackModifiers; import com.eerussianguy.firmalife.compat.patchouli.FLPatchouliIntegration; +import com.eerussianguy.firmalife.compat.tooltip.TheOneProbeIntegration; import com.eerussianguy.firmalife.config.FLConfig; import com.mojang.logging.LogUtils; import net.dries007.tfc.config.TFCConfig; @@ -57,6 +61,7 @@ public FirmaLife() FLPackets.init(); bus.addListener(this::setup); + bus.addListener(this::onInterModComms); FLConfig.init(); FLEvents.init(); @@ -82,4 +87,12 @@ public void setup(FMLCommonSetupEvent event) FLPatchouliIntegration.registerMultiBlocks(); } + public void onInterModComms(InterModEnqueueEvent event) + { + if (ModList.get().isLoaded("theoneprobe")) + { + InterModComms.sendTo("theoneprobe", "getTheOneProbe", TheOneProbeIntegration::new); + } + } + } diff --git a/src/main/java/com/eerussianguy/firmalife/common/FLHelpers.java b/src/main/java/com/eerussianguy/firmalife/common/FLHelpers.java index 31fcf53b..88a49079 100644 --- a/src/main/java/com/eerussianguy/firmalife/common/FLHelpers.java +++ b/src/main/java/com/eerussianguy/firmalife/common/FLHelpers.java @@ -20,7 +20,6 @@ import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraftforge.common.capabilities.ICapabilityProvider; -import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.ItemHandlerHelper; @@ -28,6 +27,7 @@ import com.mojang.serialization.Codec; import com.mojang.serialization.JsonOps; import net.dries007.tfc.common.blockentities.TickCounterBlockEntity; +import net.dries007.tfc.common.capabilities.Capabilities; import net.dries007.tfc.util.Helpers; import static com.eerussianguy.firmalife.FirmaLife.MOD_ID; @@ -63,13 +63,13 @@ public static Component blockEntityName(String name) public static void readInventory(Level level, BlockPos pos, Supplier> type, BiConsumer consumer) { - level.getBlockEntity(pos, type.get()).ifPresent(be -> be.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).ifPresent(inv -> consumer.accept(be, inv))); + level.getBlockEntity(pos, type.get()).ifPresent(be -> be.getCapability(Capabilities.ITEM).ifPresent(inv -> consumer.accept(be, inv))); } public static InteractionResult consumeInventory(Level level, BlockPos pos, Supplier> type, BiFunction consumer) { return level.getBlockEntity(pos, type.get()).map(be -> - be.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).map(inv -> consumer.apply(be, inv)).orElse(InteractionResult.PASS) + be.getCapability(Capabilities.ITEM).map(inv -> consumer.apply(be, inv)).orElse(InteractionResult.PASS) ).orElse(InteractionResult.PASS); } @@ -89,7 +89,7 @@ public static InteractionResult takeOne(Level level, int slot, IItemHandler inv, public static InteractionResult insertOneAny(Level level, ItemStack item, int start, int end, ICapabilityProvider provider, Player player) { - return provider.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).map(inv -> insertOneAny(level, item, start, end, inv, player)).orElse(InteractionResult.PASS); + return provider.getCapability(Capabilities.ITEM).map(inv -> insertOneAny(level, item, start, end, inv, player)).orElse(InteractionResult.PASS); } public static InteractionResult insertOneAny(Level level, ItemStack item, int start, int end, IItemHandler inv, Player player) @@ -114,7 +114,7 @@ private static InteractionResult completeInsertion(Level level, ItemStack item, public static InteractionResult takeOneAny(Level level, int start, int end, ICapabilityProvider provider, Player player) { - return provider.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).map(inv -> takeOneAny(level, start, end, inv, player)).orElse(InteractionResult.PASS); + return provider.getCapability(Capabilities.ITEM).map(inv -> takeOneAny(level, start, end, inv, player)).orElse(InteractionResult.PASS); } public static InteractionResult takeOneAny(Level level, int start, int end, IItemHandler inv, Player player) diff --git a/src/main/java/com/eerussianguy/firmalife/common/blockentities/DryingMatBlockEntity.java b/src/main/java/com/eerussianguy/firmalife/common/blockentities/DryingMatBlockEntity.java index 1ddb73c3..b0c5e509 100644 --- a/src/main/java/com/eerussianguy/firmalife/common/blockentities/DryingMatBlockEntity.java +++ b/src/main/java/com/eerussianguy/firmalife/common/blockentities/DryingMatBlockEntity.java @@ -9,31 +9,24 @@ import com.eerussianguy.firmalife.common.recipes.DryingRecipe; import com.eerussianguy.firmalife.config.FLConfig; import net.dries007.tfc.common.recipes.inventory.ItemStackInventory; -import net.dries007.tfc.util.calendar.Calendars; -import net.dries007.tfc.util.calendar.ICalendar; public class DryingMatBlockEntity extends SimpleItemRecipeBlockEntity { public static void serverTick(Level level, BlockPos pos, BlockState state, DryingMatBlockEntity mat) { // reset when it rains - if (level.getGameTime() % 40 == 0 && level.isRainingAt(pos.above())) + if (level.getGameTime() % 60 == 0 && level.isRainingAt(pos.above())) { - mat.startTick = Calendars.SERVER.getTicks(); + mat.resetCounter(); } if (mat.cachedRecipe != null) { - long remainingTicks = mat.getDuration() - (Calendars.SERVER.getTicks() - mat.startTick); - if (remainingTicks <= 0) + if (mat.getTicksLeft() <= 0) { mat.finish(); } } - else - { - mat.startTick = Calendars.SERVER.getTicks(); - } } public DryingMatBlockEntity(BlockPos pos, BlockState state) diff --git a/src/main/java/com/eerussianguy/firmalife/common/blockentities/LargePlanterBlockEntity.java b/src/main/java/com/eerussianguy/firmalife/common/blockentities/LargePlanterBlockEntity.java index 5670b171..a0d5929c 100644 --- a/src/main/java/com/eerussianguy/firmalife/common/blockentities/LargePlanterBlockEntity.java +++ b/src/main/java/com/eerussianguy/firmalife/common/blockentities/LargePlanterBlockEntity.java @@ -4,7 +4,6 @@ import net.minecraft.core.Direction; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.util.Mth; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; @@ -20,6 +19,7 @@ import net.dries007.tfc.common.blockentities.FarmlandBlockEntity; import net.dries007.tfc.common.blockentities.TickableInventoryBlockEntity; import net.dries007.tfc.util.Fertilizer; +import net.dries007.tfc.util.Helpers; import net.dries007.tfc.util.calendar.Calendars; import net.dries007.tfc.util.calendar.ICalendarTickable; import org.jetbrains.annotations.Nullable; @@ -109,6 +109,7 @@ public long getLastGrowthTick() public void setLastGrowthTick(long lastGrowthTick) { this.lastGrowthTick = lastGrowthTick; + markForSync(); } @Override @@ -181,7 +182,7 @@ public boolean checkValid() if (dir != null) { BlockPos offset = worldPosition.relative(dir); - if (!(skylightValid(offset) && level.getBlockState(offset).isAir())) + if (skylightValid(offset) || level.getBlockState(offset).isAir()) { return false; } @@ -216,15 +217,15 @@ else if (level.getBrightness(LightLayer.SKY, worldPosition.relative(Direction.UP { complaint = "no_sky"; } - else if (!level.getBlockState(worldPosition.above()).isAir()) + else if (airFindOffset() != null && !level.getBlockState(worldPosition.relative(airFindOffset())).isAir()) { - complaint = "air_above"; + complaint = "air_needed"; } else if (water <= 0) { complaint = "dehydrated"; } - return new TranslatableComponent("firmalife.greenhouse." + complaint); + return Helpers.translatable("firmalife.greenhouse." + complaint); } @Nullable diff --git a/src/main/java/com/eerussianguy/firmalife/common/blockentities/OvenBottomBlockEntity.java b/src/main/java/com/eerussianguy/firmalife/common/blockentities/OvenBottomBlockEntity.java index 0e078a4a..47ab27c0 100644 --- a/src/main/java/com/eerussianguy/firmalife/common/blockentities/OvenBottomBlockEntity.java +++ b/src/main/java/com/eerussianguy/firmalife/common/blockentities/OvenBottomBlockEntity.java @@ -139,6 +139,16 @@ public OvenBottomBlockEntity(BlockPos pos, BlockState state) lastPlayerTick = Calendars.SERVER.getTicks(); } + public float getTemperature() + { + return temperature; + } + + public int getCureTicks() + { + return cureTicks; + } + @Override public void onCalendarUpdate(long ticks) { diff --git a/src/main/java/com/eerussianguy/firmalife/common/blockentities/SimpleItemRecipeBlockEntity.java b/src/main/java/com/eerussianguy/firmalife/common/blockentities/SimpleItemRecipeBlockEntity.java index 06385a13..b46f76e5 100644 --- a/src/main/java/com/eerussianguy/firmalife/common/blockentities/SimpleItemRecipeBlockEntity.java +++ b/src/main/java/com/eerussianguy/firmalife/common/blockentities/SimpleItemRecipeBlockEntity.java @@ -51,6 +51,12 @@ public int getSlotStackLimit(int slot) abstract void updateCache(); + public long getTicksLeft() + { + assert level != null; + return getDuration() - (Calendars.get(level).getTicks() - startTick); + } + public void start() { assert level != null; @@ -78,14 +84,11 @@ public void finish() } } - public ItemStack insert(ItemStack item) + public void resetCounter() { - return inventory.insertItem(0, item, false); - } - - public ItemStack extract() - { - return inventory.extractItem(0, 1, false); + assert level != null; + startTick = Calendars.get(level).getTicks(); + markForSync(); } public ItemStack readStack() diff --git a/src/main/java/com/eerussianguy/firmalife/common/blockentities/StringBlockEntity.java b/src/main/java/com/eerussianguy/firmalife/common/blockentities/StringBlockEntity.java index ecd4226d..c0d05f07 100644 --- a/src/main/java/com/eerussianguy/firmalife/common/blockentities/StringBlockEntity.java +++ b/src/main/java/com/eerussianguy/firmalife/common/blockentities/StringBlockEntity.java @@ -18,31 +18,29 @@ import net.dries007.tfc.common.capabilities.food.FoodCapability; import net.dries007.tfc.common.recipes.inventory.ItemStackInventory; import net.dries007.tfc.util.Helpers; -import net.dries007.tfc.util.calendar.Calendars; -import net.dries007.tfc.util.calendar.ICalendar; public class StringBlockEntity extends SimpleItemRecipeBlockEntity { - public static void serverTick(Level level, BlockPos pos, BlockState state, StringBlockEntity mat) + public static void serverTick(Level level, BlockPos pos, BlockState state, StringBlockEntity string) { if (level.getGameTime() % 40 == 0) { - if (mat.cachedRecipe == null) + if (string.cachedRecipe == null) { - mat.startTick = Calendars.SERVER.getTicks(); + string.resetCounter(); return; } FirepitBlockEntity firepit = StringBlock.findFirepit(level, pos); if (firepit == null) { - mat.startTick = Calendars.SERVER.getTicks(); + string.resetCounter(); } else { BlockState pitState = level.getBlockState(pos); if (pitState.hasProperty(FirepitBlock.LIT) && !pitState.getValue(FirepitBlock.LIT)) { - mat.startTick = Calendars.SERVER.getTicks(); + string.resetCounter(); } else { @@ -54,7 +52,7 @@ public static void serverTick(Level level, BlockPos pos, BlockState state, Strin if (!item.isEmpty() && !Helpers.isItem(item, FLTags.Items.SMOKING_FUEL)) { FoodCapability.applyTrait(item, FLFoodTraits.RANCID_SMOKED); - mat.startTick = Calendars.SERVER.getTicks(); + string.resetCounter(); } } }); @@ -62,10 +60,9 @@ public static void serverTick(Level level, BlockPos pos, BlockState state, Strin } } - long remainingTicks = mat.getDuration() - (Calendars.SERVER.getTicks() - mat.startTick); - if (remainingTicks <= 0) + if (string.getTicksLeft() <= 0) { - mat.finish(); + string.finish(); } } diff --git a/src/main/java/com/eerussianguy/firmalife/common/capabilities/bee/IBee.java b/src/main/java/com/eerussianguy/firmalife/common/capabilities/bee/IBee.java index eac15c47..9135e973 100644 --- a/src/main/java/com/eerussianguy/firmalife/common/capabilities/bee/IBee.java +++ b/src/main/java/com/eerussianguy/firmalife/common/capabilities/bee/IBee.java @@ -10,6 +10,8 @@ import net.minecraft.util.Mth; import net.minecraftforge.common.util.INBTSerializable; +import net.dries007.tfc.util.Helpers; + public interface IBee extends INBTSerializable { void setHasQueen(boolean exists); @@ -71,13 +73,13 @@ default void addTooltipInfo(List tooltip) if (hasQueen()) { tooltip.add(new TranslatableComponent("firmalife.bee.queen").withStyle(ChatFormatting.GOLD)); - tooltip.add(new TranslatableComponent("firmalife.bee.abilities").withStyle(ChatFormatting.WHITE)); + tooltip.add(Helpers.translatable("firmalife.bee.abilities").withStyle(ChatFormatting.WHITE)); for (BeeAbility ability : BeeAbility.VALUES) { final int amount = getAbility(ability); if (amount > 0) { - tooltip.add(new TranslatableComponent("firmalife.bee.ability." + ability.getSerializedName(), String.valueOf(amount)).withStyle(ChatFormatting.GRAY)); + tooltip.add(Helpers.translatable("firmalife.bee.ability." + ability.getSerializedName(), String.valueOf(amount)).withStyle(ChatFormatting.GRAY)); } } } diff --git a/src/main/java/com/eerussianguy/firmalife/common/items/WateringCanItem.java b/src/main/java/com/eerussianguy/firmalife/common/items/WateringCanItem.java index 4709b7cd..7d6d05e6 100644 --- a/src/main/java/com/eerussianguy/firmalife/common/items/WateringCanItem.java +++ b/src/main/java/com/eerussianguy/firmalife/common/items/WateringCanItem.java @@ -60,17 +60,17 @@ public void releaseUsing(ItemStack stack, Level level, LivingEntity entity, int @Override public InteractionResult useOn(UseOnContext context) { + ItemStack item = context.getItemInHand(); if (context.getLevel().getFluidState(context.getClickedPos().relative(context.getClickedFace())).getType().isSame(Fluids.WATER)) { - ItemStack item = context.getItemInHand(); if (item.isDamaged()) { - item.setDamageValue(getMaxDamage(item)); + item.setDamageValue(0); return InteractionResult.SUCCESS; } return InteractionResult.PASS; } - else if (context.getPlayer() != null) + else if (context.getPlayer() != null && item.getDamageValue() < item.getMaxDamage() - 1) { context.getPlayer().startUsingItem(context.getHand()); } diff --git a/src/main/java/com/eerussianguy/firmalife/compat/tooltip/FLTooltips.java b/src/main/java/com/eerussianguy/firmalife/compat/tooltip/FLTooltips.java new file mode 100644 index 00000000..85f09e00 --- /dev/null +++ b/src/main/java/com/eerussianguy/firmalife/compat/tooltip/FLTooltips.java @@ -0,0 +1,111 @@ +package com.eerussianguy.firmalife.compat.tooltip; + +import java.util.function.BiConsumer; + +import net.minecraft.network.chat.MutableComponent; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.Block; + +import com.eerussianguy.firmalife.common.FLHelpers; +import com.eerussianguy.firmalife.common.blockentities.*; +import com.eerussianguy.firmalife.common.blocks.*; +import com.eerussianguy.firmalife.common.blocks.greenhouse.LargePlanterBlock; +import net.dries007.tfc.compat.jade.common.BlockEntityTooltip; +import net.dries007.tfc.compat.jade.common.BlockEntityTooltips; +import net.dries007.tfc.compat.jade.common.EntityTooltip; +import net.dries007.tfc.util.Helpers; +import net.dries007.tfc.util.calendar.Calendars; + +public final class FLTooltips +{ + public static final class BlockEntities + { + public static void register(BiConsumer> r) + { + r.accept(PLANTERS, LargePlanterBlock.class); + r.accept(BEEHIVE, FLBeehiveBlock.class); + r.accept(DRYING_MAT, DryingMatBlock.class); + r.accept(STRING, StringBlock.class); + r.accept(CHEESE, CheeseWheelBlock.class); + r.accept(OVEN_BOTTOM, OvenBottomBlock.class); + r.accept(OVEN_TOP, OvenTopBlock.class); + } + + public static final BlockEntityTooltip PLANTERS = (level, state, pos, entity, tooltip) -> { + if (state.getBlock() instanceof LargePlanterBlock block && entity instanceof LargePlanterBlockEntity planter) + { + BlockEntityTooltips.hoeOverlay(level, block, planter, tooltip); + } + }; + + public static final BlockEntityTooltip BEEHIVE = (level, state, pos, entity, tooltip) -> { + if (state.getBlock() instanceof FLBeehiveBlock block && entity instanceof FLBeehiveBlockEntity hive) + { + BlockEntityTooltips.hoeOverlay(level, block, hive, tooltip); + } + }; + + public static final BlockEntityTooltip DRYING_MAT = (level, state, pos, entity, tooltip) -> { + if (state.getBlock() instanceof DryingMatBlock block && entity instanceof DryingMatBlockEntity mat) + { + tooltip.accept(Helpers.translatable("tfc.jade.time_left", delta(level, mat.getTicksLeft()))); + } + }; + + public static final BlockEntityTooltip STRING = (level, state, pos, entity, tooltip) -> { + if (state.getBlock() instanceof StringBlock block && entity instanceof StringBlockEntity mat) + { + tooltip.accept(Helpers.translatable("tfc.jade.time_left", delta(level, mat.getTicksLeft()))); + } + }; + + public static final BlockEntityTooltip CHEESE = (level, state, pos, entity, tooltip) -> { + if (state.getBlock() instanceof CheeseWheelBlock block) + { + if (state.getValue(CheeseWheelBlock.AGING)) + { + tooltip.accept(Helpers.translatable("firmalife.jade.aging")); + } + else + { + tooltip.accept(Helpers.translatable("firmalife.jade.not_aging")); + } + tooltip.accept(Helpers.translatable("firmalife.jade.slices", state.getValue(CheeseWheelBlock.COUNT))); + tooltip.accept(Helpers.translatable("firmalife.jade.food_age", FLHelpers.translateEnum(state.getValue(CheeseWheelBlock.AGE)))); + } + }; + + public static final BlockEntityTooltip OVEN_BOTTOM = (level, state, pos, entity, tooltip) -> { + if (state.getBlock() instanceof OvenBottomBlock block && entity instanceof OvenBottomBlockEntity oven) + { + BlockEntityTooltips.heat(tooltip, oven.getTemperature()); + if (state.getBlock() instanceof ICure cure && !cure.isCured()) + { + tooltip.accept(Helpers.translatable("firmalife.jade.cure_time_left", delta(level, OvenBottomBlockEntity.CURE_TICKS - oven.getCureTicks()))); + } + } + }; + + public static final BlockEntityTooltip OVEN_TOP = (level, state, pos, entity, tooltip) -> { + if (state.getBlock() instanceof OvenTopBlock block && entity instanceof OvenTopBlockEntity oven) + { + BlockEntityTooltips.heat(tooltip, oven.getTemperature()); + } + }; + + } + + public static final class Entities + { + public static void register(BiConsumer> r) + { + + } + } + + private static MutableComponent delta(Level level, long ticks) + { + return Calendars.get(level).getTimeDelta(ticks); + } +} diff --git a/src/main/java/com/eerussianguy/firmalife/compat/tooltip/JadeIntegration.java b/src/main/java/com/eerussianguy/firmalife/compat/tooltip/JadeIntegration.java new file mode 100644 index 00000000..9149c6d4 --- /dev/null +++ b/src/main/java/com/eerussianguy/firmalife/compat/tooltip/JadeIntegration.java @@ -0,0 +1,34 @@ +package com.eerussianguy.firmalife.compat.tooltip; + +import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.block.Block; + +import mcp.mobius.waila.api.IWailaClientRegistration; +import mcp.mobius.waila.api.IWailaPlugin; +import mcp.mobius.waila.api.TooltipPosition; +import mcp.mobius.waila.api.WailaPlugin; +import net.dries007.tfc.compat.jade.common.BlockEntityTooltip; +import net.dries007.tfc.compat.jade.common.EntityTooltip; + +@WailaPlugin +@SuppressWarnings("UnstableApiUsage") +public class JadeIntegration implements IWailaPlugin +{ + @Override + public void registerClient(IWailaClientRegistration registry) + { + FLTooltips.BlockEntities.register((tooltip, aClass) -> register(registry, tooltip, aClass)); + FLTooltips.Entities.register((tooltip, aClass) -> register(registry, tooltip, aClass)); + } + + private void register(IWailaClientRegistration registry, BlockEntityTooltip blockEntityTooltip, Class blockClass) + { + registry.registerComponentProvider((tooltip, access, config) -> blockEntityTooltip.display(access.getLevel(), access.getBlockState(), access.getPosition(), access.getBlockEntity(), tooltip::add), TooltipPosition.BODY, blockClass); + } + + private void register(IWailaClientRegistration registry, EntityTooltip entityTooltip, Class entityClass) + { + registry.registerComponentProvider((tooltip, access, config) -> entityTooltip.display(access.getLevel(), access.getEntity(), tooltip::add), TooltipPosition.BODY, entityClass); + } +} + diff --git a/src/main/java/com/eerussianguy/firmalife/compat/tooltip/TheOneProbeIntegration.java b/src/main/java/com/eerussianguy/firmalife/compat/tooltip/TheOneProbeIntegration.java new file mode 100644 index 00000000..15341470 --- /dev/null +++ b/src/main/java/com/eerussianguy/firmalife/compat/tooltip/TheOneProbeIntegration.java @@ -0,0 +1,67 @@ +package com.eerussianguy.firmalife.compat.tooltip; + +import java.util.Locale; +import java.util.function.Function; + +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; + +import com.eerussianguy.firmalife.common.FLHelpers; +import mcjty.theoneprobe.api.*; +import net.dries007.tfc.compat.jade.common.BlockEntityTooltip; +import net.dries007.tfc.compat.jade.common.EntityTooltip; + +public class TheOneProbeIntegration implements Function +{ + @Override + public Void apply(ITheOneProbe registry) + { + FLTooltips.BlockEntities.register((tooltip, aClass) -> register(registry, tooltip, aClass)); + FLTooltips.Entities.register((tooltip, aClass) -> register(registry, tooltip, aClass)); + return null; + } + + private void register(ITheOneProbe top, BlockEntityTooltip tooltip, Class blockClass) + { + top.registerProvider(new IProbeInfoProvider() { + @Override + public ResourceLocation getID() + { + return FLHelpers.identifier(blockClass.getSimpleName().toLowerCase(Locale.ROOT)); + } + + @Override + public void addProbeInfo(ProbeMode probeMode, IProbeInfo info, Player player, Level level, BlockState blockState, IProbeHitData data) + { + if (data.getPos() != null && blockClass.isInstance(blockState.getBlock())) + { + tooltip.display(level, blockState, data.getPos(), level.getBlockEntity(data.getPos()), info::text); + } + } + }); + } + + private void register(ITheOneProbe top, EntityTooltip tooltip, Class entityClass) + { + top.registerEntityProvider(new IProbeInfoEntityProvider() { + @Override + public String getID() + { + return FLHelpers.identifier(entityClass.getSimpleName().toLowerCase(Locale.ROOT)).toString(); + } + + @Override + public void addProbeEntityInfo(ProbeMode probeMode, IProbeInfo info, Player player, Level level, Entity entity, IProbeHitEntityData data) + { + if (entityClass.isInstance(entity)) + { + tooltip.display(level, entity, info::text); + } + } + }); + } +} diff --git a/src/main/java/com/eerussianguy/firmalife/compat/tooltip/package-info.java b/src/main/java/com/eerussianguy/firmalife/compat/tooltip/package-info.java new file mode 100644 index 00000000..a9e12a84 --- /dev/null +++ b/src/main/java/com/eerussianguy/firmalife/compat/tooltip/package-info.java @@ -0,0 +1,15 @@ +/* + * Licensed under the EUPL, Version 1.2. + * You may obtain a copy of the Licence at: + * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12 + */ + +@ParametersAreNonnullByDefault +@MethodsReturnNonnullByDefault +@FieldsAreNonnullByDefault +package com.eerussianguy.firmalife.compat.tooltip; + +import javax.annotation.ParametersAreNonnullByDefault; + +import net.minecraft.FieldsAreNonnullByDefault; +import net.minecraft.MethodsReturnNonnullByDefault; diff --git a/src/main/resources/assets/firmalife/lang/en_us.json b/src/main/resources/assets/firmalife/lang/en_us.json index 8dcf7cc0..ed96dd93 100644 --- a/src/main/resources/assets/firmalife/lang/en_us.json +++ b/src/main/resources/assets/firmalife/lang/en_us.json @@ -334,7 +334,7 @@ "firmalife.greenhouse.error_unknown": "Unknown reason for failure to grow", "firmalife.greenhouse.no_sky": "There is not enough sky light to grow", "firmalife.greenhouse.climate_invalid": "This block is not in a valid greenhouse. Try clicking your climate station.", - "firmalife.greenhouse.air_above": "Planters need an air block above them to work", + "firmalife.greenhouse.air_needed": "Planters need a block of air to grow into.", "firmalife.greenhouse.dehydrated": "This planter needs to be watered with a Watering Can", "firmalife.greenhouse.wrong_tier": "To grow this crop, upgrade to a better greenhouse", "firmalife.greenhouse.wrong_type": "This crop does not grow in this planter. It grows in a ", diff --git a/src/main/resources/data/firmalife/loot_tables/blocks/sealed_bricks.json b/src/main/resources/data/firmalife/loot_tables/blocks/sealed_bricks.json new file mode 100644 index 00000000..e8965393 --- /dev/null +++ b/src/main/resources/data/firmalife/loot_tables/blocks/sealed_bricks.json @@ -0,0 +1,21 @@ +{ + "__comment__": "This file was automatically created by mcresources", + "type": "minecraft:block", + "pools": [ + { + "name": "loot_pool", + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "name": "firmalife:sealed_bricks" + } + ], + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ] + } + ] +} \ No newline at end of file