Search in sources :

Example 6 with IEntangledStack

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

the class BlockBlinker method onBlockPlacedBy.

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

Example 7 with IEntangledStack

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

the class BlockNeutronBattery method getItem.

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

Example 8 with IEntangledStack

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

the class BlockNeutronBattery method onBlockPlacedBy.

@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
    if (!world.isRemote) {
        getTile(TileNeutronBattery.class, world, pos).ifPresent(neutron -> {
            IEntangledStack entangled = (IEntangledStack) stack.getItem();
            if (!entangled.getKey(stack).isPresent()) {
                entangled.setKey(stack, UUID.randomUUID());
            }
            entangled.getKey(stack).ifPresent(neutron::setKey);
            if (placer instanceof EntityPlayer && ((EntityPlayer) placer).capabilities.isCreativeMode) {
                ILumen lumen = neutron.getCapability(ModCapability.LUMEN_CAPABILITY, EnumFacing.UP);
                if (lumen != null) {
                    // CHEATER!!
                    lumen.set(neutron.getCapacityLazy().max);
                }
            }
        });
    }
}
Also used : IEntangledStack(arekkuusu.solar.api.entanglement.IEntangledStack) ILumen(arekkuusu.solar.api.entanglement.energy.data.ILumen) TileNeutronBattery(arekkuusu.solar.common.block.tile.TileNeutronBattery) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Example 9 with IEntangledStack

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

the class BlockQelaion method onBlockActivated.

@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    if (world.isRemote)
        return true;
    ItemStack stack = player.getHeldItem(hand);
    if (stack.getItem() == ModItems.QELAION) {
        Optional<TileQelaion> optional = getTile(TileQelaion.class, world, pos);
        if (optional.isPresent()) {
            TileQelaion qelaion = optional.get();
            Optional<UUID> nodes = ((IEntangledStack) stack.getItem()).getKey(stack);
            Optional<UUID> parent = qelaion.getKey();
            if (nodes.isPresent() && parent.isPresent()) {
                qelaion.setNodes(nodes.get());
                return true;
            }
            return false;
        }
    } else if (stack.isEmpty()) {
        getTile(TileQelaion.class, world, pos).ifPresent(qelaion -> {
            if (!player.isSneaking()) {
                qelaion.put(facing);
            } else
                qelaion.setNodes(null);
        });
    }
    return false;
}
Also used : TileQelaion(arekkuusu.solar.common.block.tile.TileQelaion) DummyBakedRegistry(arekkuusu.solar.client.util.baker.DummyBakedRegistry) Item(net.minecraft.item.Item) IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState) AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) IEntangledStack(arekkuusu.solar.api.entanglement.IEntangledStack) EnumHand(net.minecraft.util.EnumHand) FXUtil(arekkuusu.solar.client.effect.FXUtil) LibNames(arekkuusu.solar.common.lib.LibNames) ModelHandler(arekkuusu.solar.client.util.helper.ModelHandler) BlockStateContainer(net.minecraft.block.state.BlockStateContainer) Random(java.util.Random) Quat(net.katsstuff.mirror.data.Quat) ItemStack(net.minecraft.item.ItemStack) BakedQelaion(arekkuusu.solar.client.util.baker.baked.BakedQelaion) NBTHelper(arekkuusu.solar.api.helper.NBTHelper) ModItems(arekkuusu.solar.common.item.ModItems) Side(net.minecraftforge.fml.relauncher.Side) NonNullList(net.minecraft.util.NonNullList) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) Light(arekkuusu.solar.client.effect.Light) IBlockAccess(net.minecraft.world.IBlockAccess) Nullable(javax.annotation.Nullable) Direction(arekkuusu.solar.api.state.Direction) World(net.minecraft.world.World) Vector3(net.katsstuff.mirror.data.Vector3) PropertyBool(net.minecraft.block.properties.PropertyBool) EnumFacing(net.minecraft.util.EnumFacing) BlockPos(net.minecraft.util.math.BlockPos) UUID(java.util.UUID) IBlockState(net.minecraft.block.state.IBlockState) MinecraftForge(net.minecraftforge.common.MinecraftForge) List(java.util.List) FixedMaterial(arekkuusu.solar.api.util.FixedMaterial) TileQelaion(arekkuusu.solar.common.block.tile.TileQelaion) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) Optional(java.util.Optional) TileEntity(net.minecraft.tileentity.TileEntity) IEntangledStack(arekkuusu.solar.api.entanglement.IEntangledStack) ItemStack(net.minecraft.item.ItemStack) UUID(java.util.UUID)

Example 10 with IEntangledStack

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

the class BlockQelaion method onBlockPlacedBy.

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

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