Skip to content

Commit

Permalink
jade/top integration. fix air above tooltip for planters. fix waterin…
Browse files Browse the repository at this point in the history
…g cans (Closes #82). fix sealed bricks loot (Closes #83)
  • Loading branch information
eerussianguy committed Sep 12, 2022
1 parent 5b430d1 commit e26a84d
Show file tree
Hide file tree
Showing 19 changed files with 335 additions and 47 deletions.
13 changes: 13 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@ repositories {
includeGroup "curse.maven"
}
}
maven {
// Jade
url "https://www.cursemaven.com"
content {
includeGroup "curse.maven"
}
}

flatDir {
dir 'libs'
Expand All @@ -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}")
Expand Down
4 changes: 3 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
tfc_identifier=3975434
jade_version=3970956
top_version=3965688
2 changes: 1 addition & 1 deletion resources/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 7 additions & 1 deletion resources/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ',
Expand Down Expand Up @@ -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.',
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/com/eerussianguy/firmalife/FirmaLife.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand Down Expand Up @@ -57,6 +61,7 @@ public FirmaLife()
FLPackets.init();

bus.addListener(this::setup);
bus.addListener(this::onInterModComms);

FLConfig.init();
FLEvents.init();
Expand All @@ -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);
}
}

}
10 changes: 5 additions & 5 deletions src/main/java/com/eerussianguy/firmalife/common/FLHelpers.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
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;

import com.eerussianguy.firmalife.FirmaLife;
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;
Expand Down Expand Up @@ -63,13 +63,13 @@ public static Component blockEntityName(String name)

public static <T extends BlockEntity> void readInventory(Level level, BlockPos pos, Supplier<BlockEntityType<T>> type, BiConsumer<T, IItemHandler> 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 <T extends BlockEntity> InteractionResult consumeInventory(Level level, BlockPos pos, Supplier<BlockEntityType<T>> type, BiFunction<T, IItemHandler, InteractionResult> 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);
}

Expand All @@ -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)
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<DryingRecipe>
{
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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -109,6 +109,7 @@ public long getLastGrowthTick()
public void setLastGrowthTick(long lastGrowthTick)
{
this.lastGrowthTick = lastGrowthTick;
markForSync();
}

@Override
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<SmokingRecipe>
{
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
{
Expand All @@ -54,18 +52,17 @@ 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();
}
}
});
}
}
}

long remainingTicks = mat.getDuration() - (Calendars.SERVER.getTicks() - mat.startTick);
if (remainingTicks <= 0)
if (string.getTicksLeft() <= 0)
{
mat.finish();
string.finish();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<CompoundTag>
{
void setHasQueen(boolean exists);
Expand Down Expand Up @@ -71,13 +73,13 @@ default void addTooltipInfo(List<Component> 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));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
Loading

0 comments on commit e26a84d

Please sign in to comment.