-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update Botania integration for MC1.18.2
Showing
4 changed files
with
20 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 16 additions & 11 deletions
27
src/main/java/thetadev/constructionwand/containers/handlers/HandlerBotania.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,41 @@ | ||
/* | ||
TODO: Reenable this when Botania gets ported to 1.17 | ||
package thetadev.constructionwand.containers.handlers; | ||
|
||
import net.minecraft.world.level.block.Block; | ||
import net.minecraft.world.entity.player.Player; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraft.world.level.block.Block; | ||
import thetadev.constructionwand.api.IContainerHandler; | ||
import vazkii.botania.api.BotaniaForgeCapabilities; | ||
import vazkii.botania.api.item.IBlockProvider; | ||
|
||
import java.util.Optional; | ||
|
||
public class HandlerBotania implements IContainerHandler | ||
{ | ||
@Override | ||
public boolean matches(Player player, ItemStack itemStack, ItemStack inventoryStack) { | ||
return inventoryStack != null && inventoryStack.getCount() == 1 && inventoryStack.getItem() instanceof IBlockProvider; | ||
return inventoryStack != null && inventoryStack.getCapability(BotaniaForgeCapabilities.BLOCK_PROVIDER).isPresent(); | ||
} | ||
|
||
@Override | ||
public int countItems(Player player, ItemStack itemStack, ItemStack inventoryStack) { | ||
IBlockProvider prov = (IBlockProvider) inventoryStack.getItem(); | ||
int provCount = prov.getBlockCount(player, itemStack, inventoryStack, Block.byItem(itemStack.getItem())); | ||
Optional<IBlockProvider> provOptional = inventoryStack.getCapability(BotaniaForgeCapabilities.BLOCK_PROVIDER).resolve(); | ||
if(provOptional.isEmpty()) return 0; | ||
|
||
IBlockProvider prov = provOptional.get(); | ||
int provCount = prov.getBlockCount(player, inventoryStack, Block.byItem(itemStack.getItem())); | ||
if(provCount == -1) | ||
return Integer.MAX_VALUE; | ||
return provCount; | ||
} | ||
|
||
@Override | ||
public int useItems(Player player, ItemStack itemStack, ItemStack inventoryStack, int count) { | ||
IBlockProvider prov = (IBlockProvider) inventoryStack.getItem(); | ||
if(prov.provideBlock(player, itemStack, inventoryStack, Block.byItem(itemStack.getItem()), true)) | ||
Optional<IBlockProvider> provOptional = inventoryStack.getCapability(BotaniaForgeCapabilities.BLOCK_PROVIDER).resolve(); | ||
if(provOptional.isEmpty()) return 0; | ||
|
||
IBlockProvider prov = provOptional.get(); | ||
if(prov.provideBlock(player, inventoryStack, Block.byItem(itemStack.getItem()), true)) | ||
return 0; | ||
return count; | ||
} | ||
} | ||
*/ | ||
} |