本文整理汇总了Java中baubles.api.cap.IBaublesItemHandler.getStackInSlot方法的典型用法代码示例。如果您正苦于以下问题:Java IBaublesItemHandler.getStackInSlot方法的具体用法?Java IBaublesItemHandler.getStackInSlot怎么用?Java IBaublesItemHandler.getStackInSlot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类baubles.api.cap.IBaublesItemHandler
的用法示例。
在下文中一共展示了IBaublesItemHandler.getStackInSlot方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findStack
import baubles.api.cap.IBaublesItemHandler; //导入方法依赖的package包/类
@Nullable
public BeltGetter findStack(EntityPlayer player)
{
IBaublesItemHandler baubles = BaublesApi.getBaublesHandler(player);
for (int i = 0; i < baubles.getSlots(); i++)
{
ItemStack inSlot = baubles.getStackInSlot(i);
if (inSlot.getCount() > 0)
{
if (inSlot.getItem() instanceof ItemToolBelt)
{
return new BaublesBeltGetter(player, i);
}
}
}
return super.findStack(player);
}
示例2: getBaubleNBT
import baubles.api.cap.IBaublesItemHandler; //导入方法依赖的package包/类
public static NBTTagCompound getBaubleNBT(IBaublesItemHandler baubles)
{
NBTTagCompound compound = new NBTTagCompound();
NBTTagList tagList = new NBTTagList();
for (int i=0; i<baubles.getSlots(); i++)
{
ItemStack stack = baubles.getStackInSlot(i);
if (stack != null)
{
NBTTagCompound slot = new NBTTagCompound();
stack.writeToNBT(slot);
slot.setInteger("Slot", i);
tagList.appendTag(slot);
}
}
compound.setTag(BAUBLES_NBT, tagList);
compound.setInteger("Size", baubles.getSlots());
return compound;
}
示例3: handleServer
import baubles.api.cap.IBaublesItemHandler; //导入方法依赖的package包/类
@Override
protected void handleServer(ActivateBaubleMessage message, EntityPlayerMP player) {
final IBaublesItemHandler baublesItemHandler = BaublesApi.getBaublesHandler(player);
if (baublesItemHandler == null) {
return;
}
for (int i = 0; i < baublesItemHandler.getSlots(); i++) {
final ItemStack baubleStack = baublesItemHandler.getStackInSlot(i);
if (baubleStack != ItemStack.EMPTY
&& baubleStack.getItem() instanceof BaubleItem) {
((BaubleItem) baubleStack.getItem()).onBaubleActivated(baubleStack, player);
}
}
}
示例4: performChargeAura
import baubles.api.cap.IBaublesItemHandler; //导入方法依赖的package包/类
private void performChargeAura() {
final BlockPos targetPos = getPos();
Predicate<EntityPlayer> playerWithinRangePredicate = input -> input != null
&& input.getPosition().getDistance(targetPos.getX(), targetPos.getY(), targetPos.getZ()) < TMP_MANA_GAIN_DIST;
List<EntityPlayer> playersWithinRange = getWorld().getEntities(EntityPlayer.class, playerWithinRangePredicate::test);
for (EntityPlayer player : playersWithinRange) {
IBaublesItemHandler baublesItemHandler = BaublesApi.getBaublesHandler(player);
for (int i = 0; i < baublesItemHandler.getSlots(); i++) {
final ItemStack baubleStack = baublesItemHandler.getStackInSlot(i);
if (baubleStack != ItemStack.EMPTY
&& baubleStack.getItem() instanceof IChargeable) {
((IChargeable) baubleStack.getItem()).incrementChargeLevel(baubleStack, CHARGE_GAIN_PER_TICK);
}
}
}
}
示例5: onArmorTick
import baubles.api.cap.IBaublesItemHandler; //导入方法依赖的package包/类
@Override
public void onArmorTick(World world, EntityPlayer player,ItemStack itemStack) {
//we are in the armor slot
if(Loader.isModLoaded("baubles")){
if(ConfigHandler.disableDoubleInscription){
//InventoryBaubles baubles = PlayerHandler.getPlayerBaubles(player);
IBaublesItemHandler baubles = BaublesApi.getBaublesHandler(player);
for(int i=0;i<baubles.getSlots();i++){
ItemStack stack = baubles.getStackInSlot(i);
if(!stack.isEmpty() && stack.getItem()==WizardryRegistry.inscription){
return;
}
}
}
}
doTick(world, player, itemStack);
}
示例6: getWornInscription
import baubles.api.cap.IBaublesItemHandler; //导入方法依赖的package包/类
@Override
//XXXuncomment if crash with no Baubles @Optional.Method(modid="Baubles")
public ItemStack getWornInscription(EntityPlayer player) {
//InventoryBaubles baubles = PlayerHandler.getPlayerBaubles(player);
IBaublesItemHandler baubles = BaublesApi.getBaublesHandler(player);
ItemStack baub =ItemStack.EMPTY;
for(int i=0;i<baubles.getSlots();i++){
ItemStack stack = baubles.getStackInSlot(i);
if(!stack.isEmpty() && stack.getItem()==WizardryRegistry.inscription){
baub=stack;
break;
}
}
ItemStack chest = super.getWornInscription(player);
if(!baub.isEmpty()){
if(!chest.isEmpty() && ConfigHandler.disableDoubleInscription)return null;
else return baub;
}
return chest;
}
示例7: onPostRender
import baubles.api.cap.IBaublesItemHandler; //导入方法依赖的package包/类
@SubscribeEvent
public void onPostRender(RenderWorldLastEvent evt) {
if (!Loader.isModLoaded("baubles")) return;
EntityPlayer thePlayer = Minecraft.getMinecraft().player;
for(EntityPlayer entity : Minecraft.getMinecraft().world.playerEntities) {
IBaublesItemHandler baubles = BaublesApi.getBaublesHandler(entity);
ItemStack scarfStack = baubles.getStackInSlot(BAUBLE_AMULET);
if (scarfStack==null || scarfStack.isEmpty() || scarfStack.getItem()!=ThermionicsItems.SCARF) return;
Scarf scarf = scarfCache.getIfPresent(entity);
if (scarf==null) {
scarf = new Scarf();
scarfCache.put(entity, scarf);
scarf.readFromNBT(scarfStack.getTagCompound());
//System.out.println("Created scarf:"+(scarf.leftScarf.size()+scarf.rightScarf.size())+" nodes.");
} else {
scarf.updateFromNBT(scarfStack.getTagCompound());
//System.out.println("Updated scarf:"+(scarf.leftScarf.size()+scarf.rightScarf.size())+" nodes.");
}
double dx = thePlayer.prevPosX + (thePlayer.posX - thePlayer.prevPosX) * evt.getPartialTicks();
double dy = thePlayer.prevPosY + (thePlayer.posY - thePlayer.prevPosY) * evt.getPartialTicks();
double dz = thePlayer.prevPosZ + (thePlayer.posZ - thePlayer.prevPosZ) * evt.getPartialTicks();
LayerScarf.renderScarf(
dx, dy, dz,
entity, null, scarf, evt.getPartialTicks(),
Minecraft.getMinecraft().world);
}
}
示例8: dispatchRenders
import baubles.api.cap.IBaublesItemHandler; //导入方法依赖的package包/类
private void dispatchRenders(IBaublesItemHandler inv, EntityPlayer player, RenderType type, float partialTicks) {
for(int i = 0; i < inv.getSlots(); i++) {
ItemStack stack = inv.getStackInSlot(i);
if(!stack.isEmpty()) {
Item item = stack.getItem();
if(item instanceof IRenderBauble) {
GlStateManager.pushMatrix();
GL11.glColor3ub((byte) 255, (byte) 255, (byte) 255);
GlStateManager.color(1F, 1F, 1F, 1F);
((IRenderBauble) stack.getItem()).onPlayerBaubleRender(stack, player, type, partialTicks);
GlStateManager.popMatrix();
}
}
}
}
示例9: getPlayerBaubles
import baubles.api.cap.IBaublesItemHandler; //导入方法依赖的package包/类
private NBTTagList getPlayerBaubles(EntityPlayerMP player)
{
IBaublesItemHandler baubles = BaublesApi.getBaublesHandler(player);
NBTTagList taglist = new NBTTagList();
for (int i=0; i < baubles.getSlots(); i++)
{
ItemStack stack = baubles.getStackInSlot(i);
NBTTagCompound tag = new NBTTagCompound();
tag.setInteger("Slot", i);
stack.writeToNBT(tag);
taglist.appendTag(tag);
}
return taglist;
}
示例10: onItemRightClick
import baubles.api.cap.IBaublesItemHandler; //导入方法依赖的package包/类
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
if(player.isSneaking()){
//no special case if sneaking
return super.onItemRightClick(world, player, hand);
}
ItemStack stack = player.getHeldItem(hand);
ItemStack toEquip = stack.copy();
toEquip.setCount(1);
if(canEquip(toEquip, player) && Loader.isModLoaded("baubles")) {
//InventoryBaubles baubles = PlayerHandler.getPlayerBaubles(player);
IBaublesItemHandler baubles = BaublesApi.getBaublesHandler(player);
for(int i = 0; i < baubles.getSlots(); i++) {
if(baubles.isItemValidForSlot(i, toEquip,player)) {
ItemStack stackInSlot = baubles.getStackInSlot(i);
if(stackInSlot.isEmpty()) {
if(!world.isRemote) {
baubles.insertItem(i, toEquip,false);
stack.setCount(stack.getCount()-1);
}
return ActionResult.newResult(EnumActionResult.PASS, stack);
}
}
}
}
return super.onItemRightClick(world, player, hand);
}
示例11: getBelt
import baubles.api.cap.IBaublesItemHandler; //导入方法依赖的package包/类
@Override
public ItemStack getBelt()
{
IBaublesItemHandler baubles = BaublesApi.getBaublesHandler(thePlayer);
return baubles.getStackInSlot(slotNumber);
}
示例12: onRenderOverlay
import baubles.api.cap.IBaublesItemHandler; //导入方法依赖的package包/类
@Optional.Method(modid = "baubles")
@SubscribeEvent()
public void onRenderOverlay(RenderGameOverlayEvent e) {
if (e.isCancelable() || e.getType() != RenderGameOverlayEvent.ElementType.POTION_ICONS) {
return;
}
IBaublesItemHandler baublesItemHandler = BaublesApi.getBaublesHandler(minecraft.player);
for (int i = 0; i < baublesItemHandler.getSlots(); i++) {
final ItemStack baubleStack = baublesItemHandler.getStackInSlot(i);
if (baubleStack != ItemStack.EMPTY
&& baubleStack.getItem() instanceof BaubleItem) {
final BaubleItem baubleItem = (BaubleItem) baubleStack.getItem();
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glDisable(GL11.GL_LIGHTING);
// Draw the background for the chargeable item
minecraft.renderEngine.bindTexture(util.getGuiResourceLocation("chargeable_bg.png"));
drawTexturedModalRect(BG_BORDER, (i * (ICON_HEIGHT + ICON_BORDER)) + BG_BORDER, 0, 0, BG_WIDTH, BG_HEIGHT);
// TODO: Draw is currently activated
// Draw the icon of the chargeable item
minecraft.renderEngine.bindTexture(util.getGuiResourceLocation(baubleItem));
drawTexturedModalRect(ICON_BORDER, (i * (ICON_HEIGHT + ICON_BORDER)) + ICON_BORDER, 0, 0, ICON_WIDTH, ICON_HEIGHT);
// Draw the charge level beneath the icon
int maxCharge = baubleItem.getMaxChargeLevel();
int chargeLevel = baubleItem.getChargeLevel(baubleStack);
float chargeRatio = (float) (chargeLevel) / maxCharge;
int chargeWidth = (int) Math.floor(chargeRatio * ICON_WIDTH);
int chargeTop = (i * (ICON_HEIGHT + ICON_BORDER)) + ICON_HEIGHT + ICON_BORDER;
drawRect(ICON_BORDER, chargeTop, ICON_BORDER + chargeWidth, chargeTop + 2, Reference.CHARGE_COLOR);
// TODO: (Maybe) Draw is on cooldown
}
}
}
示例13: getBauble
import baubles.api.cap.IBaublesItemHandler; //导入方法依赖的package包/类
public ItemStack getBauble(EntityPlayer player, BaubleType type) {
final IBaublesItemHandler inv = getBaubles(player);
for (final int slotId : type.getValidSlots())
if (inv != null) {
final ItemStack stack = inv.getStackInSlot(slotId);
if (ItemStackTools.isValid(stack))
return stack;
}
return ItemStackTools.getEmptyStack();
}