當前位置: 首頁>>代碼示例>>Java>>正文


Java IBauble類代碼示例

本文整理匯總了Java中baubles.api.IBauble的典型用法代碼示例。如果您正苦於以下問題:Java IBauble類的具體用法?Java IBauble怎麽用?Java IBauble使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


IBauble類屬於baubles.api包,在下文中一共展示了IBauble類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: matches

import baubles.api.IBauble; //導入依賴的package包/類
@Override
public boolean matches(@Nonnull InventoryCrafting inv, @Nonnull World worldIn) {
    ItemStack ring = null;
    for(int i = 0; i < inv.getSizeInventory(); i++) {
        ItemStack stack = inv.getStackInSlot(i);
        if (stack != null) {
            if (ring != null) {
                return false;
            }
            if (stack.getItem() instanceof IBauble) {
                ring = stack.copy();
            } else {
                return false;
            }
        }
    }

    return ring != null && NBTHelper.getBoolean(ring, IJCConstants.NBT.BAUBLE_HOLDER);
}
 
開發者ID:yolp900,項目名稱:ItsJustaCharm1.10.2Dead,代碼行數:20,代碼來源:RingRemovalRecipe.java

示例2: onPlayerTick

import baubles.api.IBauble; //導入依賴的package包/類
@SubscribeEvent
public void onPlayerTick(TickEvent.PlayerTickEvent event) {
    EntityPlayer player = event.player;

    if (!player.worldObj.isRemote) {
        IInventory baublesInventory = BaublesApi.getBaubles(player);
        List<ItemStack> rings = new ArrayList<>();
        rings.add(baublesInventory.getStackInSlot(1));
        rings.add(baublesInventory.getStackInSlot(2));

        for (ItemStack ring : rings) {
            if (ring != null && ring.getItem() instanceof IBauble && NBTHelper.getBoolean(ring, IJCConstants.NBT.BAUBLE_HOLDER)) {
                ItemStack baubleAttached0 = NBTHelper.getItemStack(ring, IJCConstants.NBT.BAUBLE_ATTACHED(0));
                if (baubleAttached0 != null) {
                    ((IBauble) baubleAttached0.getItem()).onWornTick(baubleAttached0, player);
                }
                if (NBTHelper.getBoolean(ring, IJCConstants.NBT.ADVANCED_BAUBLE_HOLDER)) {
                    ItemStack baubleAttached1 = NBTHelper.getItemStack(ring, IJCConstants.NBT.BAUBLE_ATTACHED(1));
                    if (baubleAttached1 != null) {
                        ((IBauble) baubleAttached1.getItem()).onWornTick(baubleAttached1, player);
                    }
                }
            }
        }
    }
}
 
開發者ID:yolp900,項目名稱:ItsJustaCharm1.10.2Dead,代碼行數:27,代碼來源:EventBaubleTick.java

示例3: transferStackInSlot

import baubles.api.IBauble; //導入依賴的package包/類
@Hook("net.minecraft.inventory.ContainerPlayer#func_82846_b")
public static final Hook.Result transferStackInSlot(ContainerPlayer container, EntityPlayer player, int index) {
	Slot slot = container.inventorySlots.get(index);
	int id = container.inventorySlots.size();
	if (slot != null && slot.getHasStack()) {
		ItemStack item = slot.getStack();
		if (item.getItem() instanceof IBauble && container.mergeItemStack(item, id - AlchemyBaubles.getBaublesSize(), id, false)) {
			if (item.getCount() == 0)
				slot.putStack(ItemStack.EMPTY);
			else
				slot.onSlotChanged();
			return new Hook.Result(ItemStack.EMPTY);
		}
	}
	return Hook.Result.VOID;
}
 
開發者ID:NekoCaffeine,項目名稱:Alchemy,代碼行數:17,代碼來源:CapabilityBauble.java

示例4: isItemValid

import baubles.api.IBauble; //導入依賴的package包/類
@Override
public boolean isItemValid(ItemStack stack) {
    Item item = stack.getItem();
    if (type >= ARMOR_HELMET && type <= ARMOR_BOOTS) {
        return item != null && item.isValidArmor(stack, type, null);
    } else if (GearSwap.baubles && type >= BAUBLE_RING && type <= BAUBLE_BELT) {
        if (item == null) {
            return false;
        }
        if (!(item instanceof IBauble)) {
            return false;
        }
        IBauble bauble = (IBauble) item;
        BaubleType baubleType = bauble.getBaubleType(stack);
        return (baubleType == BaubleType.AMULET && type == BAUBLE_AMULET) ||
                (baubleType == BaubleType.RING && type == BAUBLE_RING) ||
                (baubleType == BaubleType.BELT && type == BAUBLE_BELT);
    } else {
        return true;
    }
}
 
開發者ID:McJty,項目名稱:GearSwapper1.8,代碼行數:22,代碼來源:GhostSlot.java

示例5: playerTick

import baubles.api.IBauble; //導入依賴的package包/類
@SubscribeEvent
public void playerTick(PlayerEvent.LivingUpdateEvent event) {
	
	//player events
	if (event.entity instanceof EntityPlayer) {
		EntityPlayer player = (EntityPlayer)event.entity;
		
		InventoryBaubles baubles = PlayerHandler.getPlayerBaubles(player);
		for (int a=0;a<baubles.getSizeInventory();a++) {
			if (baubles.getStackInSlot(a)!=null && baubles.getStackInSlot(a).getItem() instanceof IBauble) {
				((IBauble)baubles.getStackInSlot(a).getItem()).onWornTick(baubles.getStackInSlot(a), player);
			}
		}
		
	}
	
}
 
開發者ID:Romejanic,項目名稱:RuneMagic,代碼行數:18,代碼來源:EventHandlerEntity.java

示例6: isItemValidForSlot

import baubles.api.IBauble; //導入依賴的package包/類
/**
 * Returns true if automation is allowed to insert the given stack (ignoring
 * stack size) into the given slot.
 */
@Override
public boolean isItemValidForSlot(int i, ItemStack stack) {
	if (stack == null || !(stack.getItem() instanceof IBauble)
			|| !((IBauble) stack.getItem()).canEquip(stack, player.get()))
		return false;
	if (i == 0
			&& ((IBauble) stack.getItem()).getBaubleType(stack) == BaubleType.AMULET)
		return true;
	if ((i == 1 || i == 2)
			&& ((IBauble) stack.getItem()).getBaubleType(stack) == BaubleType.RING)
		return true;
	if (i == 3
			&& ((IBauble) stack.getItem()).getBaubleType(stack) == BaubleType.BELT)
		return true;
	return false;
}
 
開發者ID:Romejanic,項目名稱:RuneMagic,代碼行數:21,代碼來源:InventoryBaubles.java

示例7: isItemValidForSlot

import baubles.api.IBauble; //導入依賴的package包/類
/**
 * Returns true if automation is allowed to insert the given stack (ignoring
 * stack size) into the given slot.
 */
@Override
public boolean isItemValidForSlot(int slot, ItemStack stack, EntityLivingBase player) {
	if (stack==null || stack.isEmpty() || !(stack.getItem() instanceof IBauble) ||
			!((IBauble) stack.getItem()).canEquip(stack, player))
		return false;		
	return ((IBauble) stack.getItem()).getBaubleType(stack).hasSlot(slot);
}
 
開發者ID:inifire201,項目名稱:MagicWinds,代碼行數:12,代碼來源:BaublesContainer.java

示例8: isItemValid

import baubles.api.IBauble; //導入依賴的package包/類
/**
 * Check if the stack is a valid item for this slot. 
 */
@Override
public boolean isItemValid(ItemStack stack)
{
	return !ItemStackTools.isNullStack(stack) && stack.getItem() !=null &&
    	   stack.getItem() instanceof IBauble && 
    	   ((IBauble)stack.getItem()).getBaubleType(stack).hasSlot(baubleSlot) &&
    	   ((IBauble)stack.getItem()).canEquip(stack, player);
}
 
開發者ID:Alec-WAM,項目名稱:CrystalMod,代碼行數:12,代碼來源:SlotBauble.java

示例9: onTake

import baubles.api.IBauble; //導入依賴的package包/類
@Override
public ItemStack onTake(EntityPlayer playerIn, ItemStack stack) {
	if (!getHasStack() && !((IBaublesItemHandler)getItemHandler()).isEventBlocked()) {
		((IBauble)stack.getItem()).onUnequipped(stack, playerIn);
	}
	return super.onTake(playerIn, stack);		
}
 
開發者ID:Alec-WAM,項目名稱:CrystalMod,代碼行數:8,代碼來源:SlotBauble.java

示例10: putStack

import baubles.api.IBauble; //導入依賴的package包/類
@Override
public void putStack(ItemStack stack) {		
	if (getHasStack() && !((IBaublesItemHandler)getItemHandler()).isEventBlocked()) {
		((IBauble)getStack().getItem()).onUnequipped(getStack(), player);
	}
	
	super.putStack(stack);	
	
	if (this.getHasStack() && !((IBaublesItemHandler)getItemHandler()).isEventBlocked()) {
		((IBauble)getStack().getItem()).onEquipped(getStack(), player);
	}
}
 
開發者ID:Alec-WAM,項目名稱:CrystalMod,代碼行數:13,代碼來源:SlotBauble.java

示例11: isItemValidForSlot

import baubles.api.IBauble; //導入依賴的package包/類
/**
 * Returns true if automation is allowed to insert the given stack (ignoring
 * stack size) into the given slot.
 */
@Override
public boolean isItemValidForSlot(int slot, ItemStack stack, EntityLivingBase player) {
	if (stack==null || stack.isEmpty() || !(stack.getItem() instanceof IBauble) ||
			!((IBauble) stack.getItem()).canEquip(stack, player))
		return false;
	
	return ((IBauble) stack.getItem()).getBaubleType(stack).hasSlot(slot);
}
 
開發者ID:Alec-WAM,項目名稱:CrystalMod,代碼行數:13,代碼來源:BaublesContainer.java

示例12: matches

import baubles.api.IBauble; //導入依賴的package包/類
@Override
public boolean matches(@Nonnull InventoryCrafting inv, @Nonnull World worldIn) {
	List<ItemStack> ingredients = new ArrayList<>();
	for (int i = 0; i < inv.getSizeInventory(); i++) {
		ItemStack stack = inv.getStackInSlot(i);
		if (stack != null) {
			if (stack.getItem() instanceof IBauble && ((IBauble)stack.getItem()).getBaubleType(stack) == BaubleType.RING) {
				ingredients.add(stack);
			}
		}
	}

	if (ingredients.size() != 2) return false;

	ItemStack ringHolder;
	ItemStack ring;
	if (isItemStackHolder(ingredients.get(0)) && !isItemStackHolder(ingredients.get(1))) {
		ringHolder = ingredients.get(0);
		ring = ingredients.get(1);
	} else if (isItemStackHolder(ingredients.get(1)) && !isItemStackHolder(ingredients.get(0))) {
		ringHolder = ingredients.get(1);
		ring = ingredients.get(0);
	} else return false;

	if (ring == null || ringHolder == null) return false;

	boolean canAttachRing = false;
	List<ItemStack> attachedRings = getAttachedRings(ringHolder);
	if (attachedRings.get(0) == null) {
		canAttachRing = true;
	} else if (isAdvancedHolder(ringHolder) && attachedRings.get(1) == null) {
		if (!ItemStack.areItemStacksEqual(ring, attachedRings.get(0))) {
			canAttachRing = true;
		}
	} else return false;

	return !ItemStack.areItemStacksEqual(ring, ringHolder) && canAttachRing;

}
 
開發者ID:yolp900,項目名稱:ItsJustaCharm1.10.2Dead,代碼行數:40,代碼來源:RingAttachmentRecipe.java

示例13: getCraftingResult

import baubles.api.IBauble; //導入依賴的package包/類
@Nullable
@Override
public ItemStack getCraftingResult(@Nonnull InventoryCrafting inv) {
    ItemStack ring = null;

    for (int i = 0; i < inv.getSizeInventory(); i++) {
        ItemStack stack = inv.getStackInSlot(i);
        if (stack != null)
            ring = stack.copy();
    }

    if (ring == null || !(ring.getItem() instanceof IBauble) || !NBTHelper.getBoolean(ring, IJCConstants.NBT.BAUBLE_HOLDER)) {
        return null;
    }

    ItemStack output;
    ItemStack ring0 = NBTHelper.getItemStack(ring, IJCConstants.NBT.BAUBLE_ATTACHED(0));
    boolean advanced = NBTHelper.getBoolean(ring, IJCConstants.NBT.ADVANCED_BAUBLE_HOLDER);
    if (ring0 == null) {
        int meta = 0;
        if (advanced) {
            meta = 1;
        }
        output = new ItemStack(ModItems.BaubleRingHolder, 1, meta);
    } else {
        if (advanced) {
            ItemStack ring1 = NBTHelper.getItemStack(ring, IJCConstants.NBT.BAUBLE_ATTACHED(1));
            if (ring1 == null) {
                output = ring0.copy();
            } else {
                output = ring1.copy();
            }
        } else {
            output = ring0.copy();
        }
    }

    return output;
}
 
開發者ID:yolp900,項目名稱:ItsJustaCharm1.10.2Dead,代碼行數:40,代碼來源:RingRemovalRecipe.java

示例14: isItemValidForSlot

import baubles.api.IBauble; //導入依賴的package包/類
/**
 * Returns true if automation is allowed to insert the given stack (ignoring
 * stack size) into the given slot.
 */
@Override
public boolean isItemValidForSlot(int slot, ItemStack stack, EntityLivingBase player) {
	if (stack == null || !(stack.getItem() instanceof IBauble) ||
			!((IBauble) stack.getItem()).canEquip(stack, player))
		return false;
	
	return ((IBauble) stack.getItem()).getBaubleType(stack).hasSlot(slot);
}
 
開發者ID:yolp900,項目名稱:ItsJustaCharm1.10.2Dead,代碼行數:13,代碼來源:BaublesContainer.java

示例15: change

import baubles.api.IBauble; //導入依賴的package包/類
public void change(ItemStack old, ItemStack _new) {
	if (isEventBlocked())
		return;
	if (!old.isEmpty())
		((IBauble) old.getItem()).onUnequipped(old, living);
	if (!_new.isEmpty())
		((IBauble) _new.getItem()).onEquipped(_new, living);
}
 
開發者ID:NekoCaffeine,項目名稱:Alchemy,代碼行數:9,代碼來源:InventoryBauble.java


注:本文中的baubles.api.IBauble類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。