Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class GraftlingCertaintyFeat {
- private static final ResourceLocation NAME = new ResourceLocation(EposAPI.ID, "graftling_certainty");
- @SuppressWarnings({"ConstantConditions", "deprecation"})
- public static final Feat FEAT =
- FeatBuilder.start(NAME)
- .withEventHandler(BlockEvent.HarvestDropsEvent.class,
- (harvestDropsEvent, entity, iCharacterStats) -> {
- if (harvestDropsEvent.getState().getBlock() instanceof LeavesBlock && !harvestDropsEvent.isSilkTouching()) {
- LeavesBlock block = (LeavesBlock) harvestDropsEvent.getState().getBlock();
- boolean containsSapling = false;
- List<ItemStack> stacks = harvestDropsEvent.getDrops();
- for (ItemStack stack : stacks) {
- if (stack.getItem().isIn(ItemTags.SAPLINGS)) {
- containsSapling = true;
- }
- }
- if (block.isIn(BlockTags.LEAVES) && !containsSapling) {
- LootContext.Builder context = new LootContext.Builder(entity.world.getServer().getWorld(entity.dimension));
- List<ItemStack> stackList = new ArrayList<>();
- for (int i = 0; i < 10; i++) stackList.addAll(block.getDrops(harvestDropsEvent.getState(), context));
- for (ItemStack stack : stackList) {
- if (stack.getItem().isIn(ItemTags.SAPLINGS)) {
- harvestDropsEvent.getDrops().add(new ItemStack(stack.getItem(), 1));
- }
- }
- }
- harvestDropsEvent.setDropChance(1f);
- }
- }).finish();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement