Search in sources :

Example 1 with TileQelaion

use of arekkuusu.solar.common.block.tile.TileQelaion in project Solar by ArekkuusuJerii.

the class BlockQelaion method getExtendedState.

@Override
public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) {
    Optional<TileQelaion> optional = getTile(TileQelaion.class, world, pos);
    if (optional.isPresent()) {
        List<EnumFacing> closed = optional.get().getInputs();
        Direction direction = Direction.getDirectionFromFacings(closed.toArray(new EnumFacing[closed.size()]));
        return ((IExtendedBlockState) state).withProperty(Direction.DIR_UNLISTED, direction);
    }
    return super.getExtendedState(state, world, pos);
}
Also used : TileQelaion(arekkuusu.solar.common.block.tile.TileQelaion) IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState) EnumFacing(net.minecraft.util.EnumFacing) Direction(arekkuusu.solar.api.state.Direction)

Example 2 with TileQelaion

use of arekkuusu.solar.common.block.tile.TileQelaion 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 3 with TileQelaion

use of arekkuusu.solar.common.block.tile.TileQelaion 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)

Aggregations

TileQelaion (arekkuusu.solar.common.block.tile.TileQelaion)3 IEntangledStack (arekkuusu.solar.api.entanglement.IEntangledStack)2 Direction (arekkuusu.solar.api.state.Direction)2 ItemStack (net.minecraft.item.ItemStack)2 EnumFacing (net.minecraft.util.EnumFacing)2 IExtendedBlockState (net.minecraftforge.common.property.IExtendedBlockState)2 NBTHelper (arekkuusu.solar.api.helper.NBTHelper)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 ModItems (arekkuusu.solar.common.item.ModItems)1 LibNames (arekkuusu.solar.common.lib.LibNames)1 List (java.util.List)1 Optional (java.util.Optional)1 Random (java.util.Random)1 UUID (java.util.UUID)1 Nullable (javax.annotation.Nullable)1