Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for fluid tanks in feeding slabs #625

Open
wants to merge 1 commit into
base: dev-1.21.0
Choose a base branch
from

Conversation

kirjorjos
Copy link

Add the ability for fluid tanks and buckets to work in a feeding slab for bees that need a fluid to pollinate

} else {
IFluidHandler stackFluidTank = stack.getCapability(Capabilities.FluidHandler.ITEM);
if (stackFluidTank != null && stackFluidTank.getFluidInTank(0).getAmount() >= ProductiveBeesConfig.BEES.minimumMbForFlowering.get()) {
possibleBlocks.add(stackFluidTank.getFluidInTank(0).getFluid().defaultFluidState().createLegacyBlock().getBlock());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about fluids that don't have blocks?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Afaik, there's no way for fluids without blocks to be used right now so it would be consistent with the current behavior, but if I'm wrong or you want it to work for fluids without blocks, I would need to modify the call to be TagKey<Item> tag rather than TagKey<Block> tag which I'm fine doing, I was just trying not to change the existing code too much.

@@ -428,7 +431,7 @@ public boolean isFlowerBlock(BlockState flowerBlock) {
return flowerBlock.is(flowerTag);
} else if (nbt.contains("flowerBlock")) {
return BuiltInRegistries.BLOCK.getKey(flowerBlock.getBlock()).toString().equals(nbt.getString("flowerBlock"));
} else if (nbt.contains("flowerFluid") && !flowerBlock.getFluidState().isEmpty()) {
} else if (nbt.contains("flowerFluid") && (!flowerBlock.getFluidState().isEmpty())) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does that change anything?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I as looking at supporting tanks placed in world as valid flowers, but realized it might be beyond the scope of this PR and deleted most of what I had, but looking at this, I did forget to delete this and only noticed it after pushing to github, I figured it was fine since it didn't change any behavior, however, I will revert it on my next push.

if (nbt.contains("flowerFluid")) {
IFluidHandler flowerFluid = flowerItem.getCapability(Capabilities.FluidHandler.ITEM);
if (flowerFluid != null && flowerFluid.getFluidInTank(0).getAmount() >= ProductiveBeesConfig.BEES.minimumMbForFlowering.get()) {
return flowerFluid.getFluidInTank(0).is(BuiltInRegistries.FLUID.get(ResourceLocation.parse(nbt.getString("flowerFluid"))));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about when "flowerFluid" is a tag

@@ -561,6 +563,10 @@ public boolean isFlowerItem(ItemStack flowerItem) {
if (flowerItem.getItem() instanceof BlockItem blockItem && isFlowerBlock(blockItem.getBlock().defaultBlockState())) {
return true;
}
IFluidHandler flowerFluid = flowerItem.getCapability(Capabilities.FluidHandler.ITEM);
if (flowerFluid != null && flowerFluid.getFluidInTank(0).getAmount() >= ProductiveBeesConfig.BEES.minimumMbForFlowering.get()) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's only a check for the amount here, what about the fluid type?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was basing it mainly off the existing flower block system which uses the DEFAULT_FLOWERING_BLOCK tag, if I did it the same way, we would need to make a DEFAULT_FLOWERING_FLUID tag or have a way to grab the flowering fluid from within the ProductiveBee class. I think if you do want to check for the fluid here, adding the tags would be easier, but I'll work on doing it whichever way you want it done.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't want a default flowering fluid, this here looks like it would enable any bee to flower off of a bucket of water.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought that was checked for else where so I did a test. I'm not really sure how to do a proper test for this tbh, but I did 2 in game tests for half an hour each: both with 2 advanced hives and 4 Omega upgrades, 1 with a lava bucket in a feeding slab, 1 with a water bucket in a feeding slab. I put a water bee in both, and for the first test, just let it run, for the second test, I swapped the water bee to pollinate with lava to test it. Test 1, only the water hive filled with anything, test 2, only the lava hive filled with anything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants