本文整理匯總了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);
}
示例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);
}
}
}
}
}
}
示例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;
}
示例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;
}
}
示例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);
}
}
}
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}