Search in sources :

Example 11 with IEntangledStack

use of arekkuusu.solar.api.entanglement.IEntangledStack in project Solar by ArekkuusuJerii.

the class BlockQelaion method getItem.

@Override
public ItemStack getItem(World world, BlockPos pos, IBlockState state) {
    Optional<TileQelaion> optional = getTile(TileQelaion.class, world, pos);
    if (optional.isPresent()) {
        TileQelaion qelaion = optional.get();
        ItemStack stack = new ItemStack(Item.getItemFromBlock(this));
        qelaion.getKey().ifPresent(uuid -> {
            ((IEntangledStack) stack.getItem()).setKey(stack, uuid);
        });
        if (qelaion.getNodes() != null) {
            NBTHelper.setUniqueID(stack, "nodes", qelaion.getNodes());
        }
        return stack;
    }
    return super.getItem(world, pos, state);
}
Also used : TileQelaion(arekkuusu.solar.common.block.tile.TileQelaion) IEntangledStack(arekkuusu.solar.api.entanglement.IEntangledStack) ItemStack(net.minecraft.item.ItemStack)

Example 12 with IEntangledStack

use of arekkuusu.solar.api.entanglement.IEntangledStack in project Solar by ArekkuusuJerii.

the class BlockQimranut method onBlockPlacedBy.

@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
    if (!world.isRemote) {
        getTile(TileQimranut.class, world, pos).ifPresent(qimranut -> {
            IEntangledStack entangled = (IEntangledStack) stack.getItem();
            Optional<UUID> optional = entangled.getKey(stack);
            if (!optional.isPresent() || RelativityHandler.getRelatives(optional.get()).size() >= 2) {
                entangled.setKey(stack, UUID.randomUUID());
            }
            entangled.getKey(stack).ifPresent(qimranut::setKey);
        });
    }
}
Also used : IEntangledStack(arekkuusu.solar.api.entanglement.IEntangledStack) TileQimranut(arekkuusu.solar.common.block.tile.TileQimranut) UUID(java.util.UUID)

Example 13 with IEntangledStack

use of arekkuusu.solar.api.entanglement.IEntangledStack in project Solar by ArekkuusuJerii.

the class BlockQimranut method getItem.

@Override
public ItemStack getItem(World world, BlockPos pos, IBlockState state) {
    Optional<TileQimranut> optional = getTile(TileQimranut.class, world, pos);
    if (optional.isPresent()) {
        TileQimranut qimranut = optional.get();
        ItemStack stack = new ItemStack(Item.getItemFromBlock(this));
        qimranut.getKey().ifPresent(uuid -> {
            ((IEntangledStack) stack.getItem()).setKey(stack, uuid);
        });
        return stack;
    }
    return super.getItem(world, pos, state);
}
Also used : IEntangledStack(arekkuusu.solar.api.entanglement.IEntangledStack) TileQimranut(arekkuusu.solar.common.block.tile.TileQimranut) ItemStack(net.minecraft.item.ItemStack)

Example 14 with IEntangledStack

use of arekkuusu.solar.api.entanglement.IEntangledStack in project Solar by ArekkuusuJerii.

the class BlockQuantumMirror method getItem.

@Override
public ItemStack getItem(World world, BlockPos pos, IBlockState state) {
    Optional<TileQuantumMirror> optional = getTile(TileQuantumMirror.class, world, pos);
    if (optional.isPresent()) {
        TileQuantumMirror mirror = optional.get();
        ItemStack stack = new ItemStack(Item.getItemFromBlock(this));
        mirror.getKey().ifPresent(uuid -> {
            ((IEntangledStack) stack.getItem()).setKey(stack, uuid);
        });
        return stack;
    }
    return super.getItem(world, pos, state);
}
Also used : IEntangledStack(arekkuusu.solar.api.entanglement.IEntangledStack) ItemStack(net.minecraft.item.ItemStack) TileQuantumMirror(arekkuusu.solar.common.block.tile.TileQuantumMirror)

Example 15 with IEntangledStack

use of arekkuusu.solar.api.entanglement.IEntangledStack in project Solar by ArekkuusuJerii.

the class BlockAlternator method onBlockPlacedBy.

@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
    if (!world.isRemote) {
        getTile(TileAlternator.class, world, pos).ifPresent(alternator -> {
            IEntangledStack entangled = (IEntangledStack) stack.getItem();
            if (!entangled.getKey(stack).isPresent()) {
                entangled.setKey(stack, UUID.randomUUID());
            }
            entangled.getKey(stack).ifPresent(alternator::setKey);
        });
    }
}
Also used : IEntangledStack(arekkuusu.solar.api.entanglement.IEntangledStack) TileAlternator(arekkuusu.solar.common.block.tile.TileAlternator)

Aggregations

IEntangledStack (arekkuusu.solar.api.entanglement.IEntangledStack)15 ItemStack (net.minecraft.item.ItemStack)8 TileQelaion (arekkuusu.solar.common.block.tile.TileQelaion)3 TileAlternator (arekkuusu.solar.common.block.tile.TileAlternator)2 TileBlinker (arekkuusu.solar.common.block.tile.TileBlinker)2 TileMechanicalTranslocator (arekkuusu.solar.common.block.tile.TileMechanicalTranslocator)2 TileNeutronBattery (arekkuusu.solar.common.block.tile.TileNeutronBattery)2 TileQimranut (arekkuusu.solar.common.block.tile.TileQimranut)2 TileQuantumMirror (arekkuusu.solar.common.block.tile.TileQuantumMirror)2 UUID (java.util.UUID)2 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 ILumen (arekkuusu.solar.api.entanglement.energy.data.ILumen)1 NBTHelper (arekkuusu.solar.api.helper.NBTHelper)1 Direction (arekkuusu.solar.api.state.Direction)1 FixedMaterial (arekkuusu.solar.api.util.FixedMaterial)1 FXUtil (arekkuusu.solar.client.effect.FXUtil)1 Light (arekkuusu.solar.client.effect.Light)1 DummyBakedRegistry (arekkuusu.solar.client.util.baker.DummyBakedRegistry)1 BakedQelaion (arekkuusu.solar.client.util.baker.baked.BakedQelaion)1 ModelHandler (arekkuusu.solar.client.util.helper.ModelHandler)1