Added bags-right-clicking-to-put-items-into-chests-feature.

Closes #193
This commit is contained in:
Ellpeck 2016-08-07 01:11:01 +02:00
parent 3976ceee86
commit 9c0fc504b7
3 changed files with 51 additions and 2 deletions

View file

@ -154,7 +154,7 @@ public final class InitBooklet{
new BookletChapter("leafGen", ActuallyAdditionsAPI.entryGeneratingRF, new ItemStack(InitBlocks.blockLeafGenerator), new PageTextOnly(1).addTextReplacement("<rf>", TileEntityLeafGenerator.ENERGY_PRODUCED).addTextReplacement("<range>", TileEntityLeafGenerator.RANGE), new PageCrafting(2, BlockCrafting.recipeLeafGen)).setImportant();
//No RF Using Items
new BookletChapter("bags", ActuallyAdditionsAPI.entryItemsNonRF, new ItemStack(InitItems.itemBag), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipeBag).setNoText(), new PageCrafting(3, ItemCrafting.recipeVoidBag).setNoText()).setImportant();
new BookletChapter("bags", ActuallyAdditionsAPI.entryItemsNonRF, new ItemStack(InitItems.itemBag), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipeBag), new PageCrafting(3, ItemCrafting.recipeVoidBag).setNoText()).setImportant();
new BookletChapter("wings", ActuallyAdditionsAPI.entryItemsNonRF, new ItemStack(InitItems.itemWingsOfTheBats), new PageTextOnly(1).setStacks(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.BAT_WING.ordinal())), new PageCrafting(2, ItemCrafting.recipeWings).setNoText()).setSpecial();
new BookletChapter("foods", ActuallyAdditionsAPI.entryItemsNonRF, new ItemStack(InitItems.itemFoods, 1, TheFoods.HAMBURGER.ordinal()), new PageCrafting(1, FoodCrafting.recipeBacon).setNoText(), new PageFurnace(2, new ItemStack(InitItems.itemFoods, 1, TheFoods.RICE_BREAD.ordinal())).setNoText(), new PageCrafting(3, FoodCrafting.recipeHamburger).setNoText(), new PageCrafting(4, FoodCrafting.recipeBigCookie).setNoText(), new PageCrafting(5, FoodCrafting.recipeSubSandwich).setNoText(), new PageCrafting(6, FoodCrafting.recipeFrenchFry).setNoText(), new PageCrafting(7, FoodCrafting.recipeFrenchFries).setNoText(), new PageCrafting(8, FoodCrafting.recipeFishNChips).setNoText(), new PageCrafting(9, FoodCrafting.recipeCheese).setNoText(), new PageCrafting(10, FoodCrafting.recipePumpkinStew).setNoText(), new PageCrafting(11, FoodCrafting.recipeCarrotJuice).setNoText(), new PageCrafting(12, FoodCrafting.recipeSpaghetti).setNoText(), new PageCrafting(13, FoodCrafting.recipeNoodle).setNoText(), new PageCrafting(14, FoodCrafting.recipeChocolate).setNoText(), new PageCrafting(15, FoodCrafting.recipeChocolateCake).setNoText(), new PageCrafting(16, FoodCrafting.recipeToast).setNoText(), new PageFurnace(17, new ItemStack(InitItems.itemFoods, 1, TheFoods.BAGUETTE.ordinal())).setNoText(), new PageCrafting(18, FoodCrafting.recipeChocolateToast).setNoText(), new PageCrafting(1, FoodCrafting.recipePizza).setNoText());
new BookletChapter("leafBlower", ActuallyAdditionsAPI.entryItemsNonRF, new ItemStack(InitItems.itemLeafBlowerAdvanced), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipeLeafBlower).setNoText(), new PageCrafting(3, ItemCrafting.recipeLeafBlowerAdvanced).setNoText()).setImportant();

View file

@ -20,14 +20,19 @@ import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.EntityItemPickupEvent;
import net.minecraftforge.fml.common.eventhandler.Event;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;
public class ItemBag extends ItemBase{
@ -38,7 +43,9 @@ public class ItemBag extends ItemBase{
this.isVoid = isVoid;
this.setMaxStackSize(1);
MinecraftForge.EVENT_BUS.register(this);
if(!this.isVoid){ //So that the event stuff only runs once because this class is initialized twice
MinecraftForge.EVENT_BUS.register(this);
}
}
@SubscribeEvent
@ -111,6 +118,47 @@ public class ItemBag extends ItemBase{
}
}
@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ){
if(!this.isVoid){
TileEntity tile = worldIn.getTileEntity(pos);
if(tile != null && tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing)){
if(!worldIn.isRemote){
IItemHandler handler = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing);
if(handler != null){
boolean changed = false;
ItemStack[] inventory = new ItemStack[ContainerBag.getSlotAmount(this.isVoid)];
ItemDrill.loadSlotsFromNBT(inventory, stack);
for(int j = 4; j < inventory.length; j++){
ItemStack invStack = inventory[j];
if(invStack != null){
for(int i = 0; i < handler.getSlots(); i++){
ItemStack remain = handler.insertItem(i, invStack, false);
if(!ItemStack.areItemStacksEqual(remain, invStack)){
inventory[j] = remain == null ? null : remain.copy();
changed = true;
if(remain == null){
break;
}
}
}
}
}
if(changed){
ItemDrill.writeSlotsToNBT(inventory, stack);
}
}
}
return EnumActionResult.SUCCESS;
}
}
return EnumActionResult.PASS;
}
@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand){
if(!world.isRemote){

View file

@ -1014,6 +1014,7 @@ booklet.actuallyadditions.chapter.worms.text.2=<i>A worm at work
booklet.actuallyadditions.chapter.bags.name=Bag and Void Bag
booklet.actuallyadditions.chapter.bags.text.1=<item>Bags<r> are an easy way to <imp>transport items around<r>, however, they have some additional functions. <n>First of all, in their GUI that is accessed by <imp>right-clicking<r>, they can be set to automatically <imp>suck up items on the ground<r>. Also, they have a couple of <imp>filter slots<r> where you can configure what can actually go into the bags. <n><n><item>Void Bags<r> have the same functionality as normal bags, however, they <imp>remove items<r> from the world instead of storing them.
booklet.actuallyadditions.chapter.bags.text.2=Additionally, <item>Bags<r> can be, when filled up with a lot of items, <imp>right-clicked on a container<r> like a Chest or a <item>Storage Crate<r> to quickly <imp>move all of the items<r> in the bag into the chest.
booklet.actuallyadditions.chapter.empowerer.name=Empowerer
booklet.actuallyadditions.chapter.empowerer.text.1=The <item>Empowerer<r> is a mid-tier block that can be used to <imp>empower<r> crystals and other items. <n>To use it, items that should be empowered can be <imp>right-clicked onto the Empowerer<r>, and empowering items need to be placed on <item>Display Stands<r> that are <imp>two blocks away<r>, like seen in the <imp>picture on the next page<r>. <n>To then activate the process, <imp>every Display Stand needs to be powered with a lot of RF<r> that is then drained to empower the item on the Empowerer.