mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-11-22 11:53:29 +01:00
added the ability to automate aura bottles
This commit is contained in:
parent
7daacd17e3
commit
78af31e8ab
2 changed files with 29 additions and 0 deletions
|
@ -4,19 +4,25 @@ import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
|||
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
|
||||
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
|
||||
import de.ellpeck.naturesaura.reg.IColorProvidingItem;
|
||||
import net.minecraft.block.BlockDispenser;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.color.IItemColor;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.dispenser.BehaviorDefaultDispenseItem;
|
||||
import net.minecraft.dispenser.IBlockSource;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
|
@ -28,6 +34,25 @@ public class ItemAuraBottle extends ItemImpl implements IColorProvidingItem {
|
|||
public ItemAuraBottle() {
|
||||
super("aura_bottle");
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
|
||||
BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.putObject(Items.GLASS_BOTTLE, new BehaviorDefaultDispenseItem() {
|
||||
@Override
|
||||
protected ItemStack dispenseStack(IBlockSource source, ItemStack stack) {
|
||||
World world = source.getWorld();
|
||||
IBlockState state = source.getBlockState();
|
||||
EnumFacing facing = state.getValue(BlockDispenser.FACING);
|
||||
BlockPos offset = source.getBlockPos().offset(facing);
|
||||
IBlockState offsetState = world.getBlockState(offset);
|
||||
|
||||
ItemStack dispense = stack.splitStack(1);
|
||||
if (offsetState.getBlock().isAir(offsetState, world, offset)) {
|
||||
dispense = setType(new ItemStack(ItemAuraBottle.this), IAuraType.forWorld(world));
|
||||
}
|
||||
|
||||
doDispense(world, dispense, 6, facing, BlockDispenser.getDispensePosition(source));
|
||||
return stack;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
|
|
@ -13,6 +13,10 @@
|
|||
"item": "naturesaura:aura_bottle{stored_type:'naturesaura:overworld'}",
|
||||
"link_recipe": true,
|
||||
"text": "Of course, based on the world that you are currently in, the type of $(aura) collected will slightly vary. For instance, in the normal world, $(aura) can be gathered in the form of sunlight, while in the Nether realm, $(aura) can be gathered in the form of ghosts."
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
"text": "Additionally, the collection of $(aura) in this manner can be automated easily using $(item)Dispensers$(): Putting empty bottles into them will cause them to be shot out with the cork slightly unscrewed, making them fill up with $(aura) in the process. As they are not sucked up by the Dispenser again afterwards, an additional tool like a $(item)Hopper$() is required."
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Reference in a new issue