use of net.silentchaos512.gems.item.ItemChaosGem in project SilentGems by SilentChaos512.
the class MessageToggleChaosGem method handleMessage.
@Override
public IMessage handleMessage(MessageContext context) {
if (context.side != Side.SERVER)
return null;
EntityPlayer player = context.getServerHandler().player;
Predicate<ItemStack> predicate = s -> s.getItem() instanceof ItemChaosGem;
ItemStackList stacks = BaublesCompat.getBaubles(player, predicate);
stacks.addAll(PlayerHelper.getNonEmptyStacks(player, predicate));
for (ItemStack stack : stacks) {
if (stack.getItem() instanceof ItemChaosGem) {
ItemChaosGem item = (ItemChaosGem) stack.getItem();
item.setEnabled(stack, !item.isEnabled(stack));
if (item.isEnabled(stack))
item.applyEffects(stack, player);
else
item.removeEffects(stack, player);
if (!all)
return null;
}
}
return null;
}
use of net.silentchaos512.gems.item.ItemChaosGem in project SilentGems by SilentChaos512.
the class RecipeChaosGemUpgrade method getCraftingResult.
@Override
public ItemStack getCraftingResult(InventoryCrafting inv) {
ItemStack chaosGem = StackHelper.empty();
// Find the Chaos Gem.
for (ItemStack stack : getNonEmptyStacks(inv)) {
if (stack.getItem() instanceof ItemChaosGem) {
chaosGem = StackHelper.safeCopy(stack);
}
}
// Found Chaos Gem?
if (StackHelper.isEmpty(chaosGem)) {
return StackHelper.empty();
}
ItemChaosGem itemGem = (ItemChaosGem) chaosGem.getItem();
// Find runes and apply them.
for (ItemStack stack : getNonEmptyStacks(inv)) {
if (stack.getItem() instanceof ItemChaosRune) {
ItemChaosRune itemRune = (ItemChaosRune) stack.getItem();
if (!itemGem.addBuff(chaosGem, itemRune.getBuff(stack)))
return StackHelper.empty();
}
}
return chaosGem;
}
use of net.silentchaos512.gems.item.ItemChaosGem in project SilentGems by SilentChaos512.
the class BlockChaosPlinth method clOnBlockActivated.
@Override
protected boolean clOnBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
ItemStack heldItem = player.getHeldItem(hand);
TileEntity t = world.getTileEntity(pos);
if (t != null && t instanceof TileChaosPlinth) {
TileChaosPlinth tile = (TileChaosPlinth) t;
ItemStack currentGem = tile.getStackInSlot(0);
if (StackHelper.isValid(heldItem) && heldItem.getItem() instanceof ItemChaosGem) {
player.setHeldItem(hand, currentGem);
tile.setInventorySlotContents(0, heldItem);
return true;
} else if (StackHelper.isValid(currentGem) && StackHelper.isEmpty(heldItem)) {
// TODO
}
}
return false;
}
use of net.silentchaos512.gems.item.ItemChaosGem in project SilentGems by SilentChaos512.
the class RecipeChaosGemUpgrade method matches.
@Override
public boolean matches(InventoryCrafting inv, World world) {
int countGem = 0;
int countRune = 0;
// Count number of chaos gems and chaos runes.
for (ItemStack stack : getNonEmptyStacks(inv)) {
// Chaos Gem
if (stack.getItem() instanceof ItemChaosGem)
++countGem;
else // Chaos Rune
if (stack.getItem() instanceof ItemChaosRune)
++countRune;
else
return false;
}
// Must have only one chaos gem and one or more chaos runes.
return countGem == 1 && countRune > 0;
}
use of net.silentchaos512.gems.item.ItemChaosGem in project SilentGems by SilentChaos512.
the class TileChaosPlinth method update.
@Override
public void update() {
if (world.isRemote)
return;
// Get the Chaos Gem (if any)
ItemStack stack = getStackInSlot(0);
if (StackHelper.isEmpty(stack) || !(stack.getItem() instanceof ItemChaosGem))
return;
ItemChaosGem item = (ItemChaosGem) stack.getItem();
// TODO
}
Aggregations