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);
}
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;
}
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);
}
Aggregations